From fcbf06f0505cb4e5fbefae0c162e40eb42519a61 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Fri, 27 Jul 2018 08:14:07 -0400 Subject: [PATCH] Disable equals in JsonPath~ and XPathAssertions Issue: SPR-17091 --- .../test/web/reactive/server/JsonPathAssertions.java | 7 +++++++ .../test/web/reactive/server/XpathAssertions.java | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java index 69c6293cf6d..96675e85b21 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java @@ -176,4 +176,11 @@ public class JsonPathAssertions { return this.bodySpec; } + + @Override + public boolean equals(Object obj) { + throw new AssertionError("Object#equals is disabled " + + "to avoid being used in error instead of JsonPathAssertions#isEqualTo(String)."); + } + } diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java index 9b0f496292c..8082b32c8ce 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/XpathAssertions.java @@ -163,7 +163,6 @@ public class XpathAssertions { }); } - private WebTestClient.BodyContentSpec assertWith(CheckedExceptionTask task) { try { task.run(); @@ -190,6 +189,13 @@ public class XpathAssertions { } + @Override + public boolean equals(Object obj) { + throw new AssertionError("Object#equals is disabled " + + "to avoid being used in error instead of XPathAssertions#isEqualTo(String)."); + } + + /** * Lets us be able to use lambda expressions that could throw checked exceptions, since * {@link XpathExpectationsHelper} throws {@link Exception} on its methods.