org.apache.qpid.junit.extensions
Class ScaledTestDecorator

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.ScaledTestDecorator
All Implemented Interfaces:
junit.framework.Test, ShutdownHookable

public class ScaledTestDecorator
extends WrappedSuiteTestDecorator
implements ShutdownHookable

A test decorator that runs a test many times simultaneously in many threads.

CRC Card
Responsibilities Collaborations
Clone a test run into many threads and run them simultaneously.
Inform the test results of the start and end of each concurrent test batch. TKTestResult
Inform the test results of the concurrency level. TKTestResult


Field Summary
 
Fields inherited from class org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator
suite
 
Fields inherited from class junit.extensions.TestDecorator
fTest
 
Constructor Summary
ScaledTestDecorator(WrappedSuiteTestDecorator test)
          Creates an active test with default multiplier (1).
ScaledTestDecorator(WrappedSuiteTestDecorator test, int numThreads)
          Creates a concurrently scaled test with the specified number of threads.
ScaledTestDecorator(WrappedSuiteTestDecorator test, int[] threads)
          Creates a concurrently scaled test with the specified thread levels, the test is repeated at each level.
 
Method Summary
 int getConcurrencyLevel()
          Reports the number of tests that the scaled decorator is currently running concurrently.
 Thread getShutdownHook()
          Supplies the shut-down hook.
 void run(junit.framework.TestResult testResult)
          Runs the test simultaneously in at the specified concurrency levels.
 String toString()
          Prints a string summarizing this test decorator, mainly for debugging purposes.
 
Methods inherited from class org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator
countTestCases, getAllUnderlyingTests, testAt
 
Methods inherited from class junit.extensions.TestDecorator
basicRun, getTest
 
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

ScaledTestDecorator

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

Parameters:
test - The target test.

ScaledTestDecorator

public ScaledTestDecorator(WrappedSuiteTestDecorator test,
                           int numThreads)
Creates a concurrently scaled test with the specified number of threads.

Parameters:
test - The target test.
numThreads - The stress level.

ScaledTestDecorator

public ScaledTestDecorator(WrappedSuiteTestDecorator test,
                           int[] threads)
Creates a concurrently scaled test with the specified thread levels, the test is repeated at each level.

Parameters:
test - The target test.
threads - The concurrency levels.
Method Detail

run

public void run(junit.framework.TestResult testResult)
Runs the test simultaneously in at the specified concurrency levels.

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

getConcurrencyLevel

public int getConcurrencyLevel()
Reports the number of tests that the scaled decorator is currently running concurrently.

Returns:
The number of tests that the scaled decorator is currently running concurrently.

getShutdownHook

public Thread getShutdownHook()
Supplies the shut-down hook.

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

toString

public String toString()
Prints a string summarizing this test decorator, mainly for debugging purposes.

Overrides:
toString in class junit.extensions.TestDecorator
Returns:
String representation for debugging purposes.


Licensed to the Apache Software Foundation