org.apache.anteater.test
Class ActionTask

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.anteater.test.BaseTask
                    |
                    +--org.apache.anteater.test.ActionTask
All Implemented Interfaces:
Groupable
Direct Known Subclasses:
FileRequest, HttpRequest, Listener

public abstract class ActionTask
extends BaseTask

Common class used to represent the common functionality of running multiple matchers on:

Since:
September 27, 2001
Version:
$Revision: 1.39 $ $Date: 2003/03/09 15:29:24 $
Author:
Ovidiu Predescu, Jeff Turner

Field Summary
protected  Boolean haltonerror
           
protected  CompositeLogger logger
           
protected  MatcherSet matcherSet
           
protected  List reqFeatures
           
protected  boolean result
           
protected  Session session
           
protected  String successProp
          Property to set if this action task succeeds.
protected  String successVal
          Value to set successProp to if this action task succeeds.
 
Fields inherited from class org.apache.anteater.test.BaseTask
debug, debugWasSet
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
ActionTask()
           
 
Method Summary
 void addConfiguredLogger(LoggerFactory loggerFactory)
           
 void addConfiguredSession(Session session)
           
 void addConfiguredUses(Uses uses)
           
 void addMatch(Matcher matcher)
           
 void addNamespace(Namespace ns)
           
protected abstract  Object createMatchObject()
          This lifecycle method is called during execute(), and should be used to create the object on which Matchers should match on.
 void execute()
          Main lifecycle method.
abstract  String getId()
          Return a String identification of this HTTP action suitable for reporting.
protected  Map getObjectModel()
          Return the live object model.
 Map getProperties()
          Retrieves all Properties set for this task (from the group), plus a few 'virtual' properties, namely 'task.description', 'target.description' and 'project.description'.
protected  String getProperty(String key)
          Retrieve the value of a specific property (set from a group).
protected  int getPropertyAsInt(String key)
          Retrieve the value of a specific property (set from a group) as an int
 boolean getResult()
           
abstract  String getURL()
          Return the URL associated with this task (that it implements or tests).
 void setAssign(String propName)
          Set the name of a property which will be set in the project if this action task succeeds.
 void setDebug(int debug)
          Set the debug level.
 void setHaltonerror(Boolean haltonerror)
           
 void setValue(String propVal)
          Set the value to which the setAssign(java.lang.String) property will be set if this action task succeeds.
 
Methods inherited from class org.apache.anteater.test.BaseTask
debug, getDebug, getGroup, print, println, resolveContentURL, setGroup, setGroup
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected CompositeLogger logger

matcherSet

protected MatcherSet matcherSet

result

protected boolean result

haltonerror

protected Boolean haltonerror

session

protected Session session

reqFeatures

protected List reqFeatures

successProp

protected String successProp
Property to set if this action task succeeds. If null, none will be set.


successVal

protected String successVal
Value to set successProp to if this action task succeeds.

Constructor Detail

ActionTask

public ActionTask()
Method Detail

getObjectModel

protected Map getObjectModel()
Return the live object model.


getProperties

public Map getProperties()
Retrieves all Properties set for this task (from the group), plus a few 'virtual' properties, namely 'task.description', 'target.description' and 'project.description'. Used by loggers to report all set properties.

Returns:
A non-null Map, cloned from the internal version, mapping String names to String properties.

getProperty

protected String getProperty(String key)
Retrieve the value of a specific property (set from a group).

Parameters:
key - Name of the property, eg 'debug', 'host', 'task.description'
Returns:
String value of the property, or null if it didn't exist.

getPropertyAsInt

protected int getPropertyAsInt(String key)
Retrieve the value of a specific property (set from a group) as an int

Parameters:
key - Name of the property, eg 'debug', 'maxredirects'
Returns:
int value of the property, or null if it didn't exist.

addMatch

public void addMatch(Matcher matcher)

addConfiguredSession

public void addConfiguredSession(Session session)

addNamespace

public void addNamespace(Namespace ns)

addConfiguredUses

public void addConfiguredUses(Uses uses)

setAssign

public void setAssign(String propName)
Set the name of a property which will be set in the project if this action task succeeds. This is useful when used in conjuction with haltonerror=false, in order to implement user-defined error handling.


setValue

public void setValue(String propVal)
Set the value to which the setAssign(java.lang.String) property will be set if this action task succeeds.


setDebug

public void setDebug(int debug)
Description copied from class: BaseTask
Set the debug level.

Overrides:
setDebug in class BaseTask
Parameters:
debug - an int value

setHaltonerror

public void setHaltonerror(Boolean haltonerror)

addConfiguredLogger

public void addConfiguredLogger(LoggerFactory loggerFactory)

getId

public abstract String getId()
Return a String identification of this HTTP action suitable for reporting. The string should identify this object within a list of others. It is used to identify this ActionTask in test reports.


getURL

public abstract String getURL()
Return the URL associated with this task (that it implements or tests).


createMatchObject

protected abstract Object createMatchObject()
                                     throws Exception
This lifecycle method is called during execute(), and should be used to create the object on which Matchers should match on. Typically, this will be a HttpMessage of some sort.

As this method is called from execute(), it can rely on the setXxx methods having been called.

Exception

execute

public void execute()
Main lifecycle method. Sets up the object model, creates the object to match on (usually a HTTP response), sets up the matchers via a MatcherSet, and runs the matchers.

Usually, subclasses can get away with not touching this method, but instead overriding the createMatchObject() method, which is called from this method.

Overrides:
execute in class org.apache.tools.ant.Task

getResult

public boolean getResult()


Ant Functional Tester -- see Project home page for details