org.apache.anteater.test.matchers
Class XPath

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

public class XPath
extends MatcherTest

Assuming that the body of the HTTP message is an XML document, matches it using XPath.

Since:
October 1, 2001
Version:
$Revision: 1.23 $ $Date: 2003/01/18 04:09:47 $
Author:
Ovidiu Predescu

Field Summary
protected  int _group
          Which group to set the assign variable to.
protected  Boolean _ignoreSpaces
          Whether whitespace in the xpath expression's string value should be normalized in comparisons.
protected  String _pattern
          Regexp pattern that the xpath expression's string value should match.
 
Fields inherited from class org.apache.anteater.test.MatcherTest
logger, matcher, objectModel, property
 
Fields inherited from class org.apache.anteater.test.ContentHandlerTask
handlerFactory, matcherTests
 
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
XPath()
           
 
Method Summary
 void addText(String body)
          Sets the body text.
 String getSelect()
          Get XPath.
 String getValue()
          Get expected value.
 void setGroup(int num)
          Sets the regexp 'group number' whose match will be returned in the 'assign' variable.
 void setIgnoreSpaces(boolean ignore)
          Set whether whitespace will be ignored when testing.
 void setPattern(String v)
          Sets a regexp pattern that the header should match.
 void setSelect(String select)
          Set XPath expression to apply to HTTP body content.
 void setValue(String value)
          Set String value we expect the XPath to evaluate to.
 String toString()
           
 boolean validate()
          Return true if this instance matches against the matchOn object of the matcher.
 
Methods inherited from class org.apache.anteater.test.MatcherTest
getMatchOn, getResult, getText, setAssign, setLogger, setMatcher, setObjectModel, setPropertyValue
 
Methods inherited from class org.apache.anteater.test.ContentHandlerTask
addTask, execute
 
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, wait, wait, wait
 

Field Detail

_pattern

protected String _pattern
Regexp pattern that the xpath expression's string value should match.


_ignoreSpaces

protected Boolean _ignoreSpaces
Whether whitespace in the xpath expression's string value should be normalized in comparisons.


_group

protected int _group
Which group to set the assign variable to. Defaults to 0 (the whole match).

Constructor Detail

XPath

public XPath()
Method Detail

setSelect

public void setSelect(String select)
Set XPath expression to apply to HTTP body content.


getSelect

public String getSelect()
Get XPath.


setValue

public void setValue(String value)
Set String value we expect the XPath to evaluate to.


addText

public void addText(String body)
Description copied from class: MatcherTest
Sets the body text.

Overrides:
addText in class MatcherTest

getValue

public String getValue()
Get expected value. Can be set either from the 'value' attribute, or a nested element.


setPattern

public void setPattern(String v)
Sets a regexp pattern that the header should match.


setIgnoreSpaces

public void setIgnoreSpaces(boolean ignore)
Set whether whitespace will be ignored when testing. Useful when whitespace differences are incidental, eg linefeed differences. Defaults to false, ie whitespace is significant.


setGroup

public void setGroup(int num)
Sets the regexp 'group number' whose match will be returned in the 'assign' variable. Defaults to 0, ie if the text matches, it will all be returned in the 'assign' variable.

For example, if the text we're matching is 'name: Joe Bloggs':


toString

public String toString()
Overrides:
toString in class Object

validate

public boolean validate()
                 throws org.apache.tools.ant.BuildException
Description copied from class: MatcherTest
Return true if this instance matches against the matchOn object of the matcher.

Specified by:
validate in class MatcherTest
Returns:
a boolean value
org.apache.tools.ant.BuildException


Ant Functional Tester -- see Project home page for details