org.jboss.dtf.testframework.testnode
Class TaskRunner

java.lang.Object
  extended by org.jboss.dtf.testframework.testnode.TaskRunner
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
JavaTaskRunner, JavaTaskRunner, JUnitReportParser, JUnitTaskRunner, ShellScriptTaskRunner, UnitTaskRunner, UnitTestTaskRunner

public abstract class TaskRunner
extends java.lang.Object
implements java.lang.Runnable


Field Summary
protected  TestNodeInterface _associatedTestNode
           
protected  java.lang.String _associatedTestNodeName
           
protected  java.lang.String _className
           
protected  java.lang.String _classpathRef
           
protected  boolean _finished
           
protected  java.lang.Object _finishedSyncObject
           
protected  java.lang.String[] _jvmParameters
           
protected  TaskResultListener _listener
           
protected  java.lang.String _loggingResource
           
protected  LoggingService _loggingService
           
protected  NodeConfiguration _nodeConfig
           
protected  java.lang.String[] _parameters
           
protected  ProductConfiguration _productConfig
           
protected  boolean _ready
           
protected  TaskResultListener _resultListener
           
protected  RunUID _runId
           
protected  java.util.Hashtable _runnerParameters
           
protected  boolean _running
           
protected  ServiceUtils _serviceUtils
           
protected  TaskIdInterface _taskId
           
protected  java.lang.Object _taskIsRunning
           
protected  java.lang.String _taskName
           
protected  java.lang.String _taskPermutationCode
           
protected  java.lang.String _testId
           
protected  java.lang.String _testPermutationCode
           
protected  int _testType
           
protected  boolean _timedOut
           
protected  int _timeoutValue
           
static java.lang.String JAVA_HOME_DIRECTORY_PARAMETER
           
 
Constructor Summary
TaskRunner()
           
 
Method Summary
 java.lang.String getClasspathString()
          Get the classpath required to run tasks for the given product
 java.lang.String getJavaExe()
          Retrieve the configured JAVA executable directory (JAVA_HOME/bin)
 java.lang.String getJavaHome()
           
 LoggingService getLoggingService()
          Retrieves the logging service to be used by the task runner to log results.
 NodeConfiguration getNodeConfiguration()
           
 TaskResultListener getResultListener()
          Retrieve a reference to the task result listener for this task runner.
 java.util.Hashtable getRunnerParameters()
          Retrieves a table of name value parameters passed to this task runner by the currently executing test.
 TaskIdInterface getRunningTaskId()
          Retrieve the task id.
 java.lang.String getRunningTaskPermutationCode()
          Retrieve the permutation code of the task being run by this task runner.
 java.lang.String getRunningTestPermutationCode()
          Retrieve the permutation code of the test currently being run.
 ServiceUtils getServiceUtils()
          Retrieve the service utils used by the framework.
 java.lang.String getTaskName()
          Get the name of the task being run by this task runner.
 boolean hasFinished()
          Returns true if the task has finished.
 boolean hasTimedOut()
          Returns true if the task this task runner is running has timedout.
 void indicateTaskIsRunning()
          Called by the task runner when it has detected that the task is running.
 void initialise(java.util.Hashtable runnerParameters, java.lang.String testId, java.lang.String className, java.lang.String classpathRef, java.lang.String taskName, java.lang.String[] parameters, java.lang.String[] jvmParameters, int testType, int timeoutValue, ProductConfiguration productConfig, NodeConfiguration nodeConfig, TaskIdInterface taskId, TaskResultListener listener, TestNodeInterface associatedTestNode, RunUID runId, java.lang.String taskPermutationCode, java.lang.String testPermutationCode, java.lang.String loggingResource, ServiceUtils serviceUtils)
          Called by the framework to initialise this task runner.
 boolean isReady()
          Returns true if this task has signalled that it is ready.
protected  void readySignalled()
          This method is called by a task runner when the task it is running has declared that it is ready to be used.
 void registerResultListener(TaskResultListener listener)
          Registers a task result listener for this task runner.
 void run()
           
abstract  void runTask()
          This is the main body of the task runner.
 void start()
           
abstract  boolean terminate()
          Called by the framework when it wishes to terminate the task this runner is running.
 java.lang.String toString()
           
abstract  void waitFor()
          Called by the framework when it wishes to wait for the task to finish.
 boolean waitForFinished()
          Called by the framework to wait for the task ro signal that it is finished.
 boolean waitForReadyOrFinished()
          Called by the framework to wait for the task to signal Ready or finish.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JAVA_HOME_DIRECTORY_PARAMETER

public static final java.lang.String JAVA_HOME_DIRECTORY_PARAMETER
See Also:
Constant Field Values

_className

protected java.lang.String _className

_parameters

protected java.lang.String[] _parameters

_jvmParameters

protected java.lang.String[] _jvmParameters

_testType

protected int _testType

_timeoutValue

protected int _timeoutValue

_nodeConfig

protected NodeConfiguration _nodeConfig

_productConfig

protected ProductConfiguration _productConfig

_listener

protected TaskResultListener _listener

_taskId

protected TaskIdInterface _taskId

_resultListener

protected TaskResultListener _resultListener

_associatedTestNode

protected TestNodeInterface _associatedTestNode

_associatedTestNodeName

protected java.lang.String _associatedTestNodeName

_runnerParameters

protected java.util.Hashtable _runnerParameters

_finished

protected boolean _finished

_finishedSyncObject

protected java.lang.Object _finishedSyncObject

_ready

protected boolean _ready

_runId

protected RunUID _runId

_loggingResource

protected java.lang.String _loggingResource

_taskPermutationCode

protected java.lang.String _taskPermutationCode

_testPermutationCode

protected java.lang.String _testPermutationCode

_testId

protected java.lang.String _testId

_taskName

protected java.lang.String _taskName

_timedOut

protected boolean _timedOut

_running

protected boolean _running

_taskIsRunning

protected java.lang.Object _taskIsRunning

_serviceUtils

protected ServiceUtils _serviceUtils

_loggingService

protected LoggingService _loggingService

_classpathRef

protected java.lang.String _classpathRef
Constructor Detail

TaskRunner

public TaskRunner()
Method Detail

initialise

public final void initialise(java.util.Hashtable runnerParameters,
                             java.lang.String testId,
                             java.lang.String className,
                             java.lang.String classpathRef,
                             java.lang.String taskName,
                             java.lang.String[] parameters,
                             java.lang.String[] jvmParameters,
                             int testType,
                             int timeoutValue,
                             ProductConfiguration productConfig,
                             NodeConfiguration nodeConfig,
                             TaskIdInterface taskId,
                             TaskResultListener listener,
                             TestNodeInterface associatedTestNode,
                             RunUID runId,
                             java.lang.String taskPermutationCode,
                             java.lang.String testPermutationCode,
                             java.lang.String loggingResource,
                             ServiceUtils serviceUtils)
                      throws java.rmi.RemoteException
Called by the framework to initialise this task runner.

Parameters:
runnerParameters -
testId -
className -
taskName -
parameters -
jvmParameters -
testType -
timeoutValue -
productConfig -
nodeConfig -
taskId -
listener -
associatedTestNode -
runId -
taskPermutationCode -
testPermutationCode -
loggingResource -
serviceUtils -
Throws:
java.rmi.RemoteException

getRunnerParameters

public final java.util.Hashtable getRunnerParameters()
Retrieves a table of name value parameters passed to this task runner by the currently executing test.

Returns:
A hashtable containing the name value pairs.

registerResultListener

public final void registerResultListener(TaskResultListener listener)
Registers a task result listener for this task runner. Only one can registered per task runner and only the last one is stored. This listener will be invoked when data is generated by the task being executed.

Parameters:
listener - A reference to the task result listener.

getLoggingService

public LoggingService getLoggingService()
Retrieves the logging service to be used by the task runner to log results.

Returns:
A reference to the logging service to use to log results.

getTaskName

public final java.lang.String getTaskName()
Get the name of the task being run by this task runner.

Returns:
The name of the task being executed.

getRunningTaskId

public final TaskIdInterface getRunningTaskId()
Retrieve the task id. given to this task by the parent test node.

Returns:
The task id. of the task being run.

getRunningTestPermutationCode

public final java.lang.String getRunningTestPermutationCode()
Retrieve the permutation code of the test currently being run.

Returns:
The permutation code of the test currently being run.

getRunningTaskPermutationCode

public final java.lang.String getRunningTaskPermutationCode()
Retrieve the permutation code of the task being run by this task runner.

Returns:
The permutation of the task this task runner is to run.

getResultListener

public final TaskResultListener getResultListener()
Retrieve a reference to the task result listener for this task runner.

Returns:
The task result listener for this task runner.

hasTimedOut

public boolean hasTimedOut()
Returns true if the task this task runner is running has timedout.

Returns:
True - if the task has timedout.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

readySignalled

protected final void readySignalled()
                             throws java.rmi.RemoteException
This method is called by a task runner when the task it is running has declared that it is ready to be used. This signal is only acted upon if the task is run as a server.

Throws:
java.rmi.RemoteException

start

public final void start()

waitForReadyOrFinished

public final boolean waitForReadyOrFinished()
                                     throws java.lang.InterruptedException
Called by the framework to wait for the task to signal Ready or finish.

Returns:
true if neither happened within the timeout period
Throws:
java.lang.InterruptedException

waitForFinished

public final boolean waitForFinished()
                              throws java.lang.InterruptedException
Called by the framework to wait for the task ro signal that it is finished.

Returns:
True if the task did not finish.
Throws:
java.lang.InterruptedException

hasFinished

public final boolean hasFinished()
Returns true if the task has finished.

Returns:
True - if the task has finished.

isReady

public final boolean isReady()
                      throws java.lang.Exception
Returns true if this task has signalled that it is ready.

Returns:
True if the task has signalled ready.
Throws:
java.lang.Exception - If this task is not expected to have a ready state.

run

public final void run()
Specified by:
run in interface java.lang.Runnable

getServiceUtils

public ServiceUtils getServiceUtils()
Retrieve the service utils used by the framework. This contains methods to retrieve references to all of the services offered by the testing framework.

Returns:
A reference to the service utils.

indicateTaskIsRunning

public final void indicateTaskIsRunning()
Called by the task runner when it has detected that the task is running.


getNodeConfiguration

public final NodeConfiguration getNodeConfiguration()

getClasspathString

public java.lang.String getClasspathString()
Get the classpath required to run tasks for the given product

Returns:

runTask

public abstract void runTask()
                      throws java.lang.Exception
This is the main body of the task runner. Within this method the task runner can start the task and monitor its state.

Throws:
java.lang.Exception

terminate

public abstract boolean terminate()
Called by the framework when it wishes to terminate the task this runner is running.

Returns:
True if the task was successfully terminated.

waitFor

public abstract void waitFor()
                      throws java.lang.InterruptedException
Called by the framework when it wishes to wait for the task to finish. This method MUST block until the task has finished. If a method is called which could throw an InterruptedException then let this be thrown by the method and it will be handled correctly by the test node.

Throws:
java.lang.InterruptedException

getJavaHome

public final java.lang.String getJavaHome()

getJavaExe

public final java.lang.String getJavaExe()
Retrieve the configured JAVA executable directory (JAVA_HOME/bin)

Returns: