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

    Modifier and Type
    Method
    Description
    static 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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      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.