Class DeterministicExecutor
java.lang.Object
org.jmock.lib.concurrent.DeterministicExecutor
- All Implemented Interfaces:
Executor
An
Executor that executes commands on the thread that calls
runPendingCommands or runUntilIdle.
This is useful when using Mock Objects to test code that spawns background tasks.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanisIdle()Returns whether this executor is idle -- has no pending background tasks waiting to be run.voidRuns all commands that are currently pending.voidRuns executed commands until there are no commands pending execution, but does not tick time forward.
-
Field Details
-
commands
-
-
Constructor Details
-
DeterministicExecutor
public DeterministicExecutor()
-
-
Method Details
-
isIdle
public boolean isIdle()Returns whether this executor is idle -- has no pending background tasks waiting to be run.- Returns:
- true if there are no background tasks to be run, false otherwise.
- See Also:
-
runPendingCommands
public void runPendingCommands()Runs all commands that are currently pending. If those commands also schedule commands for execution, the scheduled commands will not be executed until the next call torunPendingCommands()orrunUntilIdle(). -
runUntilIdle
public void runUntilIdle()Runs executed commands until there are no commands pending execution, but does not tick time forward. -
execute
-