Class RandomFactory
java.lang.Object
de.hsh.graja.regression.noisereduction.RandomFactory
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
Modifier and TypeMethodDescriptionstatic void
Disables mock mode globally Allocated factories might not reflect this behavior when using defaultRandom()static void
Enables mock mode globally Allocated factories might not reflect this behavior when using defaultRandom()static Random
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 Details
-
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
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
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.
-