Package org.mockserver.time
Class EpochService
java.lang.Object
org.mockserver.time.EpochService
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic booleanstatic voidfixedTime(boolean fixed) Test-only: pin (or unpin)currentTimeMillis()toFIXED_TIME_FOR_TESTSfor the CURRENT thread only, so parallel test classes do not observe each other's fixed clock.static voidfixedTimeGlobally(boolean fixed) Test-only: pin (or unpin)currentTimeMillis()for ALL threads.
-
Field Details
-
FIXED_TIME_FOR_TESTS
public static final long FIXED_TIME_FOR_TESTS
-
-
Constructor Details
-
EpochService
public EpochService()
-
-
Method Details
-
currentTimeMillis
public static long currentTimeMillis() -
fixedTime
public static void fixedTime(boolean fixed) Test-only: pin (or unpin)currentTimeMillis()toFIXED_TIME_FOR_TESTSfor the CURRENT thread only, so parallel test classes do not observe each other's fixed clock. Prefer theorg.mockserver.time.FixedTimeJUnit rule, which guarantees the reset even on failure. -
fixedTimeGlobally
public static void fixedTimeGlobally(boolean fixed) Test-only: pin (or unpin)currentTimeMillis()for ALL threads. Required only by tests that assert on timestamps generated off the test thread (e.g. the event-log disruptor). Because it is JVM-global it is NOT parallel-safe - such tests must run in the sequential Surefire phase. Prefer theorg.mockserver.time.GlobalFixedTimeJUnit rule, which guarantees the reset. -
fixedTime
public static boolean fixedTime()
-