Package de.gebit.integrity.runner.time
Class SimpleTestTimeAdapter
- java.lang.Object
-
- de.gebit.integrity.runner.time.SimpleTestTimeAdapter
-
- All Implemented Interfaces:
TestTimeAdapter
public class SimpleTestTimeAdapter extends Object implements TestTimeAdapter
A simple default implementation of aTestTimeAdapter, 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 theIntegrityRunnerModule(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 MethodaccessorMethodThe method used to access the adapter.protected ClassLoaderclassLoaderThe classloader to use when resolvingSUT_TIME_ADAPTER_CLASS_PROPERTY.static StringSUT_TIME_ADAPTER_CLASS_PROPERTYThe 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 ObjectsystemUnderTestAdapterThe adapter provided by the system-under-test.
-
Constructor Summary
Constructors Constructor Description SimpleTestTimeAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetInternalState(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.
-
-
-
Field Detail
-
SUT_TIME_ADAPTER_CLASS_PROPERTY
public static final 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 Object systemUnderTestAdapter
The adapter provided by the system-under-test.
-
accessorMethod
protected Method accessorMethod
The method used to access the adapter. If this is null, thesystemUnderTestAdapterwas found to be an implementation ofTestTimeAdapterand thus can be called directly without Reflection.
-
classLoader
@Inject protected ClassLoader classLoader
The classloader to use when resolvingSUT_TIME_ADAPTER_CLASS_PROPERTY.
-
-
Method Detail
-
setInternalState
public void setInternalState(long aRealtimeOffset, long aRealtimeDecouplingTime, double aProgressionFactor)Description copied from interface:TestTimeAdapterSets 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, seeTimeAndDateSingleton.
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:
setInternalStatein interfaceTestTimeAdapter- 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 timeaProgressionFactor- 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)
-
-