net.sf.jbenchmark
Class TopLevelContext

java.lang.Object
  extended bynet.sf.jbenchmark.TopLevelContext
All Implemented Interfaces:
TestContext, TestListener

public class TopLevelContext
extends java.lang.Object
implements TestContext, TestListener

Test Context, includes Features, Resources accessible by all tests etc.

Version:
$Id: TopLevelContext.java,v 1.4 2004/07/02 01:11:34 twpatkua Exp $
Author:
Brett Dargan

Constructor Summary
TopLevelContext()
          Default constructor
 
Method Summary
 void assertNoFailures()
          Asserts that no tests failed.
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of a test attribute.
 ConnectionFactory getConnectionFactory()
           
 java.io.InputStream getExternalResource(java.lang.String nameOfResource)
          Locate an external resource that is made availble to the class loader from whichi this top level context was created from.
 java.util.List getFailures()
           
 TestListener getListener()
          Returns the listener to use to notify the container of test execution.
 ResultPublisher getPublisher()
           
 java.lang.Object getResource(java.lang.Class resClass)
          Locates a resource.
 HttpServer getServer()
           
 StatisticPublisher getStatisticPublisher()
          Return the publisher that should be used for publishing statistics.
 int getThreadCount()
          There is always 1 thread in the top-level context.
 void setAttribute(java.lang.String name, java.lang.String value)
          Sets the value of a test attribute.
 void setConnectionFactory(ConnectionFactory connectionFactory)
           
 void setPublisher(ResultPublisher publisher)
           
 void setServer(HttpServer server)
           
 void setStatisticPublisher(StatisticPublisher publisher)
          Set the publisher that should be used for publishing statistics.
 void testFailed(Test test, java.lang.Throwable throwable)
          Called when a test fails.
 void testFinished(TestResult result)
          Called when a test finishes.
 void testStart(Test test)
          Called when a test starts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TopLevelContext

public TopLevelContext()
Default constructor

Method Detail

getResource

public java.lang.Object getResource(java.lang.Class resClass)
                             throws java.lang.Exception
Locates a resource.

Specified by:
getResource in interface TestContext
Throws:
java.lang.Exception

getExternalResource

public java.io.InputStream getExternalResource(java.lang.String nameOfResource)
Locate an external resource that is made availble to the class loader from whichi this top level context was created from.

Specified by:
getExternalResource in interface TestContext

getListener

public TestListener getListener()
Returns the listener to use to notify the container of test execution.

Specified by:
getListener in interface TestContext

getServer

public HttpServer getServer()
Returns:
HttpServer

getPublisher

public ResultPublisher getPublisher()
Returns:
ResultPublisher

getConnectionFactory

public ConnectionFactory getConnectionFactory()
Returns:
ConnectionFactory

getFailures

public java.util.List getFailures()
Returns:
List of failed tests

setServer

public void setServer(HttpServer server)
Parameters:
server -

setPublisher

public void setPublisher(ResultPublisher publisher)
Parameters:
publisher -

setConnectionFactory

public void setConnectionFactory(ConnectionFactory connectionFactory)
Parameters:
connectionFactory -

getThreadCount

public int getThreadCount()
There is always 1 thread in the top-level context.

Specified by:
getThreadCount in interface TestContext

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns the value of a test attribute.

Specified by:
getAttribute in interface TestContext
Returns:
The value of the attribute, or null if the attribute has no value.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
Sets the value of a test attribute.

Specified by:
setAttribute in interface TestContext

testStart

public void testStart(Test test)
Called when a test starts.

Specified by:
testStart in interface TestListener

testFailed

public void testFailed(Test test,
                       java.lang.Throwable throwable)
Called when a test fails.

Specified by:
testFailed in interface TestListener

testFinished

public void testFinished(TestResult result)
Called when a test finishes.

Specified by:
testFinished in interface TestListener

assertNoFailures

public void assertNoFailures()
                      throws java.lang.Exception
Asserts that no tests failed.

Throws:
java.lang.Exception

getStatisticPublisher

public StatisticPublisher getStatisticPublisher()
Return the publisher that should be used for publishing statistics.


setStatisticPublisher

public void setStatisticPublisher(StatisticPublisher publisher)
Set the publisher that should be used for publishing statistics.