Class SimpleTestTimeAdapter

  • All Implemented Interfaces:
    TestTimeAdapter

    public class SimpleTestTimeAdapter
    extends java.lang.Object
    implements TestTimeAdapter
    A simple default implementation of a TestTimeAdapter, which just tries to instantiate the "real" adapter implemented by the system-under-test by resolving the class name of a system property. The adapter shall then forward the parameters to the actual time proxy implementation.

    You can either use this mechanism to inject your adapter or, if you think it's a little bit dirty to use a system property, you can also override this adapter directly by specifying a different one in a custom subclass of the IntegrityRunnerModule (the same class where you can basically customize the entire service set of internal Integrity services).
    Author:
    Rene Schneider - initial API and implementation
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.reflect.Method accessorMethod
      The method used to access the adapter.
      protected java.lang.ClassLoader classLoader
      The classloader to use when resolving SUT_TIME_ADAPTER_CLASS_PROPERTY.
      static java.lang.String SUT_TIME_ADAPTER_CLASS_PROPERTY
      The system property used by this adapter to instantiate the actual adapter supplied by the system-under-test, which has the purpose to forward the fake time parameters to the test time provider in the application.
      protected java.lang.Object systemUnderTestAdapter
      The adapter provided by the system-under-test.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void setInternalState​(long aRealtimeOffset, long aRealtimeDecouplingTime, double aProgressionFactor)
      Sets the internal state of an entity that can use this state to calculate a "fake" current date and time that is to be used for the system under test.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SUT_TIME_ADAPTER_CLASS_PROPERTY

        public static final java.lang.String SUT_TIME_ADAPTER_CLASS_PROPERTY
        The system property used by this adapter to instantiate the actual adapter supplied by the system-under-test, which has the purpose to forward the fake time parameters to the test time provider in the application.
        See Also:
        Constant Field Values
      • systemUnderTestAdapter

        protected java.lang.Object systemUnderTestAdapter
        The adapter provided by the system-under-test.
      • accessorMethod

        protected java.lang.reflect.Method accessorMethod
        The method used to access the adapter. If this is null, the systemUnderTestAdapter was found to be an implementation of TestTimeAdapter and thus can be called directly without Reflection.
    • Constructor Detail

      • SimpleTestTimeAdapter

        public SimpleTestTimeAdapter()
    • Method Detail

      • setInternalState

        public void setInternalState​(long aRealtimeOffset,
                                     long aRealtimeDecouplingTime,
                                     double aProgressionFactor)
        Description copied from interface: TestTimeAdapter
        Sets the internal state of an entity that can use this state to calculate a "fake" current date and time that is to be used for the system under test. Depending on the parameters, the time is intended to be frozen (if no progression factor or one of 0.0 is provided) or to progress at a certain speed relative to real-time. From the provided parameters, an accurate test time can be calculated. For an example how this can be done, see TimeAndDateSingleton.

        If the realtime offset is zero and the progression factor is exactly 1.0, this means that the "fake test time" is reverted to actual realtime.
        Specified by:
        setInternalState in interface TestTimeAdapter
        Parameters:
        aRealtimeOffset - the offset of our test time from real system time (wall clock)
        aRealtimeDecouplingTime - the point in real time at which our test time was decoupled from system time
        aProgressionFactor - the speed at which the test time should progress (1.0 is normal speed, progression factor may be negative too, or 0.0, which means time is frozen)