Polishing
See gh-2023
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -103,17 +103,18 @@ public class XpathExpectationsHelper {
|
||||
MatcherAssert.assertThat("XPath " + this.expression, node, matcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the content, evaluate the XPath expression as a {@link NodeList},
|
||||
* and assert it with the given {@code Matcher<NodeList>}.
|
||||
*/
|
||||
public void assertNodeList(byte[] content, @Nullable String encoding, final Matcher<? super NodeList> matcher)
|
||||
throws Exception {
|
||||
/**
|
||||
* Parse the content, evaluate the XPath expression as a {@link NodeList},
|
||||
* and assert it with the given {@code Matcher<NodeList>}.
|
||||
* @since 5.2.2
|
||||
*/
|
||||
public void assertNodeList(byte[] content, @Nullable String encoding, final Matcher<? super NodeList> matcher)
|
||||
throws Exception {
|
||||
|
||||
Document document = parseXmlByteArray(content, encoding);
|
||||
NodeList nodeList = evaluateXpath(document, XPathConstants.NODESET, NodeList.class);
|
||||
MatcherAssert.assertThat("XPath " + this.getXpathExpression(), nodeList, matcher);
|
||||
}
|
||||
Document document = parseXmlByteArray(content, encoding);
|
||||
NodeList nodeList = evaluateXpath(document, XPathConstants.NODESET, NodeList.class);
|
||||
MatcherAssert.assertThat("XPath " + this.getXpathExpression(), nodeList, matcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the XPath expression and assert the resulting content exists.
|
||||
|
||||
@@ -70,16 +70,17 @@ public class XpathResultMatchers {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate the XPath and assert the {@link NodeList} content found with the
|
||||
* given Hamcrest {@link Matcher}.
|
||||
*/
|
||||
public ResultMatcher nodeList(final Matcher<? super NodeList> matcher) {
|
||||
return result -> {
|
||||
MockHttpServletResponse response = result.getResponse();
|
||||
this.xpathHelper.assertNodeList(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Evaluate the XPath and assert the {@link NodeList} content found with the
|
||||
* given Hamcrest {@link Matcher}.
|
||||
* @since 5.2.2
|
||||
*/
|
||||
public ResultMatcher nodeList(final Matcher<? super NodeList> matcher) {
|
||||
return result -> {
|
||||
MockHttpServletResponse response = result.getResponse();
|
||||
this.xpathHelper.assertNodeList(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the response encoding if explicitly defined in the response, {code null} otherwise.
|
||||
|
||||
Reference in New Issue
Block a user