@Deprecated
public class TestRunnable
extends java.lang.Object
implements java.lang.Runnable
This structure is used extensively within threadly's own unit tests. Please use those as examples using this class.
Constructor and Description |
---|
TestRunnable()
Deprecated.
Constructs a new runnable for unit testing.
|
TestRunnable(int runTimeInMillis)
Deprecated.
Constructs a new runnable for unit testing.
|
Modifier and Type | Method and Description |
---|---|
void |
blockTillFinished()
Deprecated.
Blocks until run has completed at least once.
|
void |
blockTillFinished(int timeout)
Deprecated.
Blocks until run has completed at least once.
|
void |
blockTillFinished(int timeout,
int expectedRunCount)
Deprecated.
Blocks until run completed been called the provided quantity of times.
|
void |
blockTillStarted()
Deprecated.
Blocks until run has been called at least once.
|
void |
blockTillStarted(int timeout)
Deprecated.
Blocks until run has been called at least once.
|
long |
getCreationTime()
Deprecated.
Returns the millis returned from
Clock.accurateForwardProgressingMillis() , that was
recorded when this runnable was constructed. |
long |
getDelayTillFirstRun()
Deprecated.
This function blocks till the first run completes then will return the time until the first
run started it's call.
|
long |
getDelayTillRun(int runNumber)
Deprecated.
This function blocks till the run provided, and then gets the time between creation and a
given run.
|
long |
getDelayTillRun(int runNumber,
int timeout)
Deprecated.
This function blocks till the run provided, and
then gets the time between creation and a given run.
|
int |
getRunCount()
Deprecated.
Getter for the number of times the run function has completed.
|
int |
getRunDelayInMillis()
Deprecated.
Getter for the currently set amount of time the
TestRunnable will block after
handleRunStart() and before handleRunFinish() is called. |
void |
handleRunFinish()
Deprecated.
Function to be overloaded by extending classes if more data or operations need to happen at
the run point.
|
void |
handleRunStart()
Deprecated.
Function to be overloaded by extending classes if more data or operations need to happen at
the run point.
|
boolean |
isRunning()
Deprecated.
Check to see if the run function has started but has not completed returned yet.
|
boolean |
ranConcurrently()
Deprecated.
Check if this instance has ever been detected to run concurrently.
|
boolean |
ranOnce()
Deprecated.
Getter to check if the runnable has run exactly once.
|
void |
run()
Deprecated.
|
void |
setRunDelayInMillis(int runDelayInMillis)
Deprecated.
Changes the amount of time the runnable will sleep/block when called.
|
public TestRunnable()
public TestRunnable(int runTimeInMillis)
This constructor allows the parameter for the runnable to sleep after handleRunStart()
was called and before handleRunFinish()
is called.
runTimeInMillis
- time for runnable to sleep in millisecondspublic void setRunDelayInMillis(int runDelayInMillis)
runDelayInMillis
- new amount to wait when run is calledpublic int getRunDelayInMillis()
TestRunnable
will block after
handleRunStart()
and before handleRunFinish()
is called.public long getCreationTime()
Clock.accurateForwardProgressingMillis()
, that was
recorded when this runnable was constructed.TestRunnable
was constructedpublic boolean ranConcurrently()
handleRunStart()
,
handleRunFinish()
, or in the constructor increases the chances of detecting
concurrency.public boolean ranOnce()
true
if the runnable has been called oncepublic boolean isRunning()
public int getRunCount()
public long getDelayTillFirstRun()
public long getDelayTillRun(int runNumber)
runNumber
- the run count to get delay topublic long getDelayTillRun(int runNumber, int timeout)
runNumber
- the run count to get delay totimeout
- timeout to wait for given run count to finishpublic void blockTillFinished()
public void blockTillFinished(int timeout)
timeout
- time to wait for run to be called before throwing exceptionpublic void blockTillFinished(int timeout, int expectedRunCount)
timeout
- time to wait for run to be called before throwing exceptionexpectedRunCount
- run count to wait forpublic void blockTillStarted()
public void blockTillStarted(int timeout)
timeout
- time to wait for run to be called before throwing exceptionpublic final void run()
run
in interface java.lang.Runnable
public void handleRunStart() throws java.lang.InterruptedException
This is also the first call to be made in the runnable, but all necessary
TestRunnable
actions are in a finally block so it is safe to throw any exceptions
necessary here.
java.lang.InterruptedException
- only InterruptedExceptions will be swallowedpublic void handleRunFinish()
This is the last call to be made in the runnable. If you want a RuntimeException
to
get thrown to the caller, it must be thrown from here.