diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-03-02 15:34:39 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-03-02 15:34:39 +0100 |
commit | 3844b4dbcc5e03489e82924ac2e1707897f9e43e (patch) | |
tree | fa450261161697fc44cd89b68ef97ed1afa5e575 /config | |
parent | 8ec5743e254b039fe860339fdc4b5ab4aa1f0364 (diff) |
Remove junit.fdramework usage
Diffstat (limited to 'config')
6 files changed, 51 insertions, 66 deletions
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceTest.java index 2706cb16312..00f7d23bedf 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceTest.java @@ -9,15 +9,14 @@ import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; -import static junit.framework.TestCase.fail; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public class ConfigSourceTest { + @Test(expected = IllegalArgumentException.class) public void require_that_FileSource_throws_exception_on_invalid_file() { new FileSource(new File("invalid")); @@ -39,7 +38,9 @@ public class ConfigSourceTest { ConfigGetter.getConfig(SimpletypesConfig.class, "dir:" + tmpDir, dirSource); fail(); } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("Could not find a config file for '" + SimpletypesConfig.getDefName() + "' in '" + folder + "/'")); + assertEquals("Could not find a config file for '" + SimpletypesConfig.getDefName() + "' in '" + folder + "/'", + e.getMessage()); } } + } diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java index 780a577a8dd..586ad7857f4 100644 --- a/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java @@ -15,19 +15,14 @@ import org.junit.Test; import java.util.Collections; import java.util.List; -import static junit.framework.TestCase.fail; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** - * @author hmusum, lulf - * @since 5.1 + * @author hmusum + * @author Ulf Lillengen */ public class ConfigSubscriptionTest { + @Test public void testEquals() { ConfigSubscriber sub = new ConfigSubscriber(); @@ -38,12 +33,12 @@ public class ConfigSubscriptionTest { sub, new RawSource(payload), new TimingValues()); ConfigSubscription<SimpletypesConfig> c = ConfigSubscription.get(new ConfigKey<>(SimpletypesConfig.class, "test2"), sub, new RawSource(payload), new TimingValues()); - assertThat(a, is(b)); - assertThat(a, is(a)); - assertThat(b, is(b)); - assertThat(c, is(c)); - assertThat(a, is(not(c))); - assertThat(b, is(not(c))); + assertEquals(b, a); + assertEquals(a, a); + assertEquals(b, b); + assertEquals(c, c); + assertNotEquals(c, a); + assertNotEquals(c, b); ConfigSubscriber subscriber = new ConfigSubscriber(); ConfigSet configSet = new ConfigSet(); @@ -73,12 +68,12 @@ public class ConfigSubscriptionTest { ConfigHandle<SimpletypesConfig> handle = sub.subscribe(SimpletypesConfig.class, "raw:boolval true", 10000); assertNotNull(handle); sub.nextConfig(); - assertThat(handle.getConfig().boolval(), is(true)); + assertTrue(handle.getConfig().boolval()); //assertTrue(sub.getSource() instanceof RawSource); } - // Test that subscription is closed and subscriptionHandles is empty if we get an exception (only the last is possible to - // test right now). + // Test that subscription is closed and subscriptionHandles is empty if we get an exception + // (only the last is possible to test right now). @Test @Ignore public void testSubscribeWithException() { @@ -88,7 +83,7 @@ public class ConfigSubscriptionTest { sub.subscribe(SimpletypesConfig.class, "configid", configSourceSet, new TimingValues().setSubscribeTimeout(100)); fail(); } catch (ConfigurationRuntimeException e) { - assertThat(sub.getSubscriptionHandles().size(), is(0)); + assertEquals(0, sub.getSubscriptionHandles().size()); } } @@ -97,4 +92,5 @@ public class ConfigSubscriptionTest { return subscriptionHandles; } } + } diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionKeyTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionKeyTest.java index 7014460d1a6..c4024a73c97 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionKeyTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionKeyTest.java @@ -3,11 +3,7 @@ package com.yahoo.vespa.config; import org.junit.Test; -import static junit.framework.TestCase.assertFalse; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - +import static org.junit.Assert.*; /** * Tests ConfigDefinitionKey @@ -21,8 +17,8 @@ public class ConfigDefinitionKeyTest { ConfigDefinitionKey def1 = new ConfigDefinitionKey("foo", "fuz"); ConfigDefinitionKey def2 = new ConfigDefinitionKey("foo", "bar"); - assertThat(def1.getName(), is("foo")); - assertThat(def1.getNamespace(), is("fuz")); + assertEquals("foo", def1.getName()); + assertEquals("fuz", def1.getNamespace()); assertTrue(def1.equals(def1)); assertFalse(def1.equals(def2)); @@ -35,8 +31,8 @@ public class ConfigDefinitionKeyTest { ConfigKey<?> key1 = new ConfigKey<>("foo", "id", "bar"); ConfigDefinitionKey def1 = new ConfigDefinitionKey(key1); - assertThat(def1.getName(), is(key1.getName())); - assertThat(def1.getNamespace(), is(key1.getNamespace())); + assertEquals(key1.getName(), def1.getName()); + assertEquals(key1.getNamespace(), def1.getNamespace()); } } diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionSetTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionSetTest.java index b8f08ac4233..30bf4c64275 100644 --- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionSetTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionSetTest.java @@ -3,17 +3,13 @@ package com.yahoo.vespa.config; import org.junit.Test; -import static junit.framework.TestCase.assertNull; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; /** * Class to hold config definitions and resolving requests for the correct definition * * @author hmusum - * @since 2011-11-18 */ public class ConfigDefinitionSetTest { @@ -29,10 +25,10 @@ public class ConfigDefinitionSetTest { configDefinitionSet.add(key2, def2); ConfigDefinitionKey key3 = new ConfigDefinitionKey(def3.getName(), def3.getNamespace()); configDefinitionSet.add(key3, def3); - assertThat(configDefinitionSet.size(), is(3)); - assertThat(configDefinitionSet.get(key1), is(def1)); - assertThat(configDefinitionSet.get(key2), is(def2)); - assertThat(configDefinitionSet.get(key3), is(def3)); + assertEquals(3, configDefinitionSet.size()); + assertEquals(def1, configDefinitionSet.get(key1)); + assertEquals(def2, configDefinitionSet.get(key2)); + assertEquals(def3, configDefinitionSet.get(key3)); String str = configDefinitionSet.toString(); assertTrue(str.contains("namespace1.foo")); @@ -50,8 +46,9 @@ public class ConfigDefinitionSetTest { configDefinitionSet.add(new ConfigDefinitionKey(def2.getName(), def2.getNamespace()), def2); // fallback to default namespace - assertThat(configDefinitionSet.get(new ConfigDefinitionKey("foo", "namespace")), is(def1)); + assertEquals(def1, configDefinitionSet.get(new ConfigDefinitionKey("foo", "namespace"))); // Should not fallback to some other config with same name, but different namespace (not default namespace) assertNull(configDefinitionSet.get(new ConfigDefinitionKey("bar", "someothernamespace"))); } + } 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 6021671cff5..0d0e0350a9e 100644 --- a/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java @@ -11,16 +11,13 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertNull; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.*; /** * @author hmusum - * @since 5.1.9 + */ public class RawConfigTest { @@ -35,19 +32,19 @@ public class RawConfigTest { public void basic() { RawConfig config = new RawConfig(key, defMd5); assertEquals(config.getKey(), key); - assertThat(config.getDefMd5(), is(defMd5)); - assertThat(config.getName(), is("foo")); - assertThat(config.getDefNamespace(), is("bar")); - assertThat(config.getConfigId(), is("id")); + assertEquals(defMd5, config.getDefMd5()); + assertEquals("foo", config.getName()); + assertEquals("bar", config.getDefNamespace()); + assertEquals("id", config.getConfigId()); - assertThat(config.isError(), is(false)); + assertFalse(config.isError()); // Copy constructor RawConfig copiedConfig = new RawConfig(config); - assertThat(copiedConfig, is(config)); + assertEquals(config, copiedConfig); - assertThat(config.toString(), is("bar.foo," + defMd5 + ",id,,0,null")); - assertThat(config.getVespaVersion(), is(Optional.empty())); + assertEquals("bar.foo," + defMd5 + ",id,,0,null", config.toString()); + assertEquals(Optional.empty(), config.getVespaVersion()); } @Test diff --git a/config/src/test/java/com/yahoo/vespa/config/buildergen/ConfigBuilderGeneratorTest.java b/config/src/test/java/com/yahoo/vespa/config/buildergen/ConfigBuilderGeneratorTest.java index 525921d3052..4501768822c 100644 --- a/config/src/test/java/com/yahoo/vespa/config/buildergen/ConfigBuilderGeneratorTest.java +++ b/config/src/test/java/com/yahoo/vespa/config/buildergen/ConfigBuilderGeneratorTest.java @@ -11,22 +11,19 @@ import com.yahoo.vespa.config.ConfigPayloadApplier; import org.junit.Test; import java.io.File; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.net.URISyntaxException; import static com.yahoo.config.codegen.ConfiggenUtil.createClassName; -import static junit.framework.TestCase.assertNotNull; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; /** - * @author lulf - * @since 5.1 + * @author Ulf Lilleengen */ public class ConfigBuilderGeneratorTest { + @Test - public void require_that_custom_classes_can_be_generated() throws URISyntaxException, IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { + public void require_that_custom_classes_can_be_generated() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { String[] schema = new String[] { "namespace=foo.bar", "intval int", @@ -46,6 +43,7 @@ public class ConfigBuilderGeneratorTest { String className = createClassName(key.getName()); ConfigInstance instance = (ConfigInstance) builder.getClass().getClassLoader().loadClass("com.yahoo." + key.getNamespace() + "." + className).getConstructor(new Class<?>[]{builder.getClass()}).newInstance(builder); assertNotNull(instance); - assertThat(instance.toString(), is("intval 3\nstringval \"Hello, world\"")); + assertEquals("intval 3\nstringval \"Hello, world\"", instance.toString()); } + } |