abbot.script
Class Assert

java.lang.Object
  |
  +--abbot.script.Step
        |
        +--abbot.script.Call
              |
              +--abbot.script.PropertyCall
                    |
                    +--abbot.script.Assert
All Implemented Interfaces:
Serializable, Tags, XMLifiable

public class Assert
extends PropertyCall

Encapsulate an assertion (or a wait). Usage:

<assert method="[!]assertXXX" args="..." [class="..."]>
<assert method="[!](get|is|has)XXX" component="component_id" value="...">
<assert method="[!]XXX" args="..." class="...">

<wait ... [timeout="..."] [pollInterval="..."]>
The first example above invokes a core assertion provided by the ComponentTester class; the class tag is required for assertions based on a class derived from ComponentTester; the class tag indicates the Component class, not the Tester class (the appropriate tester class will be derived automatically). The second format indicates a property check on the given component, and an expected value must be provided; the method name must start with "is", "get", or "has". Finally, any arbitrary static boolean method may be used in the assertion; you must specify the class and arguments.

You can invert the sense of either form of assertion by inserting a '!' character before the method name, or adding an invert="true" attribute.

The default timeout for a wait is ten seconds; the default poll interval (sleep time between checking the assertion) is 1/10 second.

See Also:
Serialized Form

Field Summary
static int DEFAULT_INTERVAL
          Default interval between checking the assertion in a wait.
static int DEFAULT_TIMEOUT
          Default timeout before a wait will indicate failure.
 
Fields inherited from interface abbot.script.Tags
TAG_ACTION, TAG_ARGS, TAG_ASSERT, TAG_AWTTESTSCRIPT, TAG_CALL, TAG_CLASS, TAG_CLASSPATH, TAG_COMMENT, TAG_COMPONENT, TAG_COUNT, TAG_DELEGATE, TAG_DESC, TAG_DOCBASE, TAG_EVENT, TAG_FILENAME, TAG_FORKED, TAG_HEIGHT, TAG_HORDER, TAG_ID, TAG_INDEX, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARAMS, TAG_PARENT, TAG_POLL_INTERVAL, TAG_PROPERTY, TAG_SAMPLE, TAG_SCRIPT, TAG_SEQUENCE, TAG_SLOW, 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_VMARGS, TAG_VORDER, TAG_WAIT, TAG_WIDTH, TAG_WINDOW, TAG_X, TAG_Y
 
Constructor Summary
Assert(Resolver resolver, Map attributes)
          Construct an assert step from XML.
Assert(Resolver resolver, String desc, String methodName, String[] args, Class testedClass, String expectedResult, boolean invert)
          Assertion provided by a ComponentTester subclass which operates on a Component subclass.
Assert(Resolver resolver, String desc, String methodName, String[] args, String expectedResult, boolean invert)
          Assertion provided by the ComponentTester class.
Assert(Resolver resolver, String desc, String methodName, String[] args, String componentID, String expectedResult, boolean invert)
          Property assertion on Component subclass.
 
Method Summary
protected  void evaluateAssertion()
          Check the assertion.
 Map getAttributes()
          Save attributes specific to this Step class.
protected  String getDefaultDescription()
          Return a reasonable default description for this script step.
 String getExpectedResult()
           
 long getPollInterval()
           
 long getTimeout()
           
 String getUsage()
          Provide a usage String for this step.
 String getXMLTag()
          Define the XML tag to use for this script step.
 boolean isInverted()
           
 boolean isWait()
           
protected  void runStep()
          Run this step.
 void setExpectedResult(String result)
           
 void setInverted(boolean invert)
           
 void setPollInterval(long interval)
           
 void setTimeout(long timeout)
           
 void setWait(boolean wait)
           
protected  String toString(Object obj)
          Print out arrays by individual element.
 
Methods inherited from class abbot.script.PropertyCall
getComponentID, getTarget, isPropertyMethod, setComponentID
 
Methods inherited from class abbot.script.Call
encode, getArgs, getEncodedArguments, getMethod, getMethodName, getTargetClass, getTargetClassName, invoke, resolveMethod, setArguments, setMethodName, setTargetClassName
 
Methods inherited from class abbot.script.Step
addAttributes, addContent, createAttributeMap, createStep, createStep, getDescription, getFinder, getResolver, parseStepAttributes, resolve, resolveClass, resolveTester, run, setDescription, setScriptError, simpleClassName, toEditableString, toString, toXML, toXMLString, usage, usage
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_INTERVAL

public static final int DEFAULT_INTERVAL
Default interval between checking the assertion in a wait.

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
Default timeout before a wait will indicate failure.
Constructor Detail

Assert

public Assert(Resolver resolver,
              Map attributes)
Construct an assert step from XML.

Assert

public Assert(Resolver resolver,
              String desc,
              String methodName,
              String[] args,
              String expectedResult,
              boolean invert)
Assertion provided by the ComponentTester class.

Assert

public Assert(Resolver resolver,
              String desc,
              String methodName,
              String[] args,
              Class testedClass,
              String expectedResult,
              boolean invert)
Assertion provided by a ComponentTester subclass which operates on a Component subclass.

Assert

public Assert(Resolver resolver,
              String desc,
              String methodName,
              String[] args,
              String componentID,
              String expectedResult,
              boolean invert)
Property assertion on Component subclass.
Method Detail

setWait

public void setWait(boolean wait)

isWait

public boolean isWait()

setPollInterval

public void setPollInterval(long interval)

getPollInterval

public long getPollInterval()

setTimeout

public void setTimeout(long timeout)

getTimeout

public long getTimeout()

getExpectedResult

public String getExpectedResult()

setExpectedResult

public void setExpectedResult(String result)

isInverted

public boolean isInverted()

setInverted

public void setInverted(boolean invert)

getXMLTag

public String getXMLTag()
Description copied from class: Step
Define the XML tag to use for this script step.
Overrides:
getXMLTag in class Call

getUsage

public String getUsage()
Description copied from class: Step
Provide a usage String for this step.
Overrides:
getUsage in class Call

getDefaultDescription

protected String getDefaultDescription()
Description copied from class: Step
Return a reasonable default description for this script step. This value is used in the absence of an explicit description.
Overrides:
getDefaultDescription in class PropertyCall

getAttributes

public Map getAttributes()
Description copied from class: PropertyCall
Save attributes specific to this Step class.
Overrides:
getAttributes in class PropertyCall

evaluateAssertion

protected void evaluateAssertion()
                          throws Throwable
Check the assertion.

toString

protected String toString(Object obj)
Print out arrays by individual element.

runStep

protected void runStep()
                throws Throwable
Run this step.
Overrides:
runStep in class Call


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

SourceForge