summaryrefslogtreecommitdiffstats
path: root/vespa-http-client
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@verizonmedia.com>2019-03-22 14:17:06 +0100
committerJon Bratseth <bratseth@verizonmedia.com>2019-03-22 14:17:06 +0100
commit90cc2bce893af67d0fbb6b16ea29276d9ee5573a (patch)
tree806e2b61943d9f83524469c032061e380bcfbca6 /vespa-http-client
parent0f16f5bb7869dec2f2c4677d3b3e07d1ec788408 (diff)
Remove testutils dependency
Diffstat (limited to 'vespa-http-client')
-rw-r--r--vespa-http-client/pom.xml63
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java2
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Cluster.java3
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/ConnectionParams.java2
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Endpoint.java3
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java2
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/SessionParams.java3
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/JsonTestHelper.java52
-rw-r--r--vespa-http-client/src/test/java/com/yahoo/vespa/http/client/runner/JsonReaderTest.java2
9 files changed, 94 insertions, 38 deletions
diff --git a/vespa-http-client/pom.xml b/vespa-http-client/pom.xml
index 34392548de7..9cccaea0950 100644
--- a/vespa-http-client/pom.xml
+++ b/vespa-http-client/pom.xml
@@ -15,10 +15,12 @@
<description>Independent external feeding API towards Vespa.</description>
<dependencies>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>annotations</artifactId>
- </dependency>
+
+ <!-- NOTE: Adding dependencies here may break clients because this is used outside an OSGi container with
+ manually set up classpaths and possibly no access to the with-dependencies jar.
+
+ Vespa dependencies should not be added.
+ -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@@ -33,20 +35,9 @@
<version>3.4</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>1.8.4</version>
- <scope>test</scope>
+ <groupId>uk.co.datumedge</groupId>
+ <artifactId>hamcrest-json</artifactId>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
@@ -65,12 +56,40 @@
<artifactId>airline</artifactId>
<version>0.6</version>
</dependency>
+
+ <!-- Test dependencies -->
<dependency>
- <groupId>com.yahoo.vespa</groupId>
- <artifactId>testutil</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
+ <groupId>com.google.code.findbugs</groupId>
+ <artifactId>annotations</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.8.4</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
<plugins>
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java
index 92dd0715f06..821e12b4140 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.http.client;
import com.yahoo.vespa.http.client.config.Endpoint;
import com.yahoo.vespa.http.client.core.Document;
import com.yahoo.vespa.http.client.core.Exceptions;
-import net.jcip.annotations.Immutable;
import java.util.ArrayList;
import java.util.Collection;
@@ -83,7 +82,6 @@ public class Result {
/**
* Information in a Result for a single operation sent to a single endpoint.
*/
- @Immutable
public static final class Detail {
private final ResultType resultType;
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Cluster.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Cluster.java
index 557aeedb4c1..4707cdb705c 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Cluster.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Cluster.java
@@ -1,8 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.client.config;
-import net.jcip.annotations.Immutable;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
@@ -13,7 +11,6 @@ import java.util.List;
*
* @author Einar M R Rosenvinge
*/
-@Immutable
public final class Cluster {
/**
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/ConnectionParams.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/ConnectionParams.java
index 3747f37eb00..3296cf13875 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/ConnectionParams.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/ConnectionParams.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.http.client.config;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import net.jcip.annotations.Immutable;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import javax.net.ssl.HostnameVerifier;
@@ -26,7 +25,6 @@ import java.util.concurrent.TimeUnit;
*
* @author Einar M R Rosenvinge
*/
-@Immutable
public final class ConnectionParams {
/**
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Endpoint.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Endpoint.java
index de7bfb5bb19..7ba6dd04a80 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Endpoint.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/Endpoint.java
@@ -1,8 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.client.config;
-import net.jcip.annotations.Immutable;
-
import java.io.Serializable;
/**
@@ -11,7 +9,6 @@ import java.io.Serializable;
*
* @author Einar M R Rosenvinge
*/
-@Immutable
public final class Endpoint implements Serializable {
/**
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java
index 4adf3912dbd..30f1ad11d3a 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/FeedParams.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.http.client.config;
import com.google.common.annotations.Beta;
-import net.jcip.annotations.Immutable;
import java.util.concurrent.TimeUnit;
@@ -13,7 +12,6 @@ import java.util.concurrent.TimeUnit;
* @author Einar M R Rosenvinge
*/
-@Immutable
public final class FeedParams {
public boolean getDenyIfBusyV3() {
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/SessionParams.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/SessionParams.java
index eb3e8ec982b..daa6eecb823 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/SessionParams.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/config/SessionParams.java
@@ -1,8 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.client.config;
-import net.jcip.annotations.Immutable;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -18,7 +16,6 @@ import java.util.List;
* @see com.yahoo.vespa.http.client.SessionFactory
* @see Builder
*/
-@Immutable
public final class SessionParams {
/**
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
new file mode 100644
index 00000000000..0081497fb20
--- /dev/null
+++ b/vespa-http-client/src/test/java/com/yahoo/vespa/http/client/JsonTestHelper.java
@@ -0,0 +1,52 @@
+// 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.google.common.base.Joiner;
+import org.hamcrest.MatcherAssert;
+
+import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
+
+import java.io.UncheckedIOException;
+
+public class JsonTestHelper {
+
+ private static final ObjectMapper mapper = new ObjectMapper();
+
+ /**
+ * 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 134274ff869..e2046fe17a6 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,7 +12,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import static com.yahoo.test.json.JsonTestHelper.inputJson;
+import static com.yahoo.vespa.http.client.JsonTestHelper.inputJson;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;