public class XpathExpectationsHelper extends Object
Constructor and Description |
---|
XpathExpectationsHelper(String expression,
Map<String,String> namespaces,
Object... args)
XpathExpectationsHelper constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
assertBoolean(String content,
boolean expectedValue)
Apply the XPath expression and assert the resulting content as a Boolean.
|
void |
assertNode(String content,
org.hamcrest.Matcher<? super Node> matcher)
Parse the content, evaluate the XPath expression as a
Node ,
and assert it with the given Matcher<Node> . |
void |
assertNodeCount(String content,
int expectedCount)
Apply the XPath expression and assert the resulting content as an integer.
|
void |
assertNodeCount(String content,
org.hamcrest.Matcher<Integer> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertNumber(String content,
Double expectedValue)
Apply the XPath expression and assert the resulting content as a Double.
|
void |
assertNumber(String content,
org.hamcrest.Matcher<? super Double> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertString(String content,
org.hamcrest.Matcher<? super String> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertString(String content,
String expectedValue)
Apply the XPath expression and assert the resulting content as a String.
|
void |
doesNotExist(String content)
Apply the XPath expression and assert the resulting content does not exist.
|
protected <T> T |
evaluateXpath(Document document,
QName evaluationType,
Class<T> expectedClass)
Apply the XPath expression to given document.
|
void |
exists(String content)
Apply the XPath expression and assert the resulting content exists.
|
protected XPathExpression |
getXpathExpression()
Return the compiled XPath expression.
|
protected Document |
parseXmlString(String xml)
Parse the given XML content to a
Document . |
public XpathExpectationsHelper(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
expression
- the XPath expressionnamespaces
- XML namespaces referenced in the XPath expression, or null
args
- arguments to parameterize the XPath expression with using the
formatting specifiers defined in String.format(String, Object...)
XPathExpressionException
protected XPathExpression getXpathExpression()
public void assertNode(String content, org.hamcrest.Matcher<? super Node> matcher) throws Exception
Node
,
and assert it with the given Matcher<Node>
.Exception
protected Document parseXmlString(String xml) throws Exception
Document
.xml
- the content to parseException
protected <T> T evaluateXpath(Document document, QName evaluationType, Class<T> expectedClass) throws XPathExpressionException
XPathExpressionException
public void exists(String content) throws Exception
Exception
- if content parsing or expression evaluation failspublic void doesNotExist(String content) throws Exception
Exception
- if content parsing or expression evaluation failspublic void assertNodeCount(String content, org.hamcrest.Matcher<Integer> matcher) throws Exception
Exception
- if content parsing or expression evaluation failspublic void assertNodeCount(String content, int expectedCount) throws Exception
Exception
- if content parsing or expression evaluation failspublic void assertString(String content, org.hamcrest.Matcher<? super String> matcher) throws Exception
Exception
- if content parsing or expression evaluation failspublic void assertString(String content, String expectedValue) throws Exception
Exception
- if content parsing or expression evaluation failspublic void assertNumber(String content, org.hamcrest.Matcher<? super Double> matcher) throws Exception
Exception
- if content parsing or expression evaluation failspublic void assertNumber(String content, Double expectedValue) throws Exception
Exception
- if content parsing or expression evaluation fails