aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2021-10-20 14:15:00 +0200
committergjoranv <gv@verizonmedia.com>2021-10-20 14:15:00 +0200
commit56b38e771a08597b7440135879ad1630786b594c (patch)
treef47c2de24c1ac282fba7bfcf293565a836dc0333 /vespa-http-client
parente5573dc7279c54cefe47cc5eb450ff9018196145 (diff)
Remove duplicate test util class and dependency to hamcrest-json.
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/pom.xml5
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/JsonTestHelper.java61
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/runner/JsonReaderTest.java4
3 files changed, 5 insertions, 65 deletions
diff --git a/vespa-http-client/pom.xml b/vespa-http-client/pom.xml
index 644ee38367e..7028b1802ed 100644
--- a/vespa-http-client/pom.xml
+++ b/vespa-http-client/pom.xml
@@ -100,8 +100,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>uk.co.datumedge</groupId>
- <artifactId>hamcrest-json</artifactId>
+ <groupId>com.yahoo.vespa</groupId>
+ <artifactId>testutil</artifactId>
+ <version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/JsonTestHelper.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/JsonTestHelper.java
deleted file mode 100644
index b2c8e7c2f4f..00000000000
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/JsonTestHelper.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.http.client;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.google.common.base.Joiner;
-import org.hamcrest.MatcherAssert;
-
-import java.io.UncheckedIOException;
-
-import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
-
-public class JsonTestHelper {
-
- private static final ObjectMapper mapper = createMapper();
-
- private static ObjectMapper createMapper() {
- ObjectMapper mapper = new ObjectMapper();
- mapper.registerModule(new Jdk8Module());
- mapper.registerModule(new JavaTimeModule());
- return mapper;
- }
-
- /**
- * Convenience method to input JSON without escaping double quotes and newlines
- * Each parameter represents a line of JSON encoded data
- * The lines are joined with newline and single quotes are replaced with double quotes
- */
- public static String inputJson(String... lines) {
- return Joiner.on("\n").join(lines).replaceAll("'", "\"");
- }
-
- /** Structurally compare two JSON encoded strings */
- public static void assertJsonEquals(String inputJson, String expectedJson) {
- MatcherAssert.assertThat(inputJson, sameJSONAs(expectedJson));
- }
-
- /** Structurally compare a {@link JsonNode} and a JSON string. */
- public static void assertJsonEquals(JsonNode left, String rightJson) {
- try {
- String leftJson = mapper.writeValueAsString(left);
- assertJsonEquals(leftJson, rightJson);
- } catch (JsonProcessingException e) {
- throw new UncheckedIOException(e);
- }
- }
-
- /** Structurally compare two {@link JsonNode}s. */
- public static void assertJsonEquals(JsonNode left, JsonNode right) {
- try {
- String leftJson = mapper.writeValueAsString(left);
- String rightJson = mapper.writeValueAsString(right);
- assertJsonEquals(leftJson, rightJson);
- } catch (JsonProcessingException e) {
- throw new UncheckedIOException(e);
- }
- }
-}
diff --git a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/runner/JsonReaderTest.java b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/runner/JsonReaderTest.java
index 779e4713ce2..0a5b3771958 100644
--- a/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/runner/JsonReaderTest.java
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/runner/JsonReaderTest.java
@@ -12,9 +12,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import static com.yahoo.vespa.http.client.JsonTestHelper.inputJson;
+import static com.yahoo.test.json.JsonTestHelper.inputJson;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertThat;
public class JsonReaderTest {