org.apache.anteater.test
Class Matcher

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--org.apache.anteater.test.BaseTask
                    |
                    +--org.apache.anteater.test.Matcher
All Implemented Interfaces:
Groupable, ObjectModel, org.apache.tools.ant.TaskContainer

public class Matcher
extends BaseTask
implements org.apache.tools.ant.TaskContainer, ObjectModel

A Matcher corresponds to a <match> element, and describes a set of tests that need to be applied on an object. Multiple Matchers can be applied on an object, by grouping them into a MatcherSet; see the description of this class to understand how this works.

A Matcher contains multiple tests which are to be verified on an object. These tests are described by MatcherTest instances. All of the tests have to succeed for a matcher to succeed.

Version:
$Revision: 1.20 $ $Date: 2002/10/26 11:49:50 $
Author:
Costin Manolache, Ovidiu Predescu
See Also:
Represents a set of <matcher> elements, and takes each Matcher through it's lifecycle., A test element inside a <matcher>, eg <responseCode>, <regexp> etc.

Field Summary
protected  boolean error
          If the test failed, was it an error?
protected  Logger logger
           
protected  MatcherSet matcherSet
           
protected  ArrayList matcherTests
           
protected  Object matchOn
           
protected  boolean result
          Did the test pass?
protected  String successProp
          Property to set if this match element's tests all succeed.
protected  String successVal
          Value to set successProp to if this match element's tests all succeed.
 
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
 
Fields inherited from interface org.apache.anteater.test.ObjectModel
NAMESPACES_KEY, PROPERTIES_KEY
 
Constructor Summary
Matcher()
           
 
Method Summary
 void addTask(org.apache.tools.ant.Task task)
           
 void execute()
          Run all the MatcherTest children of this instance.
 boolean getErrorFlag()
          Returns whether this matcher exited with an error, as opposed to a failure.
 Object getMatchOn()
           
 boolean getResult()
          Retusn whether this matcher succeeded.
 void setAssign(String propName)
          Set the name of a property which will be set in the project if this matcher succeeds.
 void setLogger(Logger logger)
          Set the logger.
 void setMatcherSet(MatcherSet matcherSet)
           
 void setMatchOn(Object matchOn)
           
 void setObjectModel(Map objectModel)
          Set the context in the receiving object.
 void setValue(String propVal)
          Set the value to which the setAssign(java.lang.String) property will be set if this matcher succeeds.
 
Methods inherited from class org.apache.anteater.test.BaseTask
debug, getDebug, getGroup, print, println, resolveContentURL, setDebug, 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

successProp

protected String successProp
Property to set if this match element's tests all succeed. If null, none will be set.


successVal

protected String successVal
Value to set successProp to if this match element's tests all succeed.


logger

protected Logger logger

matchOn

protected Object matchOn

matcherSet

protected MatcherSet matcherSet

result

protected boolean result
Did the test pass?


error

protected boolean error
If the test failed, was it an error?


matcherTests

protected ArrayList matcherTests
Constructor Detail

Matcher

public Matcher()
Method Detail

setObjectModel

public void setObjectModel(Map objectModel)
Description copied from interface: ObjectModel
Set the context in the receiving object.

Specified by:
setObjectModel in interface ObjectModel
Parameters:
objectModel - a HashMap value

setLogger

public void setLogger(Logger logger)
Set the logger. Matcher is responsible for calling log methods related to an individual test, ie Logger.startTest(org.apache.anteater.test.MatcherTest), Logger.endTest(org.apache.anteater.test.MatcherTest), and Logger.testLog(java.lang.String), Logger.testError(java.lang.String, java.lang.Exception), Logger.testFailure(java.lang.String, java.lang.Exception).


setAssign

public void setAssign(String propName)
Set the name of a property which will be set in the project if this matcher succeeds. This allows tasks following the action task to take action based on which matcher succeeded.


setValue

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


setMatchOn

public void setMatchOn(Object matchOn)

getMatchOn

public Object getMatchOn()

setMatcherSet

public void setMatcherSet(MatcherSet matcherSet)

addTask

public void addTask(org.apache.tools.ant.Task task)
Specified by:
addTask in interface org.apache.tools.ant.TaskContainer

getResult

public boolean getResult()
Retusn whether this matcher succeeded. false implies an error or failure occurred.


getErrorFlag

public boolean getErrorFlag()
Returns whether this matcher exited with an error, as opposed to a failure. Only meaningful if getResult() returns false.


execute

public void execute()
             throws org.apache.tools.ant.BuildException
Run all the MatcherTest children of this instance. If one of them fails, the whole matcher fails. Any child which is not a MatcherTest instance, is simply executed.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if a logger isn't set, something goes drastically wrong, or a non-Anteater nested task fails.


Ant Functional Tester -- see Project home page for details