public class XPathValidator extends BaseConditionalValidator
Use is of the form:
<xpath select="..." [ value="..." ] [ cond="true | false" ] />
Where :
select
is an XPath expression, designed to match a node in
the XML body of the response.value
is an option value which the string value of the
selected node should match.cond
is an optional boolean value, indicating
whether the test logic is to be inverted. Defaults to
true
.
If the user has specified a value
, then the XPath
expression is expected to evaluate to a text or attribute node (or other
textual 'leaf' nodes), in which case the selected value must match that
specified.
If no value is specified, then the XPath expression will be used to check for the existence of a node.
If the XPath expression evaluates to a boolean condition (eg
<xpath select="foo/bar='baz'"/>), then the condition will be evaluated and will
result in the test passing or failing. Equivalently, an expression may be
specified, and value
used to require a specific value (eg
<xpath select="/foo/bar" value="baz"/>).
Finally, setting cond="false"
negates the sense of the
test, allowing one to test for the nonexistence or
inequality of nodes and values.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
_lastSelected |
protected java.lang.String |
_select |
protected java.lang.String |
_value |
_condition, _log
_label
Constructor and Description |
---|
XPathValidator() |
XPathValidator(java.lang.String label) |
XPathValidator(java.lang.String label,
java.lang.String select,
boolean cond,
java.lang.String value) |
Modifier and Type | Method and Description |
---|---|
boolean |
assertTrue(Response response)
Return true or false, depending on whether or not
the test conditions were met.
|
java.lang.String |
generateBareExceptionMessage()
The BASE exception message for a subclass of
BaseConditionalValidator.
|
void |
setSelect(java.lang.String select) |
void |
setValue(java.lang.String value) |
getCondition, setCondition, throwValidationException, validate
fail, getLabel, setLabel
protected java.lang.String _select
protected java.lang.String _value
protected java.lang.Object _lastSelected
public XPathValidator()
public XPathValidator(java.lang.String label)
public XPathValidator(java.lang.String label, java.lang.String select, boolean cond, java.lang.String value)
public void setSelect(java.lang.String select)
public void setValue(java.lang.String value)
public boolean assertTrue(Response response) throws ValidationException
BaseConditionalValidator
assertTrue
in class BaseConditionalValidator
response
- HTTP responseValidationException
- when a validation failspublic java.lang.String generateBareExceptionMessage()
BaseConditionalValidator
generateBareExceptionMessage
in class BaseConditionalValidator
Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.