net.sf.jbenchmark
Class Test

java.lang.Object
  extended bynet.sf.jbenchmark.TestFeature
      extended bynet.sf.jbenchmark.Test
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
AbstractSQLCallTest, ChooseRandom, ChooseRandomItemTest, FixedDelay, FixedThroughputTest, HttpGetTest, TestGroup

public abstract class Test
extends TestFeature
implements java.lang.Runnable

Abstract superclass for all tests. Tests are the real exceutables that make up a real JBencmark test.

Version:
$Id: Test.java,v 1.6 2004/07/02 02:40:24 twpatkua Exp $
Author:
Adam Murdoch

Constructor Summary
Test()
           
 
Method Summary
 void addAssertion(Assertion assertion)
          Adds an assertion.
protected  void addFeature(TestFeature feature)
          Adds a feature to this group.
 void addResource(TestFeature resource)
          Adds a resource.
protected  void doCleanup()
          Allow tests to perform finish work without impacting on the times.
protected  void doInitialise()
          Allow tests to perform start up work without impacting on the times.
protected abstract  TestResult doRun()
          Executes the test.
 void finish()
          Finishes up the test.
protected  TestContext getFeatureContext()
          Returns the context to use for features of this test.
 java.lang.Object getResource(java.lang.Class resClass)
          Given a specific class, locates the first instance encountered of all the resources that were added to this test instance.
 void run()
          Executes the test.
 void setContext(TestContext context)
          Sets the context for this feature.
 
Methods inherited from class net.sf.jbenchmark.TestFeature
getContext, getName, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Test

public Test()
Method Detail

setContext

public void setContext(TestContext context)
Sets the context for this feature.

Overrides:
setContext in class TestFeature

addAssertion

public void addAssertion(Assertion assertion)
Adds an assertion.


doInitialise

protected void doInitialise()
                     throws java.lang.Exception
Allow tests to perform start up work without impacting on the times.

Throws:
java.lang.Exception

doCleanup

protected void doCleanup()
                  throws java.lang.Exception
Allow tests to perform finish work without impacting on the times.

Throws:
java.lang.Exception

run

public final void run()
Executes the test. This method may be called more than once, and from more than one thread. The basic TestResult attributes (such as the test being run and the duration of doRun() are controlled here. Children of TestResult may be returned to provide more information about the actual test result.

Specified by:
run in interface java.lang.Runnable

doRun

protected abstract TestResult doRun()
                             throws java.lang.Exception
Executes the test. This method may be called more than once, and from more than one thread.

Throws:
java.lang.Exception

addResource

public void addResource(TestFeature resource)
Adds a resource. Certain resources may be required before this can run at all.


addFeature

protected void addFeature(TestFeature feature)
Adds a feature to this group.


getFeatureContext

protected TestContext getFeatureContext()
Returns the context to use for features of this test.


finish

public void finish()
            throws java.lang.Exception
Finishes up the test.

Overrides:
finish in class TestFeature
Throws:
java.lang.Exception

getResource

public java.lang.Object getResource(java.lang.Class resClass)
                             throws java.lang.Exception
Given a specific class, locates the first instance encountered of all the resources that were added to this test instance. If none were found for this instance, the work is delegated to TestContext.getResource(java.lang.Class) of the context returned by TestFeature.getContext().

Throws:
java.lang.Exception