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(byte[] content,
String encoding,
boolean expectedValue)
Apply the XPath expression and assert the resulting content as a Boolean.
|
void |
assertNode(byte[] content,
String encoding,
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(byte[] content,
String encoding,
int expectedCount)
Apply the XPath expression and assert the resulting content as an integer.
|
void |
assertNodeCount(byte[] content,
String encoding,
org.hamcrest.Matcher<Integer> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertNumber(byte[] content,
String encoding,
Double expectedValue)
Apply the XPath expression and assert the resulting content as a Double.
|
void |
assertNumber(byte[] content,
String encoding,
org.hamcrest.Matcher<? super Double> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertString(byte[] content,
String encoding,
org.hamcrest.Matcher<? super String> matcher)
Apply the XPath expression and assert the resulting content with the
given Hamcrest matcher.
|
void |
assertString(byte[] content,
String encoding,
String expectedValue)
Apply the XPath expression and assert the resulting content as a String.
|
void |
doesNotExist(byte[] content,
String encoding)
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(byte[] content,
String encoding)
Apply the XPath expression and assert the resulting content exists.
|
protected XPathExpression |
getXpathExpression()
Return the compiled XPath expression.
|
protected Document |
parseXmlByteArray(byte[] xml,
String encoding)
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 nullargs - arguments to parameterize the XPath expression with using the
formatting specifiers defined in String.format(String, Object...)XPathExpressionExceptionprotected XPathExpression getXpathExpression()
public void assertNode(byte[] content,
String encoding,
org.hamcrest.Matcher<? super Node> matcher)
throws Exception
Node,
and assert it with the given Matcher<Node>.Exceptionprotected Document parseXmlByteArray(byte[] xml, String encoding) throws Exception
Document.xml - the content to parseencoding - optional content encoding, if provided as metadata (e.g. in HTTP headers)Exceptionprotected <T> T evaluateXpath(Document document, QName evaluationType, Class<T> expectedClass) throws XPathExpressionException
XPathExpressionExceptionpublic void exists(byte[] content,
String encoding)
throws Exception
Exception - if content parsing or expression evaluation failspublic void doesNotExist(byte[] content,
String encoding)
throws Exception
Exception - if content parsing or expression evaluation failspublic void assertNodeCount(byte[] content,
String encoding,
org.hamcrest.Matcher<Integer> matcher)
throws Exception
Exception - if content parsing or expression evaluation failspublic void assertNodeCount(byte[] content,
String encoding,
int expectedCount)
throws Exception
Exception - if content parsing or expression evaluation failspublic void assertString(byte[] content,
String encoding,
org.hamcrest.Matcher<? super String> matcher)
throws Exception
Exception - if content parsing or expression evaluation failspublic void assertString(byte[] content,
String encoding,
String expectedValue)
throws Exception
Exception - if content parsing or expression evaluation failspublic void assertNumber(byte[] content,
String encoding,
org.hamcrest.Matcher<? super Double> matcher)
throws Exception
Exception - if content parsing or expression evaluation failspublic void assertNumber(byte[] content,
String encoding,
Double expectedValue)
throws Exception
Exception - if content parsing or expression evaluation fails