Class ManualClock
java.lang.Object
io.github.teceli.resiliencia.test.ManualClock
- All Implemented Interfaces:
Clock
Deterministic
Clock for tests: time only moves when advanced explicitly via
advance(java.time.Duration) or when a pattern sleeps, so timing-based behavior (Retry backoff,
RateLimiter windows) can be asserted exactly and runs instantly.
Thread-safe: patterns may read and sleep on this clock from multiple threads.-
Method Summary
Modifier and TypeMethodDescriptionvoidMove the clock forward by the given duration.static ManualClockcreate()A manual clock starting at a fixed, arbitrary instant.instant()The current instant, as seen by this clock.voidsleep(long millis) Does not block: advances the clock by the requested duration and returns immediately.static ManualClockstartingAt(Instant start) A manual clock starting at the given instant.
-
Method Details
-
create
A manual clock starting at a fixed, arbitrary instant. -
startingAt
A manual clock starting at the given instant. -
instant
Description copied from interface:ClockThe current instant, as seen by this clock. -
sleep
public void sleep(long millis) Does not block: advances the clock by the requested duration and returns immediately. -
advance
Move the clock forward by the given duration.
-