diff options
Diffstat (limited to 'config-lib/src/test')
13 files changed, 181 insertions, 137 deletions
diff --git a/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java b/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java index bfa2f747c1c..50d71ba50e9 100644 --- a/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/BooleanNodeTest.java @@ -1,10 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen @@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue; */ public class BooleanNodeTest { @Test - public void testSetValue() { + void testSetValue() { BooleanNode n = new BooleanNode(); assertTrue(n.doSetValue("true")); assertTrue(n.doSetValue("TRUE")); diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java index 613cfe1cced..f05baeff08c 100644 --- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java +++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceBuilderTest.java @@ -6,7 +6,7 @@ import com.yahoo.foo.StructtypesConfig; import com.yahoo.test.FunctionTestConfig; import com.yahoo.test.IntConfig; import com.yahoo.test.RestartConfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.lang.reflect.Field; @@ -26,11 +26,11 @@ import static com.yahoo.test.FunctionTestConfig.RootStruct; import static com.yahoo.test.FunctionTestConfig.MyStructMap; import static com.yahoo.foo.MaptypesConfig.Innermap; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author gjoranv @@ -40,7 +40,7 @@ public class ConfigInstanceBuilderTest { @Test - public void struct_values_can_be_set_without_declaring_a_new_struct_builder() { + void struct_values_can_be_set_without_declaring_a_new_struct_builder() { var builder = new StructtypesConfig.Builder(); builder.simple .name("myname") @@ -52,7 +52,7 @@ public class ConfigInstanceBuilderTest } @Test - public void leaf_map_setter_merges_maps() { + void leaf_map_setter_merges_maps() { MaptypesConfig.Builder builder = new MaptypesConfig.Builder() .intmap("one", 1); @@ -66,10 +66,10 @@ public class ConfigInstanceBuilderTest } @Test - public void inner_map_setter_merges_maps() { + void inner_map_setter_merges_maps() { MaptypesConfig.Builder builder = new MaptypesConfig.Builder() .innermap("one", new Innermap.Builder() - .foo(1)); + .foo(1)); Map<String, Innermap.Builder> newMap = new HashMap<>(); newMap.put("two", new Innermap.Builder().foo(2)); @@ -81,13 +81,13 @@ public class ConfigInstanceBuilderTest } @Test - public void testVariableAccessWithBuilder() { + void testVariableAccessWithBuilder() { FunctionTestConfig config = createVariableAccessConfigWithBuilder(); assertVariableAccessValues(config, ":parent:"); } @Test - public void require_that_unset_builder_fields_are_null() throws Exception { + void require_that_unset_builder_fields_are_null() throws Exception { FunctionTestConfig.Builder builder = new FunctionTestConfig.Builder(); assertNull(getMember(builder, "bool_val")); assertNull(getMember(builder, "bool_with_def")); @@ -111,7 +111,7 @@ public class ConfigInstanceBuilderTest } @Test - public void require_that_set_builder_fields_are_nonNull() throws Exception { + void require_that_set_builder_fields_are_nonNull() throws Exception { FunctionTestConfig.Builder builder = createVariableAccessBuilder(); assertNotNull(getMember(builder, "bool_val")); assertNotNull(getMember(builder, "bool_with_def")); @@ -129,13 +129,13 @@ public class ConfigInstanceBuilderTest assertNotNull(getMember(builder, "refwithdef")); assertNotNull(getMember(builder, "fileVal")); - BasicStruct.Builder basicStructBuilder = (BasicStruct.Builder)getMember(builder, "basicStruct"); + BasicStruct.Builder basicStructBuilder = (BasicStruct.Builder) getMember(builder, "basicStruct"); assertNotNull(getMember(basicStructBuilder, "foo")); assertNotNull(getMember(basicStructBuilder, "bar")); } @Test - public void require_that_config_can_be_recreated_from_another_configs_builder() { + void require_that_config_can_be_recreated_from_another_configs_builder() { FunctionTestConfig original = createVariableAccessConfigWithBuilder(); FunctionTestConfig copy = new FunctionTestConfig(new FunctionTestConfig.Builder(original)); assertVariableAccessValues(copy, ":parent:"); @@ -330,13 +330,13 @@ public class ConfigInstanceBuilderTest } @Test - public void require_that_config_class_reports_any_restart_values() throws Exception { + void require_that_config_class_reports_any_restart_values() throws Exception { assertTrue(callContainsFieldsFlaggedWithRestart(RestartConfig.class)); assertFalse(callContainsFieldsFlaggedWithRestart(IntConfig.class)); } @Test - public void require_that_config_class_can_make_change_report() throws Exception { + void require_that_config_class_can_make_change_report() throws Exception { IntConfig noRestart1 = new IntConfig(new IntConfig.Builder().intVal(42)); IntConfig noRestart2 = new IntConfig(new IntConfig.Builder().intVal(21)); ChangesRequiringRestart report = callGetChangesRequiringRestart(noRestart1, noRestart2); @@ -370,33 +370,33 @@ public class ConfigInstanceBuilderTest assertEquals("function-test", report.getName()); assertTrue( report.toString().startsWith( - "# An int value\n" + - "# Also test that multiline comments\n" + - "# work.\n" + - "function-test.int_val has changed from 5 to 100\n" + - "function-test.stringarr[0] has changed from \"bar\" to \"foo\"\n" + - "# This is a map of ints.\n" + - "function-test.intMap{one} has changed from 1 to 42\n" + - "# This is a map of ints.\n" + - "function-test.intMap{two} with value 2 was removed\n" + - "# This is a map of ints.\n" + - "function-test.intMap{three} was added with value 3\n" + - "# A basic struct\n" + - "function-test.basicStruct.foo has changed from \"basicFoo\" to \"basic\"\n" + - "function-test.basicStruct.bar has changed from 3 to 1234\n" + - "function-test.basicStruct.intArr[0] with value 310 was removed\n" + - "function-test.basicStruct.intArr[1] with value 311 was removed\n" + - "function-test.myarray[0].anotherarray[0].foo has changed from 7 to 32\n" + - "# This is my array\n" + - "function-test.myarray[1].intval has changed from 5 to 17\n" + - "function-test.myarray[2] was added with value \n" + "# An int value\n" + + "# Also test that multiline comments\n" + + "# work.\n" + + "function-test.int_val has changed from 5 to 100\n" + + "function-test.stringarr[0] has changed from \"bar\" to \"foo\"\n" + + "# This is a map of ints.\n" + + "function-test.intMap{one} has changed from 1 to 42\n" + + "# This is a map of ints.\n" + + "function-test.intMap{two} with value 2 was removed\n" + + "# This is a map of ints.\n" + + "function-test.intMap{three} was added with value 3\n" + + "# A basic struct\n" + + "function-test.basicStruct.foo has changed from \"basicFoo\" to \"basic\"\n" + + "function-test.basicStruct.bar has changed from 3 to 1234\n" + + "function-test.basicStruct.intArr[0] with value 310 was removed\n" + + "function-test.basicStruct.intArr[1] with value 311 was removed\n" + + "function-test.myarray[0].anotherarray[0].foo has changed from 7 to 32\n" + + "# This is my array\n" + + "function-test.myarray[1].intval has changed from 5 to 17\n" + + "function-test.myarray[2] was added with value \n" ) ); assertTrue( report.toString().contains( - "function-test.myStructMap{one}.myInt has changed from 1 to 42\n" + - "function-test.myStructMap{new} was added with value \n" + "function-test.myStructMap{one}.myInt has changed from 1 to 42\n" + + "function-test.myStructMap{new} was added with value \n" ) ); diff --git a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java index 536c18786da..1584293a137 100644 --- a/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java +++ b/config-lib/src/test/java/com/yahoo/config/ConfigInstanceEqualsTest.java @@ -3,8 +3,8 @@ package com.yahoo.config; import com.yahoo.test.AppConfig; import com.yahoo.test.FunctionTestConfig; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.Arrays; @@ -14,15 +14,15 @@ import static com.yahoo.test.FunctionTestConfig.Enum_val; import static com.yahoo.test.FunctionTestConfig.Enumarr; import static com.yahoo.test.FunctionTestConfig.Myarray; import static com.yahoo.test.FunctionTestConfig.RootStruct; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class ConfigInstanceEqualsTest { FunctionTestConfig config1; FunctionTestConfig.Builder builder2; FunctionTestConfig config2; - @Before + @BeforeEach public void reset() { config1 = new FunctionTestConfig(newBuilder()); builder2 = newBuilder(); @@ -30,28 +30,28 @@ public class ConfigInstanceEqualsTest { } @Test - public void require_same_hashCode_for_equal_instances() { + void require_same_hashCode_for_equal_instances() { assertEquals(config1.hashCode(), config2.hashCode()); } @Test - public void require_true_for_equal_instances() { + void require_true_for_equal_instances() { assertEquals(config1, config2); } @Test - public void require_false_for_null() { + void require_false_for_null() { assertNotEquals(null, config1); } @Test - public void require_false_for_different_subclass() { + void require_false_for_different_subclass() { assertNotEquals(config1, new AppConfig(new AppConfig.Builder())); } @Test - public void require_false_for_different_scalars_at_root_node() { + void require_false_for_different_scalars_at_root_node() { assertNotEquals(config1, new FunctionTestConfig(newBuilder().bool_val(true))); assertNotEquals(config1, new FunctionTestConfig(newBuilder().int_val(0))); assertNotEquals(config1, new FunctionTestConfig(newBuilder().long_val(0L))); @@ -63,50 +63,50 @@ public class ConfigInstanceEqualsTest { } @Test - public void require_false_for_different_leaf_array_at_root_node() { + void require_false_for_different_leaf_array_at_root_node() { builder2.longarr.set(0, 0L); assertNotEquals(config1, new FunctionTestConfig(builder2)); } @Test - public void require_false_for_different_scalar_in_struct() { + void require_false_for_different_scalar_in_struct() { builder2.basicStruct(new BasicStruct.Builder(config1.basicStruct()).bar(0)); assertNotEquals(config1, new FunctionTestConfig(builder2)); } @Test - public void require_false_for_different_scalar_in_inner_array() { + void require_false_for_different_scalar_in_inner_array() { builder2.myarray.get(0).intval(0); assertNotEquals(config1, new FunctionTestConfig(builder2)); } @Test - public void require_false_for_different_leaf_array_in_inner_array() { + void require_false_for_different_leaf_array_in_inner_array() { builder2.myarray.get(0).stringval.set(0, ""); assertNotEquals(config1, new FunctionTestConfig(builder2)); } @Test - public void require_equal_structs_for_equal_configs() { + void require_equal_structs_for_equal_configs() { assertEquals(config1.basicStruct(), config2.basicStruct()); assertEquals(config1.rootStruct(), config2.rootStruct()); assertEquals(config1.rootStruct().inner0(), config2.rootStruct().inner0()); } @Test - public void require_equal_inner_arrays_for_equal_configs() { + void require_equal_inner_arrays_for_equal_configs() { assertEquals(config1.myarray(), config2.myarray()); assertEquals(config1.myarray(0).anotherarray(), config2.myarray(0).anotherarray()); } @Test - public void require_equal_inner_array_elements_for_equal_configs() { + void require_equal_inner_array_elements_for_equal_configs() { assertEquals(config1.myarray(0), config2.myarray(0)); assertEquals(config1.myarray(0).anotherarray(0), config2.myarray(0).anotherarray(0)); } @Test - public void require_equal_leaf_arrays_for_equal_configs() { + void require_equal_leaf_arrays_for_equal_configs() { assertEquals(config1.intarr(), config2.intarr()); assertEquals(config1.boolarr(), config2.boolarr()); assertEquals(config1.longarr(), config2.longarr()); diff --git a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java index 1192cc6673e..475a33104b0 100644 --- a/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/DoubleNodeTest.java @@ -1,11 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue; */ public class DoubleNodeTest { @Test - public void testSetValue() { + void testSetValue() { DoubleNode n = new DoubleNode(); assertFalse(n.doSetValue("invalid")); assertTrue(n.doSetValue("3.14")); diff --git a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java index fac765f40aa..e7723409736 100644 --- a/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/EnumNodeTest.java @@ -1,12 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen @@ -30,7 +30,7 @@ public class EnumNodeTest { } @Test - public void testEnumNode() { + void testEnumNode() { MyNode n = new MyNode(); assertNull(n.getValue()); assertEquals("(null)", n.toString()); diff --git a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java index 42e4978091d..8bec9378f8f 100644 --- a/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/FileNodeTest.java @@ -1,11 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen @@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue; public class FileNodeTest { @Test - public void testSetValue() { + void testSetValue() { FileNode n = new FileNode(); assertEquals("(null)", n.toString()); assertTrue(n.doSetValue("foo.txt")); @@ -24,7 +24,7 @@ public class FileNodeTest { assertEquals("\"foo.txt\"", n.toString()); assertEquals("path may not start with '..', but got: foo/../../boo", - assertThrows(IllegalArgumentException.class, () -> new FileNode("foo/../../boo")).getMessage()); + assertThrows(IllegalArgumentException.class, () -> new FileNode("foo/../../boo")).getMessage()); } } diff --git a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java index 899e34edce4..a195a5f65fb 100644 --- a/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/IntegerNodeTest.java @@ -1,11 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen @@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue; */ public class IntegerNodeTest { @Test - public void testSetValue() { + void testSetValue() { IntegerNode n = new IntegerNode(); assertFalse(n.setValue("invalid")); assertTrue(n.setValue("10")); diff --git a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java index fc603ba65ac..dc6d59bbc46 100644 --- a/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/LongNodeTest.java @@ -1,11 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Ulf Lilleengen @@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue; */ public class LongNodeTest { @Test - public void testSetValue() { + void testSetValue() { LongNode n = new LongNode(); assertFalse(n.setValue("invalid")); assertTrue(n.setValue("10")); diff --git a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java index 9637ab25278..e6b3b4b6a71 100644 --- a/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java +++ b/config-lib/src/test/java/com/yahoo/config/NodeVectorTest.java @@ -1,13 +1,14 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Ulf Lilleengen @@ -15,38 +16,78 @@ import static org.junit.Assert.assertTrue; */ public class NodeVectorTest { - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_add_throws_exception() { new TestNodeVector("foo").add(barNode()); } + @Test + void require_that_add_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").add(barNode()); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_addindex_throws_exception() { new TestNodeVector("foo").add(0, barNode()); } + @Test + void require_that_addindex_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").add(0, barNode()); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_addAll_throws_exception() { new TestNodeVector("foo").addAll(Arrays.asList(barNode())); } + @Test + void require_that_addAll_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").addAll(Arrays.asList(barNode())); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_addAllindex_throws_exception() { new TestNodeVector("foo").addAll(0, Arrays.asList(barNode())); } + @Test + void require_that_addAllindex_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").addAll(0, Arrays.asList(barNode())); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_clear_throws_exception() { new TestNodeVector("foo").clear(); } + @Test + void require_that_clear_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").clear(); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_remove_index_throws_exception() { new TestNodeVector("foo").remove(0); } + @Test + void require_that_remove_index_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").remove(0); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_remove_object_throws_exception() { new TestNodeVector("foo").remove(null); } + @Test + void require_that_remove_object_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").remove(null); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_removeAll_throws_exception() { new TestNodeVector("foo").removeAll(null); } + @Test + void require_that_removeAll_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").removeAll(null); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_retainAll_throws_exception() { new TestNodeVector("foo").retainAll(null); } + @Test + void require_that_retainAll_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").retainAll(null); + }); + } - @Test(expected = NodeVector.ReadOnlyException.class) - public void require_that_set_throws_exception() { new TestNodeVector("foo").set(0, null); } + @Test + void require_that_set_throws_exception() { + assertThrows(NodeVector.ReadOnlyException.class, () -> { + new TestNodeVector("foo").set(0, null); + }); + } @Test - public void require_that_contains_works() { + void require_that_contains_works() { StringNode val = new StringNode("foo"); TestNodeVector v = new TestNodeVector(val.getValue()); assertTrue(v.contains(val)); @@ -56,7 +97,7 @@ public class NodeVectorTest { } @Test - public void require_that_indexOf_works() { + void require_that_indexOf_works() { StringNode val = new StringNode("foo"); TestNodeVector v = new TestNodeVector(val.getValue()); assertFalse(v.isEmpty()); @@ -67,7 +108,7 @@ public class NodeVectorTest { } @Test - public void require_that_iterators_work() { + void require_that_iterators_work() { String val = "foo"; TestNodeVector v = new TestNodeVector(val, val, val); assertTrue(v.listIterator().hasNext()); @@ -78,7 +119,7 @@ public class NodeVectorTest { } @Test - public void require_that_sublisting_works() { + void require_that_sublisting_works() { String val = "foo"; TestNodeVector v = new TestNodeVector(val, val, val); assertEquals(1, v.subList(0, 1).size()); diff --git a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java index 016c53b42e3..ad8f5e2e65f 100644 --- a/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/PathNodeTest.java @@ -1,12 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author gjoranv @@ -15,7 +15,7 @@ import static org.junit.Assert.assertThrows; public class PathNodeTest { @Test - public void testSetValue() { + void testSetValue() { PathNode n = new PathNode(); assertEquals("(null)", n.toString()); @@ -23,7 +23,7 @@ public class PathNodeTest { assertEquals(new File("foo.txt").toPath(), n.value()); assertEquals("path may not start with '..', but got: foo/../../boo", - assertThrows(IllegalArgumentException.class, () -> new PathNode(new FileReference("foo/../../boo"))).getMessage()); + assertThrows(IllegalArgumentException.class, () -> new PathNode(new FileReference("foo/../../boo"))).getMessage()); } } diff --git a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java index 5d606e12454..d0baf8d1837 100644 --- a/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/StringNodeTest.java @@ -1,9 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author hmusum @@ -12,7 +13,7 @@ import static org.junit.Assert.assertEquals; public class StringNodeTest { @Test - public void testUnescapeQuotedString() { + void testUnescapeQuotedString() { String a = "\"Hei\""; assertEquals("Hei", StringNode.unescapeQuotedString(a)); assertEquals("foo\"bar\"", StringNode.unescapeQuotedString("foo\"bar\"")); @@ -21,13 +22,15 @@ public class StringNodeTest { assertEquals("U", StringNode.unescapeQuotedString("\\x55")); } - @Test(expected = IllegalArgumentException.class) - public void testUnescapedQuotedStringExceptions() { - StringNode.unescapeQuotedString("foo\\"); + @Test + void testUnescapedQuotedStringExceptions() { + assertThrows(IllegalArgumentException.class, () -> { + StringNode.unescapeQuotedString("foo\\"); + }); } @Test - public void testToString() { + void testToString() { StringNode n = new StringNode(); assertEquals("(null)", n.toString()); n.setValue("foo"); @@ -35,7 +38,7 @@ public class StringNodeTest { } @Test - public void testSetValue() { + void testSetValue() { StringNode n = new StringNode(); n.setValue("\"foo\""); assertEquals("foo", n.getValue()); diff --git a/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java b/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java index abf04c34bb8..1f40cb58a71 100644 --- a/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java +++ b/config-lib/src/test/java/com/yahoo/config/UrlNodeTest.java @@ -1,9 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author lesters @@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals; public class UrlNodeTest { @Test - public void testSetValue() { + void testSetValue() { UrlNode url = new UrlNode(); assertEquals("(null)", url.toString()); diff --git a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java index 54e2271f7dc..39e5f64e5e2 100644 --- a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java +++ b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java @@ -4,9 +4,9 @@ package com.yahoo.config.codegen; import com.github.myproject.NamespaceAndPackageConfig; import com.github.myproject.PackageConfig; import com.yahoo.my.namespace.NamespaceConfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author gjoranv @@ -16,17 +16,17 @@ public class NamespaceAndPackageTest { private static String PACKAGE = "com.github.myproject"; @Test - public void namespace_is_set_from_def_file() { + void namespace_is_set_from_def_file() { assertEquals(NAMESPACE, NamespaceConfig.CONFIG_DEF_NAMESPACE); } @Test - public void package_is_used_as_namespace_when_namespace_is_not_set_explicitly() { + void package_is_used_as_namespace_when_namespace_is_not_set_explicitly() { assertEquals(PACKAGE, PackageConfig.CONFIG_DEF_NAMESPACE); } @Test - public void package_does_not_override_namespace() { + void package_does_not_override_namespace() { assertEquals(NAMESPACE, NamespaceAndPackageConfig.CONFIG_DEF_NAMESPACE); } |