com.canoo.webtest.steps
Class Step

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.canoo.webtest.steps.Step
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
AbstractBaseStep, AbstractBrowserAction, AbstractExcelStep, AbstractFilter, AbstractPdfStep, AbstractStepContainer, AbstractVerifyFormStep, AbstractVerifyTextStep, BaseStoreStep, CloseWindow, DragAndDrop, EmailSetConfig, EnableJavaScript, ExpectDialog, GroovyStep, MouseBaseStep, ReportLinksStep, ScriptStep, SelectForm, SelectWindow, TestInfoStep, VerifyImages, VerifyLinkedContent, VerifyLinks, VerifyNoDialogs

public abstract class Step
extends Task
implements Serializable, Cloneable

Abstract superclass for all test steps. Provides generic services for all subclasses.

Author:
Carsten Seibert, Marc Guillemot, Paul King, ASERT
See Also:
Serialized Form

Field Summary
static String DEFAULT_DESCRIPTION
          Deprecated. The default is now not to set the value at all.
static String ELEMENT_ATTRIBUTE_ID
           
static String ELEMENT_ATTRIBUTE_NAME
           
static String PROPERTY_TYPE_ANT
          The property is an ant property.
static String PROPERTY_TYPE_ANT_STRICT
          The property is an ant property that must not overwrite an existing property.
static String PROPERTY_TYPE_DEFAULT
          The property type is set according to webtest's defaultPropertyType.
static String PROPERTY_TYPE_DYNAMIC
          The property is a dynamic property.
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
protected Step()
          This is the abstract base class for all test step specifications.
 
Method Summary
protected  void addComputedParameters(Map map)
          Adds parameters that are not issued from the config file but computed at runtime by the step
 Object clone()
          This creates a bitwise copy of the receiver.
abstract  void doExecute()
          Called to perform the step's functionality.
protected  void emptyParamCheck(String param, String paramName)
           
 void execute()
          Ant calls this method to invoke this task's functionality.
protected  Map getComputedParameters()
          TODO: would be cleaner to notify the result listener and to give him this information
 Context getContext()
           
protected  String getDefaultPropertyType()
           
 String getDescription(String prefix, String suffix)
          Gets the description with a prefix and suffix if the description is set.
 long getDuration()
          Gets the execution time for a completed step.
 Map getParameterDictionary()
          Gets a snapshot of the values.
protected  String getStepLabel()
           
protected static IStringVerifier getVerifier(boolean useRegex)
           
 Map getWebtestProperties()
           
 Map getWebtestProperties(String propertyType)
           
 String getWebtestProperty(String name)
          Gets a property of the default type.
 String getWebtestProperty(String name, String propertyType)
          Gets a property of the specified type
protected  void handleException(Throwable t)
          Called if doExecute() throws an exception
 boolean hasDescription()
           
protected  void integerParamCheck(String param, String paramName, boolean nonNegative)
           
 boolean isCompleted()
           
 boolean isPerformingAction()
          Indicates if this step performs an action on the browser
 boolean isStarted()
           
 boolean isSuccessful()
           
 void notifyCompleted()
          Called after doExecute() has completed (successfully or not)
 void notifyStarted()
          Called before calling doExecute()
protected  void notifyStepResultsListeners()
          Notifies the interested project build listeners (typically only the StepExecutionListener) that this step has produced results
 void notifySuccess()
           
protected  void nullParamCheck(Object param, String paramName)
           
protected  void nullResponseCheck()
           
protected  void optionalIntegerParamCheck(String param, String paramName, boolean nonNegative)
           
protected  void paramCheck(boolean condition, String message)
          Throw an exception if the condition holds.
protected  void positiveOrZeroParamCheck(int value, String paramName)
          Checks that the parameter's value is non negative
 void setStepid(String description)
          Deprecated. since June 10 2005. Use ProjectComponent.setDescription(String) (setter should not be removed for compatibility with existing test sequences)
 void setWebtestProperty(String name, String value)
          Sets a property of the default type.
 void setWebtestProperty(String name, String value, String propertyType)
          Sets a property of the default type.
 String toString()
           
protected  void verifyParameters()
          Called to let the step's implementation validate its parameters.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ELEMENT_ATTRIBUTE_NAME

public static final String ELEMENT_ATTRIBUTE_NAME
See Also:
Constant Field Values

ELEMENT_ATTRIBUTE_ID

public static final String ELEMENT_ATTRIBUTE_ID
See Also:
Constant Field Values

DEFAULT_DESCRIPTION

public static final String DEFAULT_DESCRIPTION
Deprecated. The default is now not to set the value at all.
See Also:
Constant Field Values

PROPERTY_TYPE_DEFAULT

public static final String PROPERTY_TYPE_DEFAULT
The property type is set according to webtest's defaultPropertyType.


PROPERTY_TYPE_DYNAMIC

public static final String PROPERTY_TYPE_DYNAMIC
The property is a dynamic property.

See Also:
Constant Field Values

PROPERTY_TYPE_ANT

public static final String PROPERTY_TYPE_ANT
The property is an ant property.

See Also:
Constant Field Values

PROPERTY_TYPE_ANT_STRICT

public static final String PROPERTY_TYPE_ANT_STRICT
The property is an ant property that must not overwrite an existing property.

See Also:
Constant Field Values
Constructor Detail

Step

protected Step()
This is the abstract base class for all test step specifications.

Method Detail

getContext

public Context getContext()

doExecute

public abstract void doExecute()
                        throws Exception
Called to perform the step's functionality. Before calling this method, the step has been completely initialized (including expanding and verifying the parameters) and the environment notified of the start.

Throws:
Exception

execute

public void execute()
Ant calls this method to invoke this task's functionality. We expand and verify the steps parameters then call doExecute() as well as handle lifecycle notifications.

Overrides:
execute in class Task

isPerformingAction

public boolean isPerformingAction()
Indicates if this step performs an action on the browser


notifyStepResultsListeners

protected void notifyStepResultsListeners()
Notifies the interested project build listeners (typically only the StepExecutionListener) that this step has produced results


verifyParameters

protected void verifyParameters()
Called to let the step's implementation validate its parameters. The method is called after parameter extensions but before doExecute(). This implementation does nothing, overwrite as needed.


hasDescription

public boolean hasDescription()

getDescription

public String getDescription(String prefix,
                             String suffix)
Gets the description with a prefix and suffix if the description is set.

Parameters:
prefix - A string to display before the description.
suffix - A string to display after the description.
Returns:
the concatenation of prefix, description and suffix.

getDuration

public long getDuration()
Gets the execution time for a completed step.

Returns:
the execution time in ms

getStepLabel

protected String getStepLabel()

isCompleted

public boolean isCompleted()

isStarted

public boolean isStarted()

isSuccessful

public boolean isSuccessful()

notifyCompleted

public void notifyCompleted()
Called after doExecute() has completed (successfully or not)


notifyStarted

public void notifyStarted()
Called before calling doExecute()


notifySuccess

public void notifySuccess()

setStepid

public void setStepid(String description)
Deprecated. since June 10 2005. Use ProjectComponent.setDescription(String) (setter should not be removed for compatibility with existing test sequences)

Parameters:
description -

toString

public String toString()
Overrides:
toString in class Object

getDefaultPropertyType

protected String getDefaultPropertyType()

setWebtestProperty

public void setWebtestProperty(String name,
                               String value)
Sets a property of the default type.

Parameters:
name - The name of the property.
value - The value of the property.

setWebtestProperty

public void setWebtestProperty(String name,
                               String value,
                               String propertyType)
Sets a property of the default type.

Parameters:
name - The name of the property.
value - The value of the property.
propertyType - The kind of property desired. One of PROPERTY_TYPE_ANT, PROPERTY_TYPE_ANT_STRICT, PROPERTY_TYPE_DYNAMIC or PROPERTY_TYPE_DEFAULT.

getWebtestProperty

public String getWebtestProperty(String name)
Gets a property of the default type.

Parameters:
name - The name of the property.
Returns:
The value of the property.

getWebtestProperty

public String getWebtestProperty(String name,
                                 String propertyType)
Gets a property of the specified type

Parameters:
name - The name of the property.
propertyType - The kind of property desired. One of PROPERTY_TYPE_ANT, PROPERTY_TYPE_DYNAMIC or PROPERTY_TYPE_DEFAULT.
Returns:
The value of the property.

getWebtestProperties

public Map getWebtestProperties()

getWebtestProperties

public Map getWebtestProperties(String propertyType)

clone

public Object clone()
             throws CloneNotSupportedException
This creates a bitwise copy of the receiver. Since we do not reference any complex objects as attributes, the default implementation of object will do. The mere relay to the super implementation is left in the code as a reminder that this needs to be updated as soon as complex objects are aggregated right here or in a subclass.

Overrides:
clone in class ProjectComponent
Throws:
CloneNotSupportedException

getVerifier

protected static IStringVerifier getVerifier(boolean useRegex)

handleException

protected void handleException(Throwable t)
Called if doExecute() throws an exception

Parameters:
t - the thrown exception

paramCheck

protected void paramCheck(boolean condition,
                          String message)
Throw an exception if the condition holds.

Parameters:
condition - If true, throws the exception.
message - The error message.

nullParamCheck

protected void nullParamCheck(Object param,
                              String paramName)

emptyParamCheck

protected void emptyParamCheck(String param,
                               String paramName)

positiveOrZeroParamCheck

protected void positiveOrZeroParamCheck(int value,
                                        String paramName)
Checks that the parameter's value is non negative

Parameters:
paramName - the name of the parameter
value - the parameter value
Throws:
StepExecutionException - if the value is negative

integerParamCheck

protected void integerParamCheck(String param,
                                 String paramName,
                                 boolean nonNegative)

optionalIntegerParamCheck

protected void optionalIntegerParamCheck(String param,
                                         String paramName,
                                         boolean nonNegative)

nullResponseCheck

protected void nullResponseCheck()

getParameterDictionary

public Map getParameterDictionary()
Gets a snapshot of the values. As the value of the attributes can change over time, it is not possible to fill and cache the Map. Either fill the Map everytime, or skip the fields and use only the Map.

This method returns all the parameters that were discovered at build time and stored in the .attributes resource. Overwrite this method if your step doesn't have a .attributes resource

Returns:
A Map of (attribute name, attribute value) for this step.

addComputedParameters

protected void addComputedParameters(Map map)
Adds parameters that are not issued from the config file but computed at runtime by the step

Parameters:
map - the map in which the parameters should be added

getComputedParameters

protected Map getComputedParameters()
TODO: would be cleaner to notify the result listener and to give him this information

Returns:
the "results" parameter of the step

Copyright © 2001-2007 Canoo Engineering AG, Basel. All rights reserved.