public class XpathExpectationsHelper
extends java.lang.Object
Constructor and Description |
---|
XpathExpectationsHelper(java.lang.String expression,
java.util.Map<java.lang.String,java.lang.String> namespaces,
java.lang.Object... args)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
assertBoolean(java.lang.String content,
boolean expectedValue)
Apply the XPath expression and assert the resulting content as a Boolean.
|
void |
assertNode(java.lang.String content,
org.hamcrest.Matcher<? super org.w3c.dom.Node> matcher)
Parse the content, evaluate the XPath expression as a
Node , and
assert it with the given Matcher<Node> . |
void |
assertNodeCount(java.lang.String content,
int expectedCount)
Apply the XPath expression and assert the resulting content as an integer.
|
void |
assertNodeCount(java.lang.String content,
org.hamcrest.Matcher<java.lang.Integer> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertNumber(java.lang.String content,
java.lang.Double expectedValue)
Apply the XPath expression and assert the resulting content as a Double.
|
void |
assertNumber(java.lang.String content,
org.hamcrest.Matcher<? super java.lang.Double> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertString(java.lang.String content,
org.hamcrest.Matcher<? super java.lang.String> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertString(java.lang.String content,
java.lang.String expectedValue)
Apply the XPath expression and assert the resulting content as a String.
|
void |
doesNotExist(java.lang.String content)
Apply the XPath expression and assert the resulting content does not exist.
|
protected <T> T |
evaluateXpath(org.w3c.dom.Document document,
QName evaluationType,
java.lang.Class<T> expectedClass)
Apply the XPath expression to given document.
|
void |
exists(java.lang.String content)
Apply the XPath expression and assert the resulting content exists.
|
protected javax.xml.xpath.XPathExpression |
getXpathExpression() |
protected org.w3c.dom.Document |
parseXmlString(java.lang.String xml)
Parse the given XML content to a
Document . |
public XpathExpectationsHelper(java.lang.String expression, java.util.Map<java.lang.String,java.lang.String> namespaces, java.lang.Object... args) throws javax.xml.xpath.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...)
javax.xml.xpath.XPathExpressionException
protected javax.xml.xpath.XPathExpression getXpathExpression()
public void assertNode(java.lang.String content, org.hamcrest.Matcher<? super org.w3c.dom.Node> matcher) throws java.lang.Exception
Node
, and
assert it with the given Matcher<Node>
.java.lang.Exception
protected org.w3c.dom.Document parseXmlString(java.lang.String xml) throws java.lang.Exception
Document
.xml
- the content to parsejava.lang.Exception
- in case of errorsprotected <T> T evaluateXpath(org.w3c.dom.Document document, QName evaluationType, java.lang.Class<T> expectedClass) throws javax.xml.xpath.XPathExpressionException
javax.xml.xpath.XPathExpressionException
public void exists(java.lang.String content) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void doesNotExist(java.lang.String content) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void assertNodeCount(java.lang.String content, org.hamcrest.Matcher<java.lang.Integer> matcher) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void assertNodeCount(java.lang.String content, int expectedCount) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void assertString(java.lang.String content, org.hamcrest.Matcher<? super java.lang.String> matcher) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void assertString(java.lang.String content, java.lang.String expectedValue) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void assertNumber(java.lang.String content, org.hamcrest.Matcher<? super java.lang.Double> matcher) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void assertNumber(java.lang.String content, java.lang.Double expectedValue) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation failspublic void assertBoolean(java.lang.String content, boolean expectedValue) throws java.lang.Exception
java.lang.Exception
- if content parsing or expression evaluation fails