junit.extensions.awt.script
Class Step

java.lang.Object
  |
  +--junit.extensions.awt.script.Step
All Implemented Interfaces:
Tags, XMLifiable
Direct Known Subclasses:
MethodInvocation, SendEvent, Sequence, Terminate

public abstract class Step
extends java.lang.Object
implements Tags, XMLifiable

Provides access to one step (line) from a script. A Step is the basic unit of execution. When run, a Step sends events to registered listener indicating STEP_START, optionally STEP_PROGRESS, and STEP_END events. If the Step encounters unexpected exceptions or test failures, it will send a STEP_ERROR or STEP_FAILURE event. By default, a Step will stop execution when a failure or error is encountered.


Field Summary
protected  java.util.ArrayList listeners
           
protected static org.apache.xerces.parsers.DOMParser parser
           
static java.lang.String STEP_END
          The step has finished.
static java.lang.String STEP_ERROR
          The step encountered an error.
static java.lang.String STEP_FAILURE
          The step failed.
static java.lang.String STEP_PROGRESS
          The step is N% complete.
static java.lang.String STEP_START
          The step has begun executing.
 
Fields inherited from interface junit.extensions.awt.script.Tags
TAG_ACTION, TAG_ARGS, TAG_ASSERT, TAG_AWTTESTSCRIPT, TAG_CLASS, TAG_COMPONENT, TAG_COUNT, TAG_DESC, TAG_EVENT, TAG_FILENAME, TAG_ID, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARENT, TAG_POLL_INTERVAL, TAG_SCRIPT, TAG_SEQUENCE, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_WAIT, TAG_WINDOW, TAG_X, TAG_Y
 
Constructor Summary
Step(Resolver resolver, ComponentFinder finder, java.util.HashMap attributes)
           
Step(Resolver resolver, ComponentFinder finder, java.lang.String description)
           
 
Method Summary
 void addStepListener(StepListener sl)
           
protected  void clearFailures()
           
protected static java.util.HashMap createAttributeMap(org.w3c.dom.Element el)
           
static Step createStep(Resolver resolver, ComponentFinder finder, org.w3c.dom.Element el)
          Factory method, equivalent to a "fromXML".
static Step createStep(Resolver resolver, ComponentFinder finder, java.lang.String xml)
          Create a new step from an XML string.
protected  void fireStepEnd()
           
protected  void fireStepError()
           
protected  void fireStepEvent(StepEvent event)
           
protected  void fireStepEvent(java.lang.String type)
           
protected  void fireStepEvent(java.lang.String type, int val)
           
protected  void fireStepFailure()
           
protected  void fireStepProgress(int val)
           
protected  void fireStepStart()
           
protected  java.lang.String getAttributes()
          Attributes to save in script.
protected  java.lang.String getContents()
          Override if the step actually has some contents.
protected abstract  java.lang.String getDefaultDescription()
          Return a reasonable default description for this script step.
 java.lang.String getDescription()
           
 java.lang.Throwable getError()
           
 junit.framework.AssertionFailedError getFailure()
           
 ComponentFinder getFinder()
           
 Resolver getResolver()
           
 boolean getStopOnError()
           
 boolean getStopOnFailure()
           
protected  ComponentTester getTester()
           
protected abstract  java.lang.String getUsage()
          Provide a usage String for this step.
protected abstract  java.lang.String getXMLTag()
          Define the XML tag to use for this script step.
protected  void parseAttributes(java.util.HashMap attributes)
           
 void removeStepListener(StepListener sl)
           
protected  java.awt.Component resolve(java.lang.String name)
          Resolve the given name into a component.
protected  ComponentTester resolveTester()
          Override this to provide a more specific tester.
 void run()
          Main run method, which stores any failures or exceptions for later retrieval.
protected abstract  void runStep()
          Main run method, which stores any failures or exceptions for later retrieval.
 void setDescription(java.lang.String desc)
           
protected  void setError(java.lang.Throwable thr)
           
protected  void setFailure(junit.framework.AssertionFailedError err)
           
 void setStopOnError(boolean stop)
           
 void setStopOnFailure(boolean stop)
           
protected  java.lang.String simpleClassName(java.lang.Class cls)
           
 java.lang.String toString()
          Return a description of this script step.
 java.lang.String toXML()
          Convert the object to XML.
protected  void usage()
          Throw an invalid script exception describing the proper script usage.
protected  void usage(java.lang.String details)
          Throw an invalid script exception describing the proper script usage.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STEP_START

public static final java.lang.String STEP_START
The step has begun executing.

STEP_PROGRESS

public static final java.lang.String STEP_PROGRESS
The step is N% complete.

STEP_END

public static final java.lang.String STEP_END
The step has finished.

STEP_ERROR

public static final java.lang.String STEP_ERROR
The step encountered an error.

STEP_FAILURE

public static final java.lang.String STEP_FAILURE
The step failed. This represents a test that failed to produce the expected results.

parser

protected static org.apache.xerces.parsers.DOMParser parser

listeners

protected java.util.ArrayList listeners
Constructor Detail

Step

public Step(Resolver resolver,
            ComponentFinder finder,
            java.util.HashMap attributes)

Step

public Step(Resolver resolver,
            ComponentFinder finder,
            java.lang.String description)
Method Detail

parseAttributes

protected void parseAttributes(java.util.HashMap attributes)

runStep

protected abstract void runStep()
                         throws java.lang.Throwable
Main run method, which stores any failures or exceptions for later retrieval.

clearFailures

protected void clearFailures()

setStopOnFailure

public void setStopOnFailure(boolean stop)

setStopOnError

public void setStopOnError(boolean stop)

getStopOnFailure

public boolean getStopOnFailure()

getStopOnError

public boolean getStopOnError()

run

public void run()
         throws java.lang.Throwable
Main run method, which stores any failures or exceptions for later retrieval. Any step will fire STEP_START on starting, and one of STEP_END, STEP_FAILURE, or STEP_ERROR upon termination.

getDescription

public java.lang.String getDescription()

setDescription

public void setDescription(java.lang.String desc)

getError

public java.lang.Throwable getError()

setError

protected void setError(java.lang.Throwable thr)

getFailure

public junit.framework.AssertionFailedError getFailure()

setFailure

protected void setFailure(junit.framework.AssertionFailedError err)

addStepListener

public void addStepListener(StepListener sl)

removeStepListener

public void removeStepListener(StepListener sl)

fireStepEvent

protected void fireStepEvent(StepEvent event)

fireStepEvent

protected void fireStepEvent(java.lang.String type)

fireStepEvent

protected void fireStepEvent(java.lang.String type,
                             int val)

fireStepStart

protected void fireStepStart()

fireStepProgress

protected void fireStepProgress(int val)

fireStepEnd

protected void fireStepEnd()

fireStepFailure

protected void fireStepFailure()

fireStepError

protected void fireStepError()

getXMLTag

protected abstract java.lang.String getXMLTag()
Define the XML tag to use for this script step.

getUsage

protected abstract java.lang.String getUsage()
Provide a usage String for this step.

getDefaultDescription

protected abstract java.lang.String getDefaultDescription()
Return a reasonable default description for this script step. This value is used in the absence of an explicit description.

usage

protected void usage()
              throws InvalidScriptException
Throw an invalid script exception describing the proper script usage. This should be used by derived classes whenever parsing indicates invalid input.

usage

protected void usage(java.lang.String details)
              throws InvalidScriptException
Throw an invalid script exception describing the proper script usage. This should be used by dervied classes whenever parsing indicates invalid input.

getAttributes

protected java.lang.String getAttributes()
Attributes to save in script. FIXME use a hash table?

resolve

protected java.awt.Component resolve(java.lang.String name)
                              throws ComponentNotFoundException
Resolve the given name into a component.

resolveTester

protected ComponentTester resolveTester()
Override this to provide a more specific tester.

getTester

protected ComponentTester getTester()

getFinder

public ComponentFinder getFinder()

getResolver

public Resolver getResolver()

getContents

protected java.lang.String getContents()
Override if the step actually has some contents. In most cases, it wont't.

toXML

public java.lang.String toXML()
Convert the object to XML.
Specified by:
toXML in interface XMLifiable

toString

public java.lang.String toString()
Return a description of this script step.
Overrides:
toString in class java.lang.Object

createStep

public static Step createStep(Resolver resolver,
                              ComponentFinder finder,
                              java.lang.String xml)
                       throws InvalidScriptException
Create a new step from an XML string.

createAttributeMap

protected static java.util.HashMap createAttributeMap(org.w3c.dom.Element el)

createStep

public static Step createStep(Resolver resolver,
                              ComponentFinder finder,
                              org.w3c.dom.Element el)
                       throws InvalidScriptException
Factory method, equivalent to a "fromXML".

simpleClassName

protected java.lang.String simpleClassName(java.lang.Class cls)