abbot.script
Class StepRunner

java.lang.Object
  extended by abbot.script.StepRunner
Direct Known Subclasses:
ForkedStepRunner, ForkedStepRunner.SlaveStepRunner

public class StepRunner
extends Object

Provides control and tracking of the execution of a step or series of steps. By default the runner stops execution on the first encountered failure/error. The running environment is preserved to the extent possible, which includes discarding any GUI components created by the code under test.

If you wish to preserve the application state when there is an error, you can use the method setTerminateOnError(boolean).


Nested Class Summary
protected  class StepRunner.ExitHandler
           
 
Field Summary
protected  AWTFixtureHelper helper
           
protected  Hierarchy hierarchy
           
 
Constructor Summary
StepRunner()
          This ctor uses a new instance of TestHierarchy as the default Hierarchy.
StepRunner(AWTFixtureHelper helper)
          Create a new runner.
 
Method Summary
 void addStepListener(StepListener sl)
           
protected  void checkFile(Script script)
          Throw an exception if the file does not exist.
protected  void clearErrors()
           
protected  SecurityManager createSecurityManager()
          Create a security manager to use for the duration of this runner's execution.
protected  void fireStepEnd(Step step)
           
protected  void fireStepError(Step step, Throwable thr)
           
protected  void fireStepEvent(StepEvent event)
          If this is used to propagate a failure/error, be sure to invoke setError on the step first.
protected  void fireStepFailure(Step step, Throwable afe)
           
protected  void fireStepProgress(Step step, int val)
           
protected  void fireStepStart(Step step)
           
 UIContext getCurrentContext()
           
 Throwable getError(Step step)
           
 Hierarchy getHierarchy()
           
 boolean getStopOnError()
           
 boolean getStopOnFailure()
           
 boolean getTerminateOnError()
           
protected  void installSecurityManager()
          Install a security manager to ensure we prevent the AUT from exiting and can clean up when it tries to.
 void launch(Script step)
          Similar to run(Step), but defers to the Script to determine what subset of steps should be run as the UI context.
protected  void removeSecurityManager()
           
 void removeStepListener(StepListener sl)
           
 void run(Step step)
          Run the given step, propagating any failures or errors to listeners.
protected  void runStep(Step step)
          Main run method, which stores any failures or exceptions for later retrieval.
protected  void setError(Step step, Throwable thr)
           
 void setStopOnError(boolean stop)
           
 void setStopOnFailure(boolean stop)
           
 void setTerminateOnError(boolean state)
          Set whether the application under test should be terminated when an error is encountered and script execution stopped.
 void stop()
          Stop execution of the script after the current step completes.
 void stop(boolean terminate)
          Stop execution, indicating whether to terminate the app.
 boolean stopped()
          Return whether the runner has been stopped.
 void terminate()
          Dispose of any extant windows and restore any saved environment state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

helper

protected AWTFixtureHelper helper

hierarchy

protected Hierarchy hierarchy
Constructor Detail

StepRunner

public StepRunner()
This ctor uses a new instance of TestHierarchy as the default Hierarchy. Note that any existing GUI components at the time of this object's creation will be ignored.


StepRunner

public StepRunner(AWTFixtureHelper helper)
Create a new runner. The given Hierarchy maintains which GUI components are in or out of scope of the runner. The AWTFixtureHelper will be used to restore state if terminate() is called.

Method Detail

getHierarchy

public Hierarchy getHierarchy()
Returns:
The designated hierarchy for this StepRunner, or null if none.

getCurrentContext

public UIContext getCurrentContext()

setStopOnFailure

public void setStopOnFailure(boolean stop)

setStopOnError

public void setStopOnError(boolean stop)

getStopOnFailure

public boolean getStopOnFailure()

getStopOnError

public boolean getStopOnError()

stop

public void stop()
Stop execution of the script after the current step completes. The launched application will be left in its current state.


stop

public void stop(boolean terminate)
Stop execution, indicating whether to terminate the app.


stopped

public boolean stopped()
Return whether the runner has been stopped.


createSecurityManager

protected SecurityManager createSecurityManager()
Create a security manager to use for the duration of this runner's execution. The default prevents invoked applications from invoking System.exit(int) and invokes terminate() instead.


installSecurityManager

protected void installSecurityManager()
Install a security manager to ensure we prevent the AUT from exiting and can clean up when it tries to.


removeSecurityManager

protected void removeSecurityManager()

run

public void run(Step step)
         throws Throwable
Run the given step, propagating any failures or errors to listeners. This method should be used for any execution that should be treated as a single logical action. This method is primarily used to execute a script, but may be used in other circumstances to execute one or more steps in isolation. The terminate() method will be invoked if the script is stopped for any reason, unless setTerminateOnError(boolean) has been called with a false argument. Otherwise terminate() will only be called if a Terminate step is encountered.

Throws:
Throwable
See Also:
terminate()

setTerminateOnError

public void setTerminateOnError(boolean state)
Set whether the application under test should be terminated when an error is encountered and script execution stopped. The default implementation always terminates.


getTerminateOnError

public boolean getTerminateOnError()

clearErrors

protected void clearErrors()

checkFile

protected void checkFile(Script script)
                  throws InvalidScriptException
Throw an exception if the file does not exist.

Throws:
InvalidScriptException

runStep

protected void runStep(Step step)
                throws Throwable
Main run method, which stores any failures or exceptions for later retrieval. Any step will fire STEP_START events to all registered StepListeners on starting, and exactly one of STEP_END, STEP_FAILURE, or STEP_ERROR upon termination. If stopOnFailure/stopOnError is set false, then both STEP_FAILURE/ERROR may be sent in addition to STEP_END.

Throws:
Throwable

launch

public void launch(Script step)
            throws Throwable
Similar to run(Step), but defers to the Script to determine what subset of steps should be run as the UI context.

Parameters:
step -
Throws:
Throwable

terminate

public void terminate()
Dispose of any extant windows and restore any saved environment state.


setError

protected void setError(Step step,
                        Throwable thr)

getError

public Throwable getError(Step step)

addStepListener

public void addStepListener(StepListener sl)

removeStepListener

public void removeStepListener(StepListener sl)

fireStepEvent

protected void fireStepEvent(StepEvent event)
If this is used to propagate a failure/error, be sure to invoke setError on the step first.


fireStepStart

protected void fireStepStart(Step step)

fireStepProgress

protected void fireStepProgress(Step step,
                                int val)

fireStepEnd

protected void fireStepEnd(Step step)

fireStepFailure

protected void fireStepFailure(Step step,
                               Throwable afe)

fireStepError

protected void fireStepError(Step step,
                             Throwable thr)


Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge