From e8f31cbe437ee969f4dd0490a0409b62b2fd045d Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 20 Dec 2021 18:38:08 +0100 Subject: GC deprecated junit assertThat. --- .../config/subscription/ConfigGetterTest.java | 39 +++++++------- .../subscription/ConfigInstancePayloadTest.java | 19 ++++--- .../ConfigInstanceSerializationTest.java | 7 ++- .../subscription/ConfigInstanceUtilTest.java | 38 +++++++------ .../ConfigInterruptedExceptionTest.java | 5 +- .../config/subscription/ConfigSourceSetTest.java | 7 +-- .../yahoo/config/subscription/ConfigURITest.java | 11 ++-- .../yahoo/config/subscription/FunctionTest.java | 6 +-- .../yahoo/config/subscription/NamespaceTest.java | 5 +- .../impl/FileConfigSubscriptionTest.java | 15 +++--- .../yahoo/vespa/config/ConfigBuilderMergeTest.java | 2 +- .../com/yahoo/vespa/config/ConfigCacheKeyTest.java | 13 +++-- .../vespa/config/ConfigDefinitionBuilderTest.java | 6 ++- .../yahoo/vespa/config/ConfigDefinitionTest.java | 35 ++++++------ .../vespa/config/ConfigFileFormatterTest.java | 44 +++++++-------- .../vespa/config/ConfigPayloadBuilderTest.java | 63 +++++++++++----------- .../com/yahoo/vespa/config/ConfigPayloadTest.java | 2 +- .../vespa/config/DefaultValueApplierTest.java | 25 +++++---- .../java/com/yahoo/vespa/config/ErrorCodeTest.java | 3 +- .../vespa/config/GenericConfigBuilderTest.java | 3 +- .../yahoo/vespa/config/JRTConnectionPoolTest.java | 13 ++--- .../vespa/config/LZ4PayloadCompressorTest.java | 5 +- .../java/com/yahoo/vespa/config/RawConfigTest.java | 2 +- .../config/protocol/JRTConfigRequestV3Test.java | 2 +- .../yahoo/vespa/config/protocol/PayloadTest.java | 16 +++--- .../config/protocol/SlimeTraceSerializerTest.java | 2 +- 26 files changed, 186 insertions(+), 202 deletions(-) (limited to 'config') diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java index ffbc1896aab..68cadb33ecd 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigGetterTest.java @@ -7,8 +7,7 @@ import org.junit.Test; import java.io.File; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** @@ -28,15 +27,15 @@ public class ConfigGetterTest { ConfigGetter getter = new ConfigGetter<>(AppConfig.class); AppConfig config = getter.getConfig(configId); - assertThat(config.times(), is(times)); - assertThat(config.message(), is(message)); - assertThat(config.a().size(), is(1)); - assertThat(config.a(0).name(), is(a0)); + assertEquals(times, config.times()); + assertEquals(message, config.message()); + assertEquals(1, config.a().size()); + assertEquals(a0, config.a(0).name()); AppService service = new AppService(configId, sourceSet); AppConfig serviceConfig = service.getConfig(); assertTrue(service.isConfigured()); - assertThat(config, is(serviceConfig)); + assertEquals(config, serviceConfig); service.cancelSubscription(); } @@ -45,16 +44,16 @@ public class ConfigGetterTest { public void testGetFromRawSource() { ConfigGetter getter = new ConfigGetter<>(new RawSource("message \"one\""), AppConfig.class); AppConfig config = getter.getConfig("test"); - assertThat(config.message(), is("one")); + assertEquals("one", config.message()); } @Test public void testGetTwice() { ConfigGetter getter = new ConfigGetter<>(AppConfig.class); AppConfig config = getter.getConfig("raw:message \"one\""); - assertThat(config.message(), is("one")); + assertEquals("one", config.message()); config = getter.getConfig("raw:message \"two\""); - assertThat(config.message(), is("two")); + assertEquals("two", config.message()); } @Test @@ -85,11 +84,11 @@ public class ConfigGetterTest { } private void verifyFooValues(AppConfig config) { - assertThat(config.message(), is("msg1")); - assertThat(config.times(), is(3)); - assertThat(config.a(0).name(), is("a0")); - assertThat(config.a(1).name(), is("a1")); - assertThat(config.a(2).name(), is("a2")); + assertEquals("msg1", config.message()); + assertEquals(3, config.times()); + assertEquals("a0", config.a(0).name()); + assertEquals("a1", config.a(1).name()); + assertEquals("a2", config.a(2).name()); } @Test @@ -100,15 +99,15 @@ public class ConfigGetterTest { String configId = "raw:times " + times + "\nmessage " + message + "\na[1]\na[0].name " + a0; AppConfig config = ConfigGetter.getConfig(AppConfig.class, configId); - assertThat(config.times(), is(times)); - assertThat(config.message(), is(message)); - assertThat(config.a().size(), is(1)); - assertThat(config.a(0).name(), is(a0)); + assertEquals(times, config.times()); + assertEquals(message, config.message()); + assertEquals(1, config.a().size()); + assertEquals(a0, config.a(0).name()); AppService service = new AppService(configId, sourceSet); AppConfig serviceConfig = service.getConfig(); assertTrue(service.isConfigured()); - assertThat(config, is(serviceConfig)); + assertEquals(config, serviceConfig); service.cancelSubscription(); } diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java index 3dc0f7188e3..c656bfe1a60 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java @@ -15,9 +15,8 @@ import java.util.Arrays; import java.util.List; import static com.yahoo.foo.FunctionTestConfig.*; -import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; /** @@ -131,8 +130,8 @@ public class ConfigInstancePayloadTest { try { System.out.println(payload.toString(false)); FunctionTestConfig config2 = new FunctionTestConfig((FunctionTestConfig.Builder)new ConfigTransformer<>(FunctionTestConfig.class).toConfigBuilder(payload)); - assertThat(config2, is(expected)); - assertThat(ConfigInstance.serialize(config2), is(ConfigInstance.serialize(expected))); + assertEquals(expected, config2); + assertEquals(ConfigInstance.serialize(expected), ConfigInstance.serialize(config2)); } catch (Exception e) { e.printStackTrace(); fail(); @@ -156,14 +155,14 @@ public class ConfigInstancePayloadTest { System.out.println(payload.toString()); MaptypesConfig config = ConfigInstanceUtil.getNewInstance(MaptypesConfig.class, "foo", payload); System.out.println(config); - assertThat(config.intmap().size(), is(1)); - assertThat(config.intmap("foo"), is(1337)); + assertEquals(1, config.intmap().size()); + assertEquals(1337, config.intmap("foo")); assertNotNull(config.innermap("bar")); - assertThat(config.innermap("bar").foo(), is(93)); - assertThat(config.nestedmap().size(), is(1)); + assertEquals(93, config.innermap("bar").foo()); + assertEquals(1, config.nestedmap().size()); assertNotNull(config.nestedmap("baz")); - assertThat(config.nestedmap("baz").inner("foo"), is(1)); - assertThat(config.nestedmap("baz").inner("bar"), is(2)); + assertEquals(1, config.nestedmap("baz").inner("foo")); + assertEquals(2, config.nestedmap("baz").inner("bar")); } private MaptypesConfig createMapTypesConfig() { diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java index 57ceee9b1bb..831e645c763 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java @@ -8,8 +8,7 @@ import org.junit.Test; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; /** * @author gjoranv @@ -27,8 +26,8 @@ public class ConfigInstanceSerializationTest { ConfigPayload payload = new CfgConfigPayloadBuilder().deserialize(lines); FunctionTestConfig config2 = ConfigInstanceUtil.getNewInstance(FunctionTestConfig.class, ":parent:", payload); - assertThat(config, is(config2)); - assertThat(ConfigInstance.serialize(config), is(ConfigInstance.serialize(config2))); + assertEquals(config, config2); + assertEquals(ConfigInstance.serialize(config), ConfigInstance.serialize(config2)); } } diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java index aaf6782a6ff..091494955fb 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java @@ -13,11 +13,9 @@ import org.junit.Test; import java.io.File; import java.util.Arrays; -import static org.hamcrest.CoreMatchers.is; - import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; import static com.yahoo.foo.FunctionTestConfig.*; +import static org.junit.Assert.assertTrue; /** * @author Ulf Lilleengen @@ -43,26 +41,26 @@ public class ConfigInstanceUtilTest { ConfigInstanceUtil.setValues(destination, source); FunctionTestConfig result = new FunctionTestConfig(destination); - assertThat(result.int_val(), is(-1)); - assertThat(result.string_val(), is("foo")); - assertThat(result.intarr().size(), is(1)); - assertThat(result.intarr(0), is(0)); - assertThat(result.longarr().size(), is(2)); - assertThat(result.doublearr().size(), is(3)); + assertEquals(-1, result.int_val()); + assertEquals("foo", result.string_val()); + assertEquals(1, result.intarr().size()); + assertEquals(0, result.intarr(0)); + assertEquals(2, result.longarr().size()); + assertEquals(3, result.doublearr().size()); assertEquals(2344.0, result.doublearr(0), 0.01); assertEquals(123.0, result.doublearr(1), 0.01); assertEquals(0.0, result.doublearr(2), 0.01); - assertThat(result.basicStruct().bar(), is(-1)); - assertThat(result.basicStruct().foo(), is("basicFoo")); - assertThat(result.basicStruct().intArr().size(), is(3)); - assertThat(result.basicStruct().intArr(0), is(310)); - assertThat(result.basicStruct().intArr(1), is(311)); - assertThat(result.basicStruct().intArr(2), is(0)); - assertThat(result.myarray().size(), is(3)); - assertThat(result.myarray(2).intval(), is(-1)); - assertThat(result.myarray(2).refval(), is("")); - assertThat(result.myarray(2).fileVal().value(), is("")); - assertThat(result.myarray(2).myStruct().a(), is(0)); + assertEquals(-1, result.basicStruct().bar()); + assertEquals("basicFoo", result.basicStruct().foo()); + assertEquals(3, result.basicStruct().intArr().size()); + assertEquals(310, result.basicStruct().intArr(0)); + assertEquals(311, result.basicStruct().intArr(1)); + assertEquals(0, result.basicStruct().intArr(2)); + assertEquals(3, result.myarray().size()); + assertEquals(-1, result.myarray(2).intval()); + assertTrue(result.myarray(2).refval().isEmpty()); + assertTrue(result.myarray(2).fileVal().value().isEmpty()); + assertEquals(0, result.myarray(2).myStruct().a()); } diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java index dbc47b7e24d..3f050c449c7 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java @@ -3,8 +3,7 @@ package com.yahoo.config.subscription; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; /** * @author Ulf Lilleengen @@ -14,6 +13,6 @@ public class ConfigInterruptedExceptionTest { @Test public void require_that_throwable_is_preserved() { ConfigInterruptedException e = new ConfigInterruptedException(new RuntimeException("foo")); - assertThat(e.getCause().getMessage(), is("foo")); + assertEquals("foo", e.getCause().getMessage()); } } diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java index 452b51bf408..2e46623ef9a 100755 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java @@ -6,8 +6,9 @@ import org.junit.After; import java.util.Set; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; /** * @author G. Voldengen @@ -54,7 +55,7 @@ public class ConfigSourceSetTest { // TODO: Unable to set environment, so only able to test property usage for now System.setProperty("configsources", "foo:123,bar:345,tcp/baz:333,quux"); ConfigSourceSet set = ConfigSourceSet.createDefault(); - assertThat(set.getSources().size(), is(4)); + assertEquals(4, set.getSources().size()); assertTrue(set.getSources().contains("tcp/foo:123")); assertTrue(set.getSources().contains("tcp/bar:345")); assertTrue(set.getSources().contains("tcp/baz:333")); diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java index 3c2750c55cb..5c6c09b8b18 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java @@ -6,8 +6,7 @@ import org.junit.Test; import java.io.File; import java.io.IOException; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** @@ -18,7 +17,7 @@ public class ConfigURITest { @Test public void testDefaultUri() { ConfigURI uri = ConfigURI.createFromId("foo"); - assertThat(uri.getConfigId(), is("foo")); + assertEquals("foo", uri.getConfigId()); assertTrue(uri.getSource() instanceof ConfigSourceSet); } @@ -26,21 +25,21 @@ public class ConfigURITest { public void testFileUri() throws IOException { File file = File.createTempFile("foo", ".cfg"); ConfigURI uri = ConfigURI.createFromId("file:" + file.getAbsolutePath()); - assertThat(uri.getConfigId(), is("")); + assertTrue(uri.getConfigId().isEmpty()); assertTrue(uri.getSource() instanceof FileSource); } @Test public void testDirUri() throws IOException { ConfigURI uri = ConfigURI.createFromId("dir:."); - assertThat(uri.getConfigId(), is("")); + assertTrue(uri.getConfigId().isEmpty()); assertTrue(uri.getSource() instanceof DirSource); } @Test public void testCustomUri() { ConfigURI uri = ConfigURI.createFromIdAndSource("foo", new ConfigSet()); - assertThat(uri.getConfigId(), is("foo")); + assertEquals("foo", uri.getConfigId()); assertTrue(uri.getSource() instanceof ConfigSet); } } diff --git a/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java b/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java index 97a682d3b9a..42c2c599899 100644 --- a/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/FunctionTest.java @@ -214,7 +214,7 @@ public class FunctionTest { assertEquals(0, config.intarr().size()); assertEquals(2, config.longarr().size()); assertEquals(Long.MAX_VALUE, config.longarr(0)); - assertThat(config.longarr().get(1), is(Long.MIN_VALUE)); + assertEquals(Long.MIN_VALUE, config.longarr().get(1).longValue()); assertEquals(2, config.doublearr().size()); assertEquals(1, config.stringarr().size()); assertEquals(1, config.enumarr().size()); @@ -231,8 +231,8 @@ public class FunctionTest { assertEquals("basicFoo", config.basicStruct().foo()); assertEquals(3, config.basicStruct().bar()); // new List api assertEquals(2, config.basicStruct().intArr().size()); - assertThat(config.basicStruct().intArr().get(0), is(310)); // new List api - assertThat(config.basicStruct().intArr().get(1), is(311)); // new List api + assertEquals(310, config.basicStruct().intArr().get(0).intValue()); // new List api + assertEquals(311, config.basicStruct().intArr().get(1).intValue()); // new List api assertEquals(310, config.basicStruct().intArr(0)); // short-hand assertEquals("inner0", config.rootStruct().inner0().name()); // new List api assertEquals(11, config.rootStruct().inner0().index()); diff --git a/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java b/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java index 4edf931a7c6..963f3de5e43 100644 --- a/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java @@ -4,8 +4,7 @@ package com.yahoo.config.subscription; import com.yahoo.myproject.config.NamespaceConfig; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; /** * @author gjoranv @@ -15,6 +14,6 @@ public class NamespaceTest { @Test public void verifyConfigClassWithExplicitNamespace() { NamespaceConfig config = new ConfigGetter<>(NamespaceConfig.class).getConfig("raw: a 0\n"); - assertThat(config.a(), is(0)); + assertEquals(0, config.a()); } } diff --git a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java index 74af35e39dc..e37a5d7b36b 100644 --- a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java @@ -14,11 +14,10 @@ import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; -import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** @@ -45,11 +44,11 @@ public class FileConfigSubscriptionTest { new ConfigKey<>(SimpletypesConfig.class, ""), TEST_TYPES_FILE); assertTrue(sub.nextConfig(1000)); - assertThat(sub.getConfigState().getConfig().intval(), is(23)); + assertEquals(23, sub.getConfigState().getConfig().intval()); Thread.sleep(1000); writeConfig("intval", "33"); assertTrue(sub.nextConfig(1000)); - assertThat(sub.getConfigState().getConfig().intval(), is(33)); + assertEquals(33, sub.getConfigState().getConfig().intval()); } @Test @@ -59,12 +58,12 @@ public class FileConfigSubscriptionTest { new ConfigKey<>(SimpletypesConfig.class, ""), TEST_TYPES_FILE); assertTrue(sub.nextConfig(1000)); - assertThat(sub.getConfigState().getConfig().intval(), is(23)); + assertEquals(23, sub.getConfigState().getConfig().intval()); writeConfig("intval", "33"); sub.reload(1); assertTrue(sub.nextConfig(1000)); ConfigSubscription.ConfigState configState = sub.getConfigState(); - assertThat(configState.getConfig().intval(), is(33)); + assertEquals(33, configState.getConfig().intval()); assertTrue(configState.isConfigChanged()); assertTrue(configState.isGenerationChanged()); @@ -81,7 +80,7 @@ public class FileConfigSubscriptionTest { sub.reload(2); assertTrue(sub.nextConfig(1000)); configState = sub.getConfigState(); - assertThat(configState.getConfig().intval(), is(33)); + assertEquals(33, configState.getConfig().intval()); assertFalse(configState.isConfigChanged()); assertTrue(configState.isGenerationChanged()); @@ -102,7 +101,7 @@ public class FileConfigSubscriptionTest { new DirSource(new File(cfgDir)), new TimingValues()); assertTrue(sub.nextConfig(1000)); - assertThat(sub.getConfigState().getConfig().configId(), is(cfgId)); + assertEquals(cfgId, sub.getConfigState().getConfig().configId()); } @Test(expected = IllegalArgumentException.class) diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java index 4800a05b114..93139d2c92e 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java @@ -12,7 +12,7 @@ import java.util.Arrays; import static com.yahoo.foo.MaptypesConfig.Innermap; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * SEO keywords: test override() on builders. overrideTest, testOverride diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java index 6788a2f9c36..7d6174c2fbc 100755 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java @@ -3,9 +3,8 @@ package com.yahoo.vespa.config; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * @@ -30,10 +29,10 @@ public class ConfigCacheKeyTest { assertEquals(k1, k2); assertNotEquals(k3, k2); assertNotEquals(k4, k1); - assertThat(k1.hashCode(), is(k2.hashCode())); - assertThat(k1.getDefMd5(), is(defMd5)); - assertThat(k1.toString(), is(configKey.toString() + "," + defMd5)); - assertThat(k5.hashCode(), is(not(k1.hashCode()))); + assertEquals(k2.hashCode(), k1.hashCode()); + assertEquals(defMd5, k1.getDefMd5()); + assertEquals(configKey + "," + defMd5, k1.toString()); + assertNotEquals(k1.hashCode(), k5.hashCode()); } } diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java index 68b25266de8..a9f09951d7e 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java @@ -10,7 +10,11 @@ import java.io.FileReader; import java.io.IOException; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * Unit tests for ConfigDefinitionBuilder. diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java index db12145776b..fa85f582e99 100755 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionTest.java @@ -11,8 +11,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; /** * Unit tests for ConfigDefinition. @@ -56,14 +56,14 @@ public class ConfigDefinitionTest { def.addIntDef("xyzzy", 2, 0, null); assertNull(def.getIntDefs().get("foo").getDefVal()); - assertThat(def.getIntDefs().get("foo").getMin(), is(ConfigDefinition.INT_MIN)); - assertThat(def.getIntDefs().get("foo").getMax(), is(ConfigDefinition.INT_MAX)); - assertThat(def.getIntDefs().get("bar").getDefVal(), is(0)); - assertThat(def.getIntDefs().get("baz").getDefVal(), is(1)); - - assertThat(def.getIntDefs().get("xyzzy").getDefVal(), is(2)); - assertThat(def.getIntDefs().get("xyzzy").getMin(), is(0)); - assertThat(def.getIntDefs().get("xyzzy").getMax(), is(ConfigDefinition.INT_MAX)); + assertEquals(ConfigDefinition.INT_MIN, def.getIntDefs().get("foo").getMin()); + assertEquals(ConfigDefinition.INT_MAX, def.getIntDefs().get("foo").getMax()); + assertEquals(0, def.getIntDefs().get("bar").getDefVal().longValue()); + assertEquals(1, def.getIntDefs().get("baz").getDefVal().longValue()); + + assertEquals(2, def.getIntDefs().get("xyzzy").getDefVal().longValue()); + assertEquals(0, def.getIntDefs().get("xyzzy").getMin().longValue()); + assertEquals(ConfigDefinition.INT_MAX, def.getIntDefs().get("xyzzy").getMax()); } @Test @@ -75,17 +75,16 @@ public class ConfigDefinitionTest { def.addLongDef("xyzzy", 2L, 0L, null); assertNull(def.getLongDefs().get("foo").getDefVal()); - assertThat(def.getLongDefs().get("foo").getMin(), is(ConfigDefinition.LONG_MIN)); - assertThat(def.getLongDefs().get("foo").getMax(), is(ConfigDefinition.LONG_MAX)); - assertThat(def.getLongDefs().get("bar").getDefVal(), is(1234567890123L)); + assertEquals(ConfigDefinition.LONG_MIN, def.getLongDefs().get("foo").getMin()); + assertEquals(ConfigDefinition.LONG_MAX, def.getLongDefs().get("foo").getMax()); + assertEquals(1234567890123L, def.getLongDefs().get("bar").getDefVal().longValue()); - assertThat(def.getLongDefs().get("xyzzy").getDefVal(), is(2L)); - assertThat(def.getLongDefs().get("xyzzy").getMin(), is(0L)); - assertThat(def.getLongDefs().get("xyzzy").getMax(), is(ConfigDefinition.LONG_MAX)); + assertEquals(2L, def.getLongDefs().get("xyzzy").getDefVal().longValue()); + assertEquals(0L, def.getLongDefs().get("xyzzy").getMin().longValue()); + assertEquals(ConfigDefinition.LONG_MAX, def.getLongDefs().get("xyzzy").getMax()); } @Test - @SuppressWarnings("serial") public void testDefaultsPayloadMap() { ConfigDefinition def = new ConfigDefinition("foo", "namespace1"); def.addStringDef("mystring"); @@ -122,7 +121,7 @@ public class ConfigDefinitionTest { def.addIntDef("intval"); def.addLongDef("longval"); def.addDoubleDef("doubleval"); - def.addEnumDef("enumval", new EnumDef(Arrays.asList("FOO"), "FOO")); + def.addEnumDef("enumval", new EnumDef(List.of("FOO"), "FOO")); def.addReferenceDef("refval"); def.addFileDef("fileval"); def.addInnerArrayDef("innerarr"); diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java index c86d54d7471..ab07b669bd0 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java @@ -19,15 +19,15 @@ import java.io.IOException; import java.io.StringReader; import java.nio.charset.StandardCharsets; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author Ulf Lilleengen */ public class ConfigFileFormatterTest { - private String expected_simpletypes = "stringval \"foo\"\n" + + private final String expected_simpletypes = "stringval \"foo\"\n" + "intval 324234\n" + "longval 324\n" + "doubleval 3.455\n" + @@ -66,7 +66,7 @@ public class ConfigFileFormatterTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is(expected_simpletypes)); + assertEquals(expected_simpletypes, baos.toString()); } @Test @@ -77,7 +77,7 @@ public class ConfigFileFormatterTest { InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is("")); + assertTrue(baos.toString().isEmpty()); } // TODO: Reenable this when we can reenable typechecking. @@ -121,7 +121,7 @@ public class ConfigFileFormatterTest { InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is("boolval false\n")); + assertEquals("boolval false\n", baos.toString()); } // TODO: Remove this when we can reenable typechecking. @@ -137,7 +137,8 @@ public class ConfigFileFormatterTest { InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(StandardCharsets.UTF_8), is("enumval null\nintval null\nlongval null\nboolval false\ndoubleval null\n")); + assertEquals("enumval null\nintval null\nlongval null\nboolval false\ndoubleval null\n", + baos.toString(StandardCharsets.UTF_8)); } // TODO: Reenable this when we can reenable typechecking. @@ -160,7 +161,7 @@ public class ConfigFileFormatterTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(StandardCharsets.UTF_8), is("stringval \"" + value + "\"\n")); + assertEquals("stringval \"" + value + "\"\n", baos.toString(StandardCharsets.UTF_8)); } @Test @@ -189,7 +190,7 @@ public class ConfigFileFormatterTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InnerCNode def = new DefParser("arraytypes", new StringReader(StringUtilities.implode(ArraytypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is( + assertEquals( "boolarr[0] true\n" + "boolarr[1] false\n" + "doublearr[0] 3.14\n" + @@ -201,7 +202,8 @@ public class ConfigFileFormatterTest { "longarr[0] 55\n" + "longarr[1] 66\n" + "stringarr[0] \"foo\"\n" + - "stringarr[1] \"bar\"\n")); + "stringarr[1] \"bar\"\n", + baos.toString()); } @Test @@ -221,7 +223,7 @@ public class ConfigFileFormatterTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InnerCNode def = new DefParser("maptypes", new StringReader(StringUtilities.implode(MaptypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is( + assertEquals( "boolmap{\"foo\"} true\n" + "boolmap{\"bar\"} false\n" + "intmap{\"foo\"} 1234\n" + @@ -229,7 +231,8 @@ public class ConfigFileFormatterTest { "doublemap{\"foo\"} 3.14\n" + "stringmap{\"foo\"} \"bar\"\n" + "innermap{\"bar\"}.foo 1234\n" + - "nestedmap{\"baz\"}.inner{\"foo\"} 1234\n")); + "nestedmap{\"baz\"}.inner{\"foo\"} 1234\n", + baos.toString()); } @Test @@ -246,12 +249,12 @@ public class ConfigFileFormatterTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InnerCNode def = new DefParser("structtypes", new StringReader(StringUtilities.implode(StructtypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is( + assertEquals( "simple.name \"myname\"\n" + "simple.gender FEMALE\n" + "simple.emails[0] \"foo@bar.com\"\n" + - "simple.emails[1] \"bar@baz.net\"\n" - )); + "simple.emails[1] \"bar@baz.net\"\n", + baos.toString()); } @Test @@ -286,8 +289,7 @@ public class ConfigFileFormatterTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); InnerCNode def = new DefParser("structtypes", new StringReader(StringUtilities.implode(StructtypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is( - "nested.inner.name \"baz\"\n" + + assertEquals("nested.inner.name \"baz\"\n" + "nested.inner.gender FEMALE\n" + "nested.inner.emails[0] \"foo\"\n" + "nested.inner.emails[1] \"bar\"\n" + @@ -296,8 +298,8 @@ public class ConfigFileFormatterTest { "nestedarr[0].inner.emails[0] \"foo@bar\"\n" + "nestedarr[0].inner.emails[1] \"bar@foo\"\n" + "complexarr[0].innerarr[0].name \"bar\"\n" + - "complexarr[0].innerarr[0].gender MALE\n" - )); + "complexarr[0].innerarr[0].gender MALE\n", + baos.toString()); } @Test @@ -308,7 +310,7 @@ public class ConfigFileFormatterTest { InnerCNode def = new DefParser("simpletypes", new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n"))).getTree(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ConfigFileFormat(def).encode(baos, slime); - assertThat(baos.toString(), is("stringval \"some\\\"quotes\\\\\\\"instring\"\n")); + assertEquals("stringval \"some\\\"quotes\\\\\\\"instring\"\n", baos.toString()); } @Test @@ -323,7 +325,7 @@ public class ConfigFileFormatterTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); new ConfigFileFormat(def).encode(baos, slime); System.out.println(bytesToHexString(baos.toByteArray())); - assertThat(Utf8.toString(baos.toByteArray()), is("stringval \"" + input + "\"\n")); + assertEquals(Utf8.toString(baos.toByteArray()), "stringval \"" + input + "\"\n"); } private static String bytesToHexString(byte[] bytes){ diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java index 3e5cf22ef37..cc5ec7de1ad 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java @@ -10,10 +10,8 @@ import org.junit.Test; import java.io.ByteArrayOutputStream; import java.io.IOException; -import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; /** * @author Ulf Lilleengen @@ -89,12 +87,12 @@ public class ConfigPayloadBuilderTest { map.put("barkey", "barvalue"); map.put("bazkey", "bazvalue"); map.put("fookey", "lolvalue"); - assertThat(map.getElements().size(), is(3)); + assertEquals(3, map.getElements().size()); Cursor root = createSlime(builder); Cursor a = root.field("foo"); - assertThat(a.field("barkey").asString(), is("barvalue")); - assertThat(a.field("bazkey").asString(), is("bazvalue")); - assertThat(a.field("fookey").asString(), is("lolvalue")); + assertEquals("barvalue", a.field("barkey").asString()); + assertEquals("bazvalue", a.field("bazkey").asString()); + assertEquals("lolvalue", a.field("fookey").asString()); } @Test @@ -111,7 +109,7 @@ public class ConfigPayloadBuilderTest { array.append("bar"); array.append("baz"); array.append("bim"); - assertThat(array.getElements().size(), is(3)); + assertEquals(3, array.getElements().size()); Cursor root = createSlime(builder); Cursor a = root.field("foo"); assertEquals("bar", a.entry(0).asString()); @@ -174,16 +172,16 @@ public class ConfigPayloadBuilderTest { ConfigPayloadBuilder b2 = array.get(1); ConfigPayloadBuilder b3 = array.get(0); ConfigPayloadBuilder b4 = array.get(1); - assertThat(b1, is(b3)); - assertThat(b2, is(b4)); + assertEquals(b1, b3); + assertEquals(b2, b4); ConfigPayloadBuilder.Array array_indexed = builder.getArray("bar"); ConfigPayloadBuilder bi3 = array_indexed.set(3); ConfigPayloadBuilder bi1 = array_indexed.set(1); ConfigPayloadBuilder bi32 = array_indexed.get(3); ConfigPayloadBuilder bi12 = array_indexed.get(1); - assertThat(bi12, is(bi1)); - assertThat(bi32, is(bi3)); + assertEquals(bi12, bi1); + assertEquals(bi32, bi3); } @Test @@ -204,30 +202,30 @@ public class ConfigPayloadBuilderTest { b3.getArray("eee").append("lll"); b3.setField("uuu", "vvv"); - assertThat(b1.override(b2), is(b1)); - assertThat(b1.override(b3), is(b1)); + assertEquals(b1, b1.override(b2)); + assertEquals(b1, b1.override(b3)); Cursor b1root = createSlime(b1); Cursor b2root = createSlime(b2); Cursor b3root = createSlime(b3); - assertThat(b3root.field("aaa").asString(), is("c")); - assertThat(b3root.field("bbb").field("ccc").asString(), is("fff")); - assertThat(b3root.field("eee").children(), is(1)); - assertThat(b3root.field("eee").entry(0).asString(), is("lll")); - assertThat(b3root.field("uuu").asString(), is("vvv")); - - assertThat(b2root.field("aaa").asString(), is("b")); - assertThat(b2root.field("bbb").field("ccc").asString(), is("eee")); - assertThat(b2root.field("eee").children(), is(1)); - assertThat(b2root.field("eee").entry(0).asString(), is("kkk")); - assertThat(b2root.field("uuu").asString(), is("ttt")); - - assertThat(b1root.field("aaa").asString(), is("c")); - assertThat(b1root.field("bbb").field("ccc").asString(), is("fff")); - assertThat(b1root.field("eee").children(), is(2)); - assertThat(b1root.field("eee").entry(0).asString(), is("kkk")); - assertThat(b1root.field("eee").entry(1).asString(), is("lll")); - assertThat(b1root.field("uuu").asString(), is("vvv")); + assertEquals("c", b3root.field("aaa").asString()); + assertEquals("fff", b3root.field("bbb").field("ccc").asString()); + assertEquals(1, b3root.field("eee").children()); + assertEquals("lll", b3root.field("eee").entry(0).asString()); + assertEquals("vvv", b3root.field("uuu").asString()); + + assertEquals("b", b2root.field("aaa").asString()); + assertEquals("eee", b2root.field("bbb").field("ccc").asString()); + assertEquals(1, b2root.field("eee").children()); + assertEquals("kkk", b2root.field("eee").entry(0).asString()); + assertEquals("ttt", b2root.field("uuu").asString()); + + assertEquals("c", b1root.field("aaa").asString()); + assertEquals("fff", b1root.field("bbb").field("ccc").asString()); + assertEquals(2, b1root.field("eee").children()); + assertEquals("kkk", b1root.field("eee").entry(0).asString()); + assertEquals("lll", b1root.field("eee").entry(1).asString()); + assertEquals("vvv", b1root.field("uuu").asString()); } @Test(expected=IllegalStateException.class) @@ -266,7 +264,8 @@ public class ConfigPayloadBuilderTest { ConfigPayloadBuilder builder = new ConfigPayloadBuilder(new ConfigPayload(slime)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ConfigPayload.fromBuilder(builder).serialize(baos, new JsonFormat(true)); - assertThat(baos.toString(), is("{\"foo\":\"bar\",\"foorio\":{\"bar\":\"bam\",\"bario\":{\"bim\":\"bul\"},\"blim\":[{\"fim\":\"fam\"},{\"blim\":\"blam\"}]},\"arrio\":[\"himbio\"]}")); + assertEquals("{\"foo\":\"bar\",\"foorio\":{\"bar\":\"bam\",\"bario\":{\"bim\":\"bul\"},\"blim\":[{\"fim\":\"fam\"},{\"blim\":\"blam\"}]},\"arrio\":[\"himbio\"]}", + baos.toString()); } @Test(expected=IllegalArgumentException.class) diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java index 50f4233e13a..46b710cdcf9 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java @@ -17,10 +17,10 @@ import org.junit.Test; import java.io.StringReader; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** diff --git a/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java b/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java index 0acefe5cd18..199d5f14b9f 100644 --- a/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java @@ -10,8 +10,7 @@ import org.junit.Test; import java.io.StringReader; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** @@ -43,9 +42,9 @@ public class DefaultValueApplierTest { public void require_that_simple_defaults_are_applied() { Slime slime = apply("strdef string default=\"foo\""); assertTrue(slime.get().field("str").valid()); - assertThat(slime.get().field("str").asString(), is("myvalue")); + assertEquals("myvalue", slime.get().field("str").asString()); assertTrue(slime.get().field("strdef").valid()); - assertThat(slime.get().field("strdef").asString(), is("foo")); + assertEquals("foo", slime.get().field("strdef").asString()); } @@ -54,7 +53,7 @@ public class DefaultValueApplierTest { Slime slime = apply("nested.str string default=\"bar\""); assertTrue(slime.get().field("nested").valid()); assertTrue(slime.get().field("nested").field("str").valid()); - assertThat(slime.get().field("nested").field("str").asString(), is("bar")); + assertEquals("bar", slime.get().field("nested").field("str").asString()); } @Test @@ -65,11 +64,11 @@ public class DefaultValueApplierTest { Slime slime = apply(payload, "nestedarr[].foo string", "nestedarr[].bar string default=\"bim\""); assertTrue(slime.get().field("nestedarr").valid()); - assertThat(slime.get().field("nestedarr").entries(), is(1)); + assertEquals(1, slime.get().field("nestedarr").entries()); assertTrue(slime.get().field("nestedarr").entry(0).field("foo").valid()); - assertThat(slime.get().field("nestedarr").entry(0).field("foo").asString(), is("myfoo")); + assertEquals("myfoo", slime.get().field("nestedarr").entry(0).field("foo").asString()); assertTrue(slime.get().field("nestedarr").entry(0).field("bar").valid()); - assertThat(slime.get().field("nestedarr").entry(0).field("bar").asString(), is("bim")); + assertEquals("bim", slime.get().field("nestedarr").entry(0).field("bar").asString()); } @Test @@ -79,8 +78,8 @@ public class DefaultValueApplierTest { Slime slime = apply(payload, "nestedarr[].foo string", "nestedarr[].bar string default=\"bim\""); assertTrue(slime.get().field("nestedarr").valid()); - assertThat(slime.get().field("nestedarr").entries(), is(0)); - assertThat(slime.get().field("nestedarr").type(), is(Type.ARRAY)); + assertEquals(0, slime.get().field("nestedarr").entries()); + assertEquals(Type.ARRAY, slime.get().field("nestedarr").type()); } @Test @@ -91,10 +90,10 @@ public class DefaultValueApplierTest { Slime slime = apply(payload, "nestedmap{}.foo string", "nestedmap{}.bar string default=\"bim\""); assertTrue(slime.get().field("nestedmap").valid()); - assertThat(slime.get().field("nestedmap").fields(), is(1)); + assertEquals(1, slime.get().field("nestedmap").fields()); assertTrue(slime.get().field("nestedmap").field("mykey").field("foo").valid()); - assertThat(slime.get().field("nestedmap").field("mykey").field("foo").asString(), is("myfoo")); + assertEquals("myfoo", slime.get().field("nestedmap").field("mykey").field("foo").asString()); assertTrue(slime.get().field("nestedmap").field("mykey").field("bar").valid()); - assertThat(slime.get().field("nestedmap").field("mykey").field("bar").asString(), is("bim")); + assertEquals("bim", slime.get().field("nestedmap").field("mykey").field("bar").asString()); } } diff --git a/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java b/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java index 4ae8bc676d7..3bbdd6f0aa2 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java @@ -4,8 +4,7 @@ package com.yahoo.vespa.config; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - +import static org.hamcrest.MatcherAssert.assertThat; /** * @author hmusum */ diff --git a/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java index bb612bb3245..ff801e5cf12 100644 --- a/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java @@ -9,8 +9,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Ulf Lilleengen */ diff --git a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java index 43f9a87454d..8186347f998 100644 --- a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java @@ -11,12 +11,9 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** @@ -100,7 +97,7 @@ public class JRTConnectionPoolTest { // Update to the same set, should be equal sourcePool.updateSources(twoSources); - assertThat(sourcesBefore, is(sourcePool.getSourceSet())); + assertEquals(sourcePool.getSourceSet(), sourcesBefore); // Update to new set List newSources = new ArrayList<>(); @@ -109,8 +106,8 @@ public class JRTConnectionPoolTest { sourcePool.updateSources(newSources); ConfigSourceSet newSourceSet = sourcePool.getSourceSet(); assertNotNull(newSourceSet); - assertThat(newSourceSet.getSources().size(), is(2)); - assertThat(newSourceSet, is(not(sourcesBefore))); + assertEquals(2, newSourceSet.getSources().size()); + assertNotEquals(sourcesBefore, newSourceSet); assertTrue(newSourceSet.getSources().contains("host2")); assertTrue(newSourceSet.getSources().contains("host3")); @@ -120,8 +117,8 @@ public class JRTConnectionPoolTest { sourcePool.updateSources(newSources2); ConfigSourceSet newSourceSet2 = sourcePool.getSourceSet(); assertNotNull(newSourceSet2); - assertThat(newSourceSet2.getSources().size(), is(1)); - assertThat(newSourceSet2, is(not(newSourceSet))); + assertEquals(1, newSourceSet2.getSources().size()); + assertNotEquals(newSourceSet, newSourceSet2); assertTrue(newSourceSet2.getSources().contains("host4")); sourcePool.close(); diff --git a/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java b/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java index 56bcdda20a0..c35dd016b39 100644 --- a/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java @@ -4,8 +4,7 @@ package com.yahoo.vespa.config; import com.yahoo.text.Utf8; import org.junit.Test; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertArrayEquals; /** * @author Ulf Lilleengen @@ -24,6 +23,6 @@ public class LZ4PayloadCompressorTest { byte[] data = Utf8.toBytes(input); byte[] compressed = compressor.compress(data); byte[] output = compressor.decompress(compressed, data.length); - assertThat(data, is(output)); + assertArrayEquals(output, data); } } diff --git a/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java b/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java index 12c1d2f8069..7d49d15dc47 100644 --- a/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java @@ -16,11 +16,11 @@ import static com.yahoo.vespa.config.PayloadChecksum.Type.MD5; import static com.yahoo.vespa.config.PayloadChecksum.Type.XXHASH64; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; /** * @author hmusum diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java index dabd87e1eec..8d160076db9 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java @@ -28,10 +28,10 @@ import java.util.Optional; import static com.yahoo.vespa.config.PayloadChecksum.Type.MD5; import static com.yahoo.vespa.config.PayloadChecksum.Type.XXHASH64; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java index 8d895d0e2b8..af6aefb26e1 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java @@ -10,8 +10,7 @@ import org.junit.Test; import java.nio.charset.StandardCharsets; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; /** * @author Ulf Lilleengen @@ -23,13 +22,13 @@ public class PayloadTest { String json = "{\"foo\":13}"; ConfigPayload configPayload = ConfigPayload.fromString(json); Payload payload = Payload.from(configPayload); - assertThat(payload.getData().toString(), is(json)); + assertEquals(json, payload.getData().toString()); payload = Payload.from(payload.getData(), CompressionInfo.create(CompressionType.UNCOMPRESSED, 0)); Payload compressed = payload.withCompression(CompressionType.LZ4); Payload uncompressed = compressed.withCompression(CompressionType.UNCOMPRESSED); - assertThat(uncompressed.getData().toString(), is(json)); - assertThat(compressed.toString(), is(json)); - assertThat(uncompressed.toString(), is(json)); + assertEquals(json, uncompressed.getData().toString()); + assertEquals(json, compressed.toString()); + assertEquals(json, uncompressed.toString()); } @Test @@ -52,10 +51,7 @@ public class PayloadTest { slime.setString("foo 2"); Payload f = Payload.from(new ConfigPayload(slime)); - Payload g = null; - Payload h = null; - Payload i = null; - Payload j = null; + Payload g, h, i, j; g = Payload.from(new Utf8Array(foo1.getBytes(StandardCharsets.UTF_8)), CompressionInfo.uncompressed()); h = Payload.from(new Utf8Array(foo1.getBytes(StandardCharsets.UTF_8)), CompressionInfo.uncompressed()); diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java index 3525809a447..8b1de561a1e 100644 --- a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java @@ -15,8 +15,8 @@ import java.util.Iterator; import java.util.Map; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** -- cgit v1.2.3