org.apache.qpid.junit.extensions
Class SetupTaskHandler

java.lang.Object
  extended by org.apache.qpid.junit.extensions.SetupTaskHandler
All Implemented Interfaces:
SetupTaskAware

public class SetupTaskHandler
extends Object
implements SetupTaskAware

SetupTaskHandler implements a task stack. It can be used, by delegation, as a base implementation for tests that want to have configurable setup/teardown task stacks. Typically it is up to the test implementation to decide whether the stack is executed in the setup/teardown methods or in the threadSetup/threadTeaddown methods.

CRC Card
Responsibilities Collaborations
Handle injection of set up tasks.
Handle injection of tear down tasks.
Run set up tasks in chain order.
Run tear down tasks in reverse chain order.


Field Summary
(package private)  Queue<Runnable> setups
          Holds the set up tasks.
(package private)  Queue<Runnable> teardowns
          Holds the tear down tasks.
 
Constructor Summary
SetupTaskHandler()
           
 
Method Summary
 void chainSetupTask(Runnable task)
          Adds the specified task to the tests setup.
 void chainTearDownTask(Runnable task)
          Adds the specified task to the tests tear down.
 void runSetupTasks()
          Runs the set up tasks in the order that they way chained.
 void runTearDownTasks()
          Runs the tear down tasks in the reverse of the order in which they were chained.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

setups

Queue<Runnable> setups
Holds the set up tasks.


teardowns

Queue<Runnable> teardowns
Holds the tear down tasks.

Constructor Detail

SetupTaskHandler

public SetupTaskHandler()
Method Detail

chainSetupTask

public void chainSetupTask(Runnable task)
Adds the specified task to the tests setup.

Specified by:
chainSetupTask in interface SetupTaskAware
Parameters:
task - The task to add to the tests setup.

chainTearDownTask

public void chainTearDownTask(Runnable task)
Adds the specified task to the tests tear down.

Specified by:
chainTearDownTask in interface SetupTaskAware
Parameters:
task - The task to add to the tests tear down.

runSetupTasks

public void runSetupTasks()
Runs the set up tasks in the order that they way chained.


runTearDownTasks

public void runTearDownTasks()
Runs the tear down tasks in the reverse of the order in which they were chained.



Licensed to the Apache Software Foundation