Class RandomFactory
- java.lang.Object
-
- de.hsh.graja.regression.noisereduction.RandomFactory
-
public class RandomFactory extends Object
A random factory as described in 5.3.5 of the thesis. Allows to allocate random objects with a reproducible seed for assignments. Used by the regression testing mechanism to prevent non-deterministic behavior within assignments that depend on random objects.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
disableMockMode()
Disables mock mode globally Allocated factories might not reflect this behavior when using defaultRandom()static void
enableMockMode()
Enables mock mode globally Allocated factories might not reflect this behavior when using defaultRandom()static Random
regressionTestableRandom()
If in mock mode this will return a new random with the same initial seed and same state.
Useful when multiple tests require a random and the test ordering is non-deterministic.static Random
regressionTestableRandom(long seed)
If in mock mode this will return a new random with the same initial seed and same state.
Useful when multiple tests require a random and the test ordering is non-deterministic.
-
-
-
Method Detail
-
enableMockMode
public static void enableMockMode()
Enables mock mode globally Allocated factories might not reflect this behavior when using defaultRandom()
-
disableMockMode
public static void disableMockMode()
Disables mock mode globally Allocated factories might not reflect this behavior when using defaultRandom()
-
regressionTestableRandom
public static Random regressionTestableRandom()
If in mock mode this will return a new random with the same initial seed and same state.
Useful when multiple tests require a random and the test ordering is non-deterministic.- Returns:
- in mock mode a new random with the same seed, else a randomly seeded random.
-
regressionTestableRandom
public static Random regressionTestableRandom(long seed)
If in mock mode this will return a new random with the same initial seed and same state.
Useful when multiple tests require a random and the test ordering is non-deterministic.- Parameters:
seed
- seed to use in a production environment (i.e. everywhere else than in a regression test)- Returns:
- in mock mode a new random with the same seed, else a random with the given seed.
-
-