com.pushtotest.testnetwork
Class Scenario

java.lang.Object
  extended by com.pushtotest.testnetwork.Scenario

public class Scenario
extends java.lang.Object

The Scenario class is a singleton that manages executions of a scenario.

Version:
0.1
Author:
bradfute bradfute@pushtotest.com

Method Summary
 void abandon()
          Abandon a loaded Scenario before it is executed.
 void abort()
          Abort a running Scenario.
 void completion(java.lang.Thread tAgentRunner)
          Mark a Scenario as completed.
 java.util.ArrayList getArguments()
          Get the last loaded argument list.
 java.util.Hashtable getFileList()
          Get the last loaded file list.
static Scenario getInstance()
          Get the instance of the Scenario singleton.
 java.lang.String getName()
          Get the last loaded scenario name.
 java.util.Hashtable getResults()
          Get the return information from the last executed scenario.
 java.lang.String getRundir()
          Get the last loaded rundir.
 java.lang.String getScript()
          Get the last loaded Script name.
 java.util.Hashtable getSnapshot()
          Get the last loaded scenario Snapshot.
 java.lang.String getState()
          Get the current execution state of the scenario.
 java.lang.String getStatus()
          Get the execution status of a Scenario.
 int getSyncFlag()
          Get the Sync Flag.
 java.lang.String getWhence()
          Get the last loaded scenario whence parameter.
 void load(java.lang.String sWhence, java.lang.String sName, java.lang.String sScript, java.lang.String sTempdir, java.util.ArrayList alsArguments, java.lang.String srootPath)
          Load an execution scenario.
 void release()
          Release this Scenario so that it can be available for other executions.
 void run(int usecase)
          Run an usecase from a loaded Scenario.
 void setSyncFlag(int iFlag)
          Set the Sync Flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Scenario getInstance()
Get the instance of the Scenario singleton.


getState

public java.lang.String getState()
Get the current execution state of the scenario. The possible states are: The states progress as follows: available + load() = loaded available + abandon() = available loaded + execute() = running loaded + abandon() = available running + abort() = aborted running + Script Completes = completed aborted + load() = loaded aborted + abandon() = available completed + release() = available

Returns:
String The state the TestNode is currently in.

getWhence

public java.lang.String getWhence()
Get the last loaded scenario whence parameter.

Returns:
String The sWhence parameter from the last successful call to load().
See Also:
load

getName

public java.lang.String getName()
Get the last loaded scenario name.

Returns:
String The sName parameter from the last successful call to load().
See Also:
load

getSnapshot

public java.util.Hashtable getSnapshot()
Get the last loaded scenario Snapshot.

Returns:
String The Snapshot String last pushed.
See Also:
setSnapshot

getSyncFlag

public int getSyncFlag()
Get the Sync Flag.

Returns:
int The Sync Flag.
See Also:
setSnapshot

setSyncFlag

public void setSyncFlag(int iFlag)
Set the Sync Flag.

Parameters:
int - The Sync Flag.

getScript

public java.lang.String getScript()
Get the last loaded Script name.

See Also:
load

getRundir

public java.lang.String getRundir()
Get the last loaded rundir.

See Also:
load

getArguments

public java.util.ArrayList getArguments()
Get the last loaded argument list. This returns an ArrayList of strings.

See Also:
load

getFileList

public java.util.Hashtable getFileList()
Get the last loaded file list. This is NOT a dynamic representation of the scenario execution directory, rather it is a list of the files that were originally part of the scenario (and the state they were originally in).


getResults

public java.util.Hashtable getResults()
Get the return information from the last executed scenario. This returns a Hashtable of information that is thought to be relevant. The Hashtable will only be populated once execution is completed (i.e. state is "completed").


load

public void load(java.lang.String sWhence,
                 java.lang.String sName,
                 java.lang.String sScript,
                 java.lang.String sTempdir,
                 java.util.ArrayList alsArguments,
                 java.lang.String srootPath)
          throws com.pushtotest.testnetwork.Scenario.StateException,
                 com.pushtotest.testnetwork.Scenario.PrepException
Load an execution scenario.

Parameters:
sWhence - An indicator of where the request came from.
sName - The name of the scenario.
sScript - The script to execute.
sRundir - The directory to use for execution.
alsArguments - The list of arguments to pass to the python processor.
Throws:
StateException - If the TestNode state is not available or aborted.
PrepException - If the execution directory cannot be created.
com.pushtotest.testnetwork.Scenario.StateException
com.pushtotest.testnetwork.Scenario.PrepException

run

public void run(int usecase)
         throws com.pushtotest.testnetwork.Scenario.StateException,
                java.lang.Throwable
Run an usecase from a loaded Scenario.

Throws:
StateException - If the TestNode state is not loaded.
com.pushtotest.testnetwork.Scenario.StateException
java.lang.Throwable

abort

public void abort()
           throws com.pushtotest.testnetwork.Scenario.StateException
Abort a running Scenario.

Throws:
StateException - If the TestNode state is not loaded.
com.pushtotest.testnetwork.Scenario.StateException

abandon

public void abandon()
             throws com.pushtotest.testnetwork.Scenario.StateException
Abandon a loaded Scenario before it is executed. Note that calling this on an available node is silently ignored.

Throws:
StateException - If the TestNode state is not loaded (although this exception is surpressed on available nodes).
com.pushtotest.testnetwork.Scenario.StateException

getStatus

public java.lang.String getStatus()
Get the execution status of a Scenario. This can be any of the states returned from getState(). Or if the thread has completed but hasn't yet been reaped it can return "NotAlive" (this should be a very small window of opportunity as the reaper should come along and convert this state to "completed"). Or if the thread was aborted but hasn't yet been reaped it can return "Interrupted" (this should be an even smaller window of opportunity as the abort() code should change the state to "aborted"). In the event that the thread is in running state but the AgentRunner thread was never set, it will return a value of "Inconsistent". This case should really not occur, if it does there is a serious bug in the Scenario handler.

Returns:
Any of the states from getState() or "NotAlive" or "Interrupted".

completion

public void completion(java.lang.Thread tAgentRunner)
                throws com.pushtotest.testnetwork.Scenario.CallerException
Mark a Scenario as completed. This is only to be called by the AgentRunner that is executing the scenario in question. This is basically a callback.

Throws:
CallerException - If called by someone other than the associated AgentRunner.
com.pushtotest.testnetwork.Scenario.CallerException

release

public void release()
             throws com.pushtotest.testnetwork.Scenario.StateException,
                    java.lang.SecurityException
Release this Scenario so that it can be available for other executions. Until this method is called, the scenario will remain in the "completed" state and new scenarios cannot be loaded, nor anything executed. This method is only available from the completed state.

Throws:
StateException - If the TestNode state is not completed
com.pushtotest.testnetwork.Scenario.StateException
java.lang.SecurityException


Copyright © 2003 PushToTest. All Rights Reserved.