summaryrefslogtreecommitdiffstats
path: root/testutil
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2021-10-19 17:54:12 +0200
committergjoranv <gv@verizonmedia.com>2021-10-20 10:57:38 +0200
commit78b40a7fdca63183442e2a498cda6ae04dd8f5a8 (patch)
treeffa4fe235e6849ae76f726135dc54408145c50fe /testutil
parent3485d5e1bf9794e19b255fe5ea764bcd08adb857 (diff)
Compare json strings with Jackson instead of obscure & abandonded lib.
Diffstat (limited to 'testutil')
-rw-r--r--testutil/pom.xml5
-rw-r--r--testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java11
2 files changed, 8 insertions, 8 deletions
diff --git a/testutil/pom.xml b/testutil/pom.xml
index 26bb3056e2f..dc795a66dab 100644
--- a/testutil/pom.xml
+++ b/testutil/pom.xml
@@ -37,11 +37,6 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>uk.co.datumedge</groupId>
- <artifactId>hamcrest-json</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
diff --git a/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java
index 08afb2fd95f..05532d2a504 100644
--- a/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java
+++ b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java
@@ -5,11 +5,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
-import org.hamcrest.MatcherAssert;
import java.io.UncheckedIOException;
-import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
+import static org.junit.Assert.assertEquals;
/**
* @author Vegard Sjonfjell
@@ -29,7 +28,13 @@ public class JsonTestHelper {
/** Structurally compare two JSON encoded strings */
public static void assertJsonEquals(String inputJson, String expectedJson) {
- MatcherAssert.assertThat(inputJson, sameJSONAs(expectedJson));
+ try {
+ JsonNode expected = mapper.readTree(expectedJson);
+ JsonNode actual = mapper.readTree(inputJson);
+ assertEquals(expected, actual);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException("Exception when comparing json strings." , e);
+ }
}
/** Structurally compare a {@link JsonNode} and a JSON string. */