org.apache.qpid.junit.extensions
Class DurationTestDecorator

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.extensions.TestDecorator
          extended by org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator
              extended by org.apache.qpid.junit.extensions.DurationTestDecorator
All Implemented Interfaces:
junit.framework.Test, ShutdownHookable

public class DurationTestDecorator
extends WrappedSuiteTestDecorator
implements ShutdownHookable

A test decorator that runs a test repeatedly until a specified length of time has passed.

CRC Card
Responsibilities Collaborations
Repeatedly run a test for a fixed length of time.

Todo:
The count of the number of tests run is an important number to keep. Also num passed/error/failed is also important to record. What to do with these numbers? They are already logged to the test listeners., The duration test runner wraps on top of size, repeat or thread wrappers, need a way for it to tell TKTestResult when the duration is up, so that it can terminate any repeats in progress. It should end as soon as possible once the test method exits.

Field Summary
 
Fields inherited from class org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator
suite
 
Fields inherited from class junit.extensions.TestDecorator
fTest
 
Constructor Summary
DurationTestDecorator(WrappedSuiteTestDecorator test)
          Creates an active test with default multiplier (1).
DurationTestDecorator(WrappedSuiteTestDecorator test, long duration)
          Creates active test with default multiplier (1).
 
Method Summary
 Thread getShutdownHook()
          Supplies the shutdown hook.
 void run(junit.framework.TestResult testResult)
          Runs the test repeatedly for the fixed duration.
 
Methods inherited from class org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator
countTestCases, getAllUnderlyingTests, testAt
 
Methods inherited from class junit.extensions.TestDecorator
basicRun, getTest, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DurationTestDecorator

public DurationTestDecorator(WrappedSuiteTestDecorator test)
Creates an active test with default multiplier (1).

Parameters:
test - The target test.

DurationTestDecorator

public DurationTestDecorator(WrappedSuiteTestDecorator test,
                             long duration)
Creates active test with default multiplier (1).

Parameters:
test - The target test.
duration - The duration in milliseconds.
Method Detail

run

public void run(junit.framework.TestResult testResult)
Runs the test repeatedly for the fixed duration.

Specified by:
run in interface junit.framework.Test
Overrides:
run in class junit.extensions.TestDecorator
Parameters:
testResult - The the results object to monitor the test results with.

getShutdownHook

public Thread getShutdownHook()
Supplies the shutdown hook. This shutdown hook does not call TKTestResult.shutdownNow() because the ScaledTestDecorator already takes care of that.

Specified by:
getShutdownHook in interface ShutdownHookable
Returns:
The shut down hook.


Licensed to the Apache Software Foundation