public class TestScheduler extends Scheduler
TestScheduler is useful for debugging. It allows you to test schedules of events by manually advancing the clock at whatever pace you choose.
Scheduler.Worker | Constructor and Description |
|---|
TestScheduler()
|
| Modifier and Type | Method and Description |
|---|---|
void |
advanceTimeBy(long delayTime, TimeUnit
Moves the Scheduler's clock forward by a specified amount of time.
|
void |
advanceTimeTo(long delayTime, TimeUnit
Moves the Scheduler's clock to a particular moment in time.
|
Scheduler |
createWorker()
Retrieves or creates a new
Scheduler.Worker that represents serial execution of actions.
|
long |
now()
Gets the current time, in milliseconds, according to this Scheduler.
|
void |
triggerActions()
Triggers any actions that have not yet been triggered and that are scheduled to be triggered at or before this Scheduler's present time.
|
public long now()
Scheduler
public void advanceTimeBy(long delayTime,
TimeUnit unit)
delayTime - the amount of time to move the Scheduler's clock forward
unit - the units of time that
delayTime is expressed in
public void advanceTimeTo(long delayTime,
TimeUnit unit)
delayTime - the point in time to move the Scheduler's clock to
unit - the units of time that
delayTime is expressed in
public void triggerActions()
public Scheduler.Worker createWorker()
Scheduler
Scheduler.Worker that represents serial execution of actions.
When work is completed it should be unsubscribed using Subscription.
Work on a Scheduler.Worker is guaranteed to be sequential.
createWorker in class
Scheduler