diff options
-rwxr-xr-x | config/pom.xml | 5 | ||||
-rw-r--r-- | config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java | 4 | ||||
-rw-r--r-- | config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java | 9 | ||||
-rw-r--r-- | config/src/test/java/com/yahoo/config/subscription/util/JsonHelper.java | 28 | ||||
-rw-r--r-- | document/pom.xml | 11 | ||||
-rw-r--r-- | document/src/main/java/com/yahoo/document/json/JsonWriter.java | 1 | ||||
-rw-r--r-- | document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java | 4 | ||||
-rw-r--r-- | document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java | 2 | ||||
-rw-r--r-- | testutil/pom.xml | 10 | ||||
-rw-r--r-- | testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java (renamed from document/src/test/java/com/yahoo/document/json/JsonTestHelper.java) | 8 | ||||
-rw-r--r-- | vespa-http-client/pom.xml | 6 | ||||
-rw-r--r-- | vespa-http-client/src/test/java/com/yahoo/vespa/http/client/runner/JsonReaderTest.java | 11 |
12 files changed, 38 insertions, 61 deletions
diff --git a/config/pom.xml b/config/pom.xml index 73c8cd5b5ad..3518426a7bd 100755 --- a/config/pom.xml +++ b/config/pom.xml @@ -62,11 +62,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>uk.co.datumedge</groupId> - <artifactId>hamcrest-json</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>13.0.1</version> diff --git a/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java b/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java index 7ad7144a1c8..2bc1a10b729 100644 --- a/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java @@ -11,8 +11,8 @@ import org.junit.Test; import java.util.Arrays; import java.util.List; -import static com.yahoo.config.subscription.util.JsonHelper.assertJsonEquals; -import static com.yahoo.config.subscription.util.JsonHelper.inputJson; +import static com.yahoo.test.json.JsonTestHelper.assertJsonEquals; +import static com.yahoo.test.json.JsonTestHelper.inputJson; import static org.junit.Assert.assertEquals; /** diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java index d3713eaa401..342e50821f4 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java @@ -1,22 +1,21 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.subscription; -import com.yahoo.foo.ArraytypesConfig; import com.yahoo.config.ConfigInstance; +import com.yahoo.foo.ArraytypesConfig; +import com.yahoo.foo.MaptypesConfig; import com.yahoo.foo.SimpletypesConfig; import com.yahoo.foo.SpecialtypesConfig; import com.yahoo.foo.StructtypesConfig; -import com.yahoo.foo.MaptypesConfig; import com.yahoo.slime.JsonFormat; import com.yahoo.slime.Slime; - import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; -import static com.yahoo.config.subscription.util.JsonHelper.assertJsonEquals; -import static com.yahoo.config.subscription.util.JsonHelper.inputJson; +import static com.yahoo.test.json.JsonTestHelper.assertJsonEquals; +import static com.yahoo.test.json.JsonTestHelper.inputJson; import static org.junit.Assert.fail; /** diff --git a/config/src/test/java/com/yahoo/config/subscription/util/JsonHelper.java b/config/src/test/java/com/yahoo/config/subscription/util/JsonHelper.java deleted file mode 100644 index 27ac1a1278c..00000000000 --- a/config/src/test/java/com/yahoo/config/subscription/util/JsonHelper.java +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.config.subscription.util; - -import com.google.common.base.Joiner; - -import static org.hamcrest.MatcherAssert.assertThat; -import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; - -/** - * @author Vegard Sjonfjell - */ -public class JsonHelper { - /** - * 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) { - assertThat(inputJson, sameJSONAs(expectedJson)); - } -} diff --git a/document/pom.xml b/document/pom.xml index 529107407ca..71713b27050 100644 --- a/document/pom.xml +++ b/document/pom.xml @@ -48,11 +48,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>uk.co.datumedge</groupId> - <artifactId>hamcrest-json</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>config</artifactId> <version>${project.version}</version> @@ -83,6 +78,12 @@ <classifier>no_aop</classifier> <scope>provided</scope> </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>testutil</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> <plugins> diff --git a/document/src/main/java/com/yahoo/document/json/JsonWriter.java b/document/src/main/java/com/yahoo/document/json/JsonWriter.java index 626c97a958a..420a6bb6669 100644 --- a/document/src/main/java/com/yahoo/document/json/JsonWriter.java +++ b/document/src/main/java/com/yahoo/document/json/JsonWriter.java @@ -112,6 +112,7 @@ public class JsonWriter implements DocumentWriter { Map.Entry<Field, FieldValue> entry = i.next(); entry.getValue().serialize(entry.getKey(), this); } + generator.writeEndObject(); generator.writeEndObject(); generator.flush(); diff --git a/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java b/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java index 53e7ed701a7..9a44ebc96d4 100644 --- a/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java +++ b/document/src/test/java/com/yahoo/document/json/DocumentUpdateJsonSerializerTest.java @@ -19,8 +19,8 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.UnsupportedEncodingException; -import static com.yahoo.document.json.JsonTestHelper.assertJsonEquals; -import static com.yahoo.document.json.JsonTestHelper.inputJson; +import static com.yahoo.test.json.JsonTestHelper.assertJsonEquals; +import static com.yahoo.test.json.JsonTestHelper.inputJson; /** * @author Vegard Sjonfjell diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java index 466a915f83f..206ab8e30f0 100644 --- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java +++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java @@ -59,7 +59,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; -import static com.yahoo.document.json.JsonTestHelper.inputJson; +import static com.yahoo.test.json.JsonTestHelper.inputJson; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.*; diff --git a/testutil/pom.xml b/testutil/pom.xml index 0d2aa8a4dbf..bd46d2e4c16 100644 --- a/testutil/pom.xml +++ b/testutil/pom.xml @@ -15,6 +15,11 @@ <description>Library of useful Hamcrest matchers.</description> <dependencies> <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> <scope>compile</scope> @@ -25,6 +30,11 @@ <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/document/src/test/java/com/yahoo/document/json/JsonTestHelper.java b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java index 45128e6d02a..fee6cc2fef0 100644 --- a/document/src/test/java/com/yahoo/document/json/JsonTestHelper.java +++ b/testutil/src/main/java/com/yahoo/test/json/JsonTestHelper.java @@ -1,7 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.document.json; +package com.yahoo.test.json; + import com.google.common.base.Joiner; -import static org.hamcrest.MatcherAssert.assertThat; +import org.hamcrest.MatcherAssert; + import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs; /** @@ -21,6 +23,6 @@ public class JsonTestHelper { * Structurally compare two JSON encoded strings */ public static void assertJsonEquals(String inputJson, String expectedJson) { - assertThat(inputJson, sameJSONAs(expectedJson)); + MatcherAssert.assertThat(inputJson, sameJSONAs(expectedJson)); } } diff --git a/vespa-http-client/pom.xml b/vespa-http-client/pom.xml index 9e2325e8016..563e4406fe9 100644 --- a/vespa-http-client/pom.xml +++ b/vespa-http-client/pom.xml @@ -83,6 +83,12 @@ <artifactId>airline</artifactId> <version>0.6</version> </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>testutil</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> <build> <plugins> 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 ab7dca0d5fb..eba8791bbb7 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 @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.http.client.runner; -import com.google.common.base.Joiner; import com.yahoo.vespa.http.client.FeedClient; import com.yahoo.vespa.http.client.core.JsonReader; import org.junit.Test; @@ -13,6 +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 org.hamcrest.core.Is.is; import static org.junit.Assert.*; @@ -260,13 +260,4 @@ public class JsonReaderTest { assertThat(session.documentIds.size(), is(1)); assertThat(session.documentIds.get(0), is("id:foo:music:doc:foo:bar")); } - - /** - * 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 - */ - static String inputJson(String... lines) { - return Joiner.on("\n").join(lines).replaceAll("'", "\""); - } }
\ No newline at end of file |