aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/vespa/model/utils
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/vespa/model/utils')
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/utils/DurationTest.java10
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java35
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java24
3 files changed, 36 insertions, 33 deletions
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/utils/DurationTest.java b/config-model/src/test/java/com/yahoo/vespa/model/utils/DurationTest.java
index 533550b1d53..9e8174e858a 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/utils/DurationTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/utils/DurationTest.java
@@ -1,14 +1,14 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
public class DurationTest {
@Test
- public void testDurationUnits() {
+ void testDurationUnits() {
assertEquals(1000, new Duration("1").getMilliSeconds());
assertEquals(2.0, new Duration("2").getSeconds(), 0.0001);
assertEquals(1, new Duration("1ms").getMilliSeconds());
@@ -30,7 +30,7 @@ public class DurationTest {
}
@Test
- public void testParseError() {
+ void testParseError() {
assertException("bjarne");
assertException("");
assertException("1 foo");
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
index 96815646a88..c7358ff1d7e 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/utils/FileSenderTest.java
@@ -14,8 +14,8 @@ import com.yahoo.vespa.config.ConfigPayloadBuilder;
import com.yahoo.vespa.model.AbstractService;
import com.yahoo.vespa.model.PortAllocBridge;
import com.yahoo.vespa.model.SimpleConfigProducer;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -23,7 +23,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* @author Ulf Lilleengen
@@ -64,7 +65,7 @@ public class FileSenderTest {
return new FileSender(serviceList, fileRegistry, new BaseDeployLogger());
}
- @Before
+ @BeforeEach
public void setup() {
MockRoot root = new MockRoot();
producer = new SimpleConfigProducer<>(root, "test");
@@ -81,7 +82,7 @@ public class FileSenderTest {
}
@Test
- public void require_that_simple_file_fields_are_modified() {
+ void require_that_simple_file_fields_are_modified() {
def.addFileDef("fileVal");
def.addStringDef("stringVal");
builder.setField("fileVal", "foo.txt");
@@ -93,7 +94,7 @@ public class FileSenderTest {
}
@Test
- public void require_that_simple_path_fields_are_modified() {
+ void require_that_simple_path_fields_are_modified() {
def.addPathDef("fileVal");
def.addStringDef("stringVal");
builder.setField("fileVal", "foo.txt");
@@ -105,7 +106,7 @@ public class FileSenderTest {
}
@Test
- public void require_that_fields_in_inner_arrays_are_modified() {
+ void require_that_fields_in_inner_arrays_are_modified() {
def.innerArrayDef("inner").addFileDef("fileVal");
def.innerArrayDef("inner").addStringDef("stringVal");
ConfigPayloadBuilder inner = builder.getArray("inner").append();
@@ -118,7 +119,7 @@ public class FileSenderTest {
}
@Test
- public void require_that_arrays_are_modified() {
+ void require_that_arrays_are_modified() {
def.arrayDef("fileArray").setTypeSpec(new ConfigDefinition.TypeSpec("fileArray", "file", null, null, null, null));
def.arrayDef("pathArray").setTypeSpec(new ConfigDefinition.TypeSpec("pathArray", "path", null, null, null, null));
def.arrayDef("stringArray").setTypeSpec(new ConfigDefinition.TypeSpec("stringArray", "string", null, null, null, null));
@@ -137,7 +138,7 @@ public class FileSenderTest {
}
@Test
- public void require_that_structs_are_modified() {
+ void require_that_structs_are_modified() {
def.structDef("struct").addFileDef("fileVal");
def.structDef("struct").addStringDef("stringVal");
builder.getObject("struct").setField("fileVal", "foo.txt");
@@ -149,7 +150,7 @@ public class FileSenderTest {
}
@Test
- public void require_that_leaf_maps_are_modified() {
+ void require_that_leaf_maps_are_modified() {
def.leafMapDef("fileMap").setTypeSpec(new ConfigDefinition.TypeSpec("fileMap", "file", null, null, null, null));
def.leafMapDef("pathMap").setTypeSpec(new ConfigDefinition.TypeSpec("pathMap", "path", null, null, null, null));
def.leafMapDef("stringMap").setTypeSpec(new ConfigDefinition.TypeSpec("stringMap", "string", null, null, null, null));
@@ -168,7 +169,7 @@ public class FileSenderTest {
}
@Test
- public void require_that_fields_in_inner_maps_are_modified() {
+ void require_that_fields_in_inner_maps_are_modified() {
def.structMapDef("inner").addFileDef("fileVal");
def.structMapDef("inner").addStringDef("stringVal");
ConfigPayloadBuilder inner = builder.getMap("inner").put("foo");
@@ -180,11 +181,13 @@ public class FileSenderTest {
assertEquals("bar.txt", builder.getMap("inner").get("foo").getObject("stringVal").getValue());
}
- @Test(expected = IllegalArgumentException.class)
- public void require_that_null_files_are_not_sent() {
- def.addFileDef("fileVal");
- fileRegistry.pathToRef.put("foo.txt", new FileNode("fooshash").value());
- fileSender().sendUserConfiguredFiles(producer);
+ @Test
+ void require_that_null_files_are_not_sent() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ def.addFileDef("fileVal");
+ fileRegistry.pathToRef.put("foo.txt", new FileNode("fooshash").value());
+ fileSender().sendUserConfiguredFiles(producer);
+ });
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java b/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java
index fb1afb75e10..d8ea631ac96 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/utils/internal/ReflectionUtilTest.java
@@ -7,14 +7,12 @@ import com.yahoo.config.ChangesRequiringRestart;
import com.yahoo.config.ConfigInstance;
import com.yahoo.test.SimpletypesConfig;
import com.yahoo.vespa.config.ConfigKey;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Set;
import static com.yahoo.vespa.model.utils.internal.ReflectionUtil.getAllConfigsProduced;
-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.*;
/**
* @author Ulf Lilleengen
@@ -67,14 +65,14 @@ public class ReflectionUtilTest {
private static class NonRestartConfig extends ConfigInstance {}
@Test
- public void getAllConfigsProduced_includes_configs_produced_by_super_class() {
+ void getAllConfigsProduced_includes_configs_produced_by_super_class() {
Set<ConfigKey<?>> configs = getAllConfigsProduced(ConcreteProducer.class, "foo");
assertEquals(1, configs.size());
assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE)));
}
@Test
- public void getAllConfigsProduced_includes_configs_produced_by_implemented_interface() {
+ void getAllConfigsProduced_includes_configs_produced_by_implemented_interface() {
Set<ConfigKey<?>> configs = getAllConfigsProduced(InterfaceImplementingProducer.class, "foo");
assertEquals(2, configs.size());
assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE)));
@@ -82,27 +80,29 @@ public class ReflectionUtilTest {
}
@Test
- public void getAllConfigsProduced_includes_configs_directly_implemented_by_producer() {
+ void getAllConfigsProduced_includes_configs_directly_implemented_by_producer() {
Set<ConfigKey<?>> configs = getAllConfigsProduced(SimpleProducer.class, "foo");
assertEquals(1, configs.size());
assertTrue(configs.contains(new ConfigKey<>(SimpletypesConfig.CONFIG_DEF_NAME, "foo", SimpletypesConfig.CONFIG_DEF_NAMESPACE)));
}
@Test
- public void requireThatRestartMethodsAreDetectedProperly() {
+ void requireThatRestartMethodsAreDetectedProperly() {
assertFalse(ReflectionUtil.hasRestartMethods(NonRestartConfig.class));
assertTrue(ReflectionUtil.hasRestartMethods(RestartConfig.class));
}
@Test
- public void requireThatRestartMethodsAreProperlyInvoked() {
+ void requireThatRestartMethodsAreProperlyInvoked() {
assertTrue(ReflectionUtil.containsFieldsFlaggedWithRestart(RestartConfig.class));
assertEquals("testing", ReflectionUtil.getChangesRequiringRestart(new RestartConfig(), new RestartConfig()).getName());
}
- @Test(expected = IllegalArgumentException.class)
- public void requireThatGetChangesRequiringRestartValidatesParameterTypes() {
- ReflectionUtil.getChangesRequiringRestart(new RestartConfig(), new NonRestartConfig());
+ @Test
+ void requireThatGetChangesRequiringRestartValidatesParameterTypes() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ ReflectionUtil.getChangesRequiringRestart(new RestartConfig(), new NonRestartConfig());
+ });
}