diff --git a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java index 028d8b06c5c..bea2c6d87ff 100644 --- a/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java +++ b/spring-test/src/main/java/org/springframework/test/util/XpathExpectationsHelper.java @@ -41,7 +41,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.util.xml.SimpleNamespaceContext; - /** * A helper class for applying assertions via XPath expressions. * @@ -96,7 +95,7 @@ public class XpathExpectationsHelper { * Parse the content, evaluate the XPath expression as a {@link Node}, * and assert it with the given {@code Matcher}. */ - public void assertNode(byte[] content, @Nullable String encoding, final Matcher matcher) + public void assertNode(byte[] content, @Nullable String encoding, Matcher matcher) throws Exception { Node node = evaluateXpath(content, encoding, Node.class); @@ -108,7 +107,7 @@ public class XpathExpectationsHelper { * and assert it with the given {@code Matcher}. * @since 5.2.2 */ - public void assertNodeList(byte[] content, @Nullable String encoding, final Matcher matcher) + public void assertNodeList(byte[] content, @Nullable String encoding, Matcher matcher) throws Exception { Document document = parseXmlByteArray(content, encoding); @@ -122,7 +121,7 @@ public class XpathExpectationsHelper { */ public void exists(byte[] content, @Nullable String encoding) throws Exception { Node node = evaluateXpath(content, encoding, Node.class); - AssertionErrors.assertTrue("XPath " + this.expression + " does not exist", node != null); + AssertionErrors.assertNotNull("XPath " + this.expression + " does not exist", node); } /** @@ -131,7 +130,7 @@ public class XpathExpectationsHelper { */ public void doesNotExist(byte[] content, @Nullable String encoding) throws Exception { Node node = evaluateXpath(content, encoding, Node.class); - AssertionErrors.assertTrue("XPath " + this.expression + " exists", node == null); + AssertionErrors.assertNull("XPath " + this.expression + " exists", node); } /** diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java index 0010ec9dabe..e6025e1b3c0 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/result/XpathResultMatchers.java @@ -75,7 +75,7 @@ public class XpathResultMatchers { * given Hamcrest {@link Matcher}. * @since 5.2.2 */ - public ResultMatcher nodeList(final Matcher matcher) { + public ResultMatcher nodeList(Matcher matcher) { return result -> { MockHttpServletResponse response = result.getResponse(); this.xpathHelper.assertNodeList(response.getContentAsByteArray(), getDefinedEncoding(response), matcher);