aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/schema/RankingConstantTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/schema/RankingConstantTest.java')
-rw-r--r--config-model/src/test/java/com/yahoo/schema/RankingConstantTest.java82
1 files changed, 38 insertions, 44 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/RankingConstantTest.java b/config-model/src/test/java/com/yahoo/schema/RankingConstantTest.java
index 883e6b50abb..c963f086ac4 100644
--- a/config-model/src/test/java/com/yahoo/schema/RankingConstantTest.java
+++ b/config-model/src/test/java/com/yahoo/schema/RankingConstantTest.java
@@ -2,28 +2,20 @@
package com.yahoo.schema;
import com.yahoo.schema.parser.ParseException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.util.Iterator;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static com.yahoo.config.model.test.TestUtil.joinLines;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author gjoranv
*/
public class RankingConstantTest {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
- public void tensor_constant_properties_are_set() throws Exception {
+ void tensor_constant_properties_are_set() throws Exception {
final String TENSOR_NAME = "my_global_tensor";
final String TENSOR_FILE = "path/my-tensor-file.json";
final String TENSOR_TYPE = "tensor(x{})";
@@ -57,39 +49,41 @@ public class RankingConstantTest {
}
@Test
- public void tensor_constant_must_have_a_type() throws Exception {
- RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("must have a type");
- schemaBuilder.addSchema(joinLines(
- "schema test {",
- " document test { }",
- " constant foo {",
- " file: bar.baz",
- " }",
- "}"
- ));
+ void tensor_constant_must_have_a_type() throws Exception {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
+ ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
+ schemaBuilder.addSchema(joinLines(
+ "schema test {",
+ " document test { }",
+ " constant foo {",
+ " file: bar.baz",
+ " }",
+ "}"
+ ));
+ });
+ assertTrue(exception.getMessage().contains("must have a type"));
}
@Test
- public void tensor_constant_must_have_a_file() throws Exception {
- RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("must have a file");
- schemaBuilder.addSchema(joinLines(
- "schema test {",
- " document test { }",
- " constant foo {",
- " type: tensor(x[])",
- " }",
- "}"
- ));
+ void tensor_constant_must_have_a_file() throws Exception {
+ Throwable exception = assertThrows(IllegalArgumentException.class, () -> {
+ RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
+ ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
+ schemaBuilder.addSchema(joinLines(
+ "schema test {",
+ " document test { }",
+ " constant foo {",
+ " type: tensor(x[])",
+ " }",
+ "}"
+ ));
+ });
+ assertTrue(exception.getMessage().contains("must have a file"));
}
@Test
- public void constant_file_does_not_need_path_or_ending() throws Exception {
+ void constant_file_does_not_need_path_or_ending() throws Exception {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
schemaBuilder.addSchema(joinLines(
@@ -108,7 +102,7 @@ public class RankingConstantTest {
}
@Test
- public void constant_uri_is_allowed() throws Exception {
+ void constant_uri_is_allowed() throws Exception {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
schemaBuilder.addSchema(joinLines(
@@ -128,7 +122,7 @@ public class RankingConstantTest {
}
@Test
- public void constant_https_uri_is_allowed() throws Exception {
+ void constant_https_uri_is_allowed() throws Exception {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
schemaBuilder.addSchema(joinLines(
@@ -148,7 +142,7 @@ public class RankingConstantTest {
}
@Test
- public void constant_uri_with_port_is_allowed() throws Exception {
+ void constant_uri_with_port_is_allowed() throws Exception {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
schemaBuilder.addSchema(joinLines(
@@ -168,7 +162,7 @@ public class RankingConstantTest {
}
@Test
- public void constant_uri_no_dual_slashes_is_allowed() throws Exception {
+ void constant_uri_no_dual_slashes_is_allowed() throws Exception {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
schemaBuilder.addSchema(joinLines(
@@ -188,7 +182,7 @@ public class RankingConstantTest {
}
@Test
- public void constant_uri_only_supports_http_and_https() {
+ void constant_uri_only_supports_http_and_https() {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
ApplicationBuilder schemaBuilder = new ApplicationBuilder(rankProfileRegistry);
String expectedMessage = "Encountered \" <IDENTIFIER> \"ftp\"\" at line 5, column 10.\n\n" +
@@ -205,7 +199,7 @@ public class RankingConstantTest {
"}"
));
} catch (ParseException e) {
- if (! e.getMessage().startsWith(expectedMessage))
+ if (!e.getMessage().startsWith(expectedMessage))
fail("Expected exception with message starting with:\n'" + expectedMessage + "\nBut got:\n'" + e.getMessage());
}
}