org.jboss.dtf.testframework.unittest
Class Test

java.lang.Object
  extended by org.jboss.dtf.testframework.unittest.Test
All Implemented Interfaces:
TestInterface
Direct Known Subclasses:
AntRunner

public abstract class Test
extends java.lang.Object
implements TestInterface

This class must be extended to implement a unit test. It contains various methods that are used by the test to report information, e.g. logInformation, logResult, etc.


Field Summary
protected  java.lang.String[] _parameters
           
static int FAILURE
           
static int SUCCESS
           
static int UNCERTAIN
           
 
Constructor Summary
Test()
           
 
Method Summary
protected static java.lang.String[] appendServerNames(java.lang.String[] args, java.lang.String[] serverNames)
          Utility method for taking two string arrays and concatenating them
 void assertFailure()
          This method is called to indicate that the test has failed.
 void assertReady()
          This method is called by Servers to indicate to the testframework they are now in a state where they are ready to receive requests.
 void assertSuccess()
          This method is called to indicate that the test has been successful i.e.
 void assertSuccessOrFailue(int result)
          This method evaluates the result and asserts the necessary result.
 boolean assertTrue(boolean value)
          This method evaluates the value - if it is false then the test is presumed to have failed.
 void assertUncertain()
          This method is called to indicate that the test cannot determine whether it passed or failed.
protected  java.lang.String[] getParameters()
          Used to retrieve the parameters passed to the test.
 java.lang.String getResultText()
           
static java.lang.String getResultText(int result)
           
 java.lang.String getService(java.lang.String name)
           
 java.lang.String getTaskName()
           
 java.lang.String getTestName()
          Accessor for the name of this test
 int getTestResult()
          This method returns the result of this test.
 void initialise(java.lang.String testName, java.lang.String taskName, java.lang.String[] parameters, HarnessInterface harness)
          Initialisation routine which is called by the test framework passing the parameters for the test.
 void logInformation(java.lang.String information)
          This method logs textual information to the logger.
protected  void logResult(java.lang.String result)
          This method makes a call to LoggingService.logResult() which sets the result of the task in the database table TestTaskResults
 void logTestRunInformation(java.lang.String information)
          This method logs textual information to the logger.
 boolean registerService(java.lang.String name, java.lang.String ior)
           
abstract  void run(java.lang.String[] args)
          The main test method which must assert either a pass or a fail.
 void runTest()
          Called by the framework to run the test and log the results
 void testComplete()
          This method is called by the testframework when the test has complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FAILURE

public static final int FAILURE
See Also:
Constant Field Values

SUCCESS

public static final int SUCCESS
See Also:
Constant Field Values

UNCERTAIN

public static final int UNCERTAIN
See Also:
Constant Field Values

_parameters

protected java.lang.String[] _parameters
Constructor Detail

Test

public Test()
Method Detail

initialise

public final void initialise(java.lang.String testName,
                             java.lang.String taskName,
                             java.lang.String[] parameters,
                             HarnessInterface harness)
Initialisation routine which is called by the test framework passing the parameters for the test.

Specified by:
initialise in interface TestInterface
Parameters:
taskName - The task name of this test class.
testName - The unqiue identifier for this test.
parameters - An array of string parameters.
harness - A reference to the harness which initiated this test

getParameters

protected final java.lang.String[] getParameters()
Used to retrieve the parameters passed to the test. The parameters declared in the test definition XML are passed first followed by the unique names generated by the test framework.


runTest

public final void runTest()
Called by the framework to run the test and log the results

Specified by:
runTest in interface TestInterface

run

public abstract void run(java.lang.String[] args)
The main test method which must assert either a pass or a fail.


getTestName

public final java.lang.String getTestName()
Accessor for the name of this test


getTaskName

public final java.lang.String getTaskName()

logInformation

public final void logInformation(java.lang.String information)
This method logs textual information to the logger.

Specified by:
logInformation in interface TestInterface
Parameters:
information - The textual information to be logged.

logTestRunInformation

public final void logTestRunInformation(java.lang.String information)
This method logs textual information to the logger. At the test run level.

Parameters:
information - The textual information to be logged.

assertReady

public final void assertReady()
This method is called by Servers to indicate to the testframework they are now in a state where they are ready to receive requests.

Specified by:
assertReady in interface TestInterface

assertSuccess

public final void assertSuccess()
This method is called to indicate that the test has been successful i.e. the test has passed.

Specified by:
assertSuccess in interface TestInterface

assertFailure

public final void assertFailure()
This method is called to indicate that the test has failed.

Specified by:
assertFailure in interface TestInterface

assertUncertain

public final void assertUncertain()
This method is called to indicate that the test cannot determine whether it passed or failed. This result usually means the test needs to be re-run. Usually a test will not call this directly.

Specified by:
assertUncertain in interface TestInterface

assertTrue

public final boolean assertTrue(boolean value)
This method evaluates the value - if it is false then the test is presumed to have failed. This method does nothing if value is true.

Specified by:
assertTrue in interface TestInterface
Parameters:
value - If this boolean is false the test is assumed to have failed.
Returns:
Returns the value passed to it.

assertSuccessOrFailue

public final void assertSuccessOrFailue(int result)
This method evaluates the result and asserts the necessary result.

Parameters:
result - The result to assert SUCCESS, FAILURE

getResultText

public static final java.lang.String getResultText(int result)

getTestResult

public final int getTestResult()
This method returns the result of this test. If the result has not yet been logged then a result of UNCERTAIN is returned.


getResultText

public final java.lang.String getResultText()

testComplete

public final void testComplete()
This method is called by the testframework when the test has complete. It evaluates the result of the test and logs the result to the logger.

Specified by:
testComplete in interface TestInterface

logResult

protected final void logResult(java.lang.String result)
This method makes a call to LoggingService.logResult() which sets the result of the task in the database table TestTaskResults


registerService

public boolean registerService(java.lang.String name,
                               java.lang.String ior)
Specified by:
registerService in interface TestInterface

getService

public java.lang.String getService(java.lang.String name)
                            throws ServiceLookupException
Specified by:
getService in interface TestInterface
Throws:
ServiceLookupException

appendServerNames

protected static final java.lang.String[] appendServerNames(java.lang.String[] args,
                                                            java.lang.String[] serverNames)
Utility method for taking two string arrays and concatenating them

Parameters:
args - The first string array
serverNames - The second string array