public class SpringFailOnTimeout extends Statement
SpringFailOnTimeout
is a custom JUnit Statement
which adds
support for Spring's @Timed
annotation by throwing an exception if the next statement in the execution
chain takes more than the specified number of milliseconds.
In contrast to JUnit's
FailOnTimeout
,
the next statement
will be executed in the same thread as the
caller and will therefore not be aborted preemptively.
evaluate()
Constructor and Description |
---|
SpringFailOnTimeout(Statement next,
long timeout)
Construct a new
SpringFailOnTimeout statement for the supplied
timeout . |
SpringFailOnTimeout(Statement next,
java.lang.reflect.Method testMethod)
Construct a new
SpringFailOnTimeout statement for the supplied
testMethod , retrieving the configured timeout from the
@Timed annotation on the supplied method. |
Modifier and Type | Method and Description |
---|---|
void |
evaluate()
Evaluate the next
statement in the execution chain
(typically an instance of SpringRepeat ) and throw a
TimeoutException if the next statement executes longer
than the specified timeout . |
public SpringFailOnTimeout(Statement next, java.lang.reflect.Method testMethod)
SpringFailOnTimeout
statement for the supplied
testMethod
, retrieving the configured timeout from the
@Timed
annotation on the supplied method.next
- the next Statement
in the execution chaintestMethod
- the current test methodTestAnnotationUtils.getTimeout(Method)
public SpringFailOnTimeout(Statement next, long timeout)
SpringFailOnTimeout
statement for the supplied
timeout
.
If the supplied timeout
is 0
, the execution of the
next
statement will not be timed.
next
- the next Statement
in the execution chain; never null
timeout
- the configured timeout
for the current test, in milliseconds;
never negativepublic void evaluate() throws java.lang.Throwable
statement
in the execution chain
(typically an instance of SpringRepeat
) and throw a
TimeoutException
if the next statement
executes longer
than the specified timeout
.