aboutsummaryrefslogtreecommitdiffstats
path: root/application/src/test/java/com/yahoo/application/container
diff options
context:
space:
mode:
Diffstat (limited to 'application/src/test/java/com/yahoo/application/container')
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java80
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java23
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java62
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java48
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java24
-rw-r--r--application/src/test/java/com/yahoo/application/container/ContainerTest.java35
-rw-r--r--application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java77
-rw-r--r--application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java10
8 files changed, 196 insertions, 163 deletions
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java b/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
index 7c786d35fab..7dad204a8ce 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerDocprocTest.java
@@ -13,12 +13,13 @@ import com.yahoo.document.Document;
import com.yahoo.document.DocumentPut;
import com.yahoo.document.DocumentType;
import com.yahoo.processing.execution.chain.ChainRegistry;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -47,16 +48,16 @@ public class ContainerDocprocTest {
return xml;
}
- @Before
+ @BeforeEach
public void resetContainer() {
Container.resetInstance();
}
@Test
- public void requireThatBasicDocumentProcessingWorks() throws Exception {
+ void requireThatBasicDocumentProcessingWorks() throws Exception {
try (Application app = new ApplicationBuilder()
- .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
- .documentType("music", DOCUMENT).build()) {
+ .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
+ .documentType("music", DOCUMENT).build()) {
JDisc container = app.getJDisc("container");
DocumentProcessing docProc = container.documentProcessing();
@@ -84,11 +85,11 @@ public class ContainerDocprocTest {
}
@Test
- public void requireThatLaterDocumentProcessingWorks() throws Exception {
+ void requireThatLaterDocumentProcessingWorks() throws Exception {
try (Application app = new ApplicationBuilder()
- .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
- .networking(Networking.disable)
- .documentType("music", DOCUMENT).build()) {
+ .servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName()))
+ .networking(Networking.disable)
+ .documentType("music", DOCUMENT).build()) {
JDisc container = app.getJDisc("container");
DocumentProcessing docProc = container.documentProcessing();
DocumentType type = docProc.getDocumentTypes().get("music");
@@ -118,35 +119,44 @@ public class ContainerDocprocTest {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void requireThatUnknownChainThrows() {
- try (JDisc container = JDisc.fromServicesXml(
- getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
- Networking.disable)) {
- container.documentProcessing().process(ComponentSpecification.fromString("unknown"),
- new com.yahoo.docproc.Processing());
- }
+ @Test
+ void requireThatUnknownChainThrows() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml(
+ getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
+ Networking.disable)) {
+ container.documentProcessing().process(ComponentSpecification.fromString("unknown"),
+ new com.yahoo.docproc.Processing());
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatProcessingFails() {
- try (JDisc container = JDisc.fromServicesXml(
- getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
- Networking.disable)) {
- container.processing();
- }
+ @Test
+ void requireThatProcessingFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml(
+ getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
+ Networking.disable)) {
+ container.processing();
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatSearchFails() {
- try (JDisc container = JDisc.fromServicesXml(
- getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
- Networking.disable)) {
- container.search();
- }
+ @Test
+ void requireThatSearchFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml(
+ getXML("foo", Rot13DocumentProcessor.class.getCanonicalName()),
+ Networking.disable)) {
+ container.search();
+ }
+
+ });
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java b/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java
index f76008b4e02..656660f7580 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerModelEvaluationTest.java
@@ -9,16 +9,16 @@ import com.yahoo.application.container.handler.Response;
import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.test.json.JsonTestHelper;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.io.File;
import java.net.URLEncoder;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.StandardCharsets;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
/**
* Verify that we can create a JDisc (and hence Application) instance capable of doing model evaluation
@@ -27,22 +27,23 @@ import static org.junit.Assume.assumeTrue;
*/
public class ContainerModelEvaluationTest {
+ // This should ideally work but may not be worth the effort
@Test
- @Ignore // This should ideally work but may not be worth the effort
- public void testCreateJDiscInstanceWithModelEvaluation() {
+ @Disabled
+ void testCreateJDiscInstanceWithModelEvaluation() {
try (JDisc jdisc =
- JDisc.fromPath(new File("src/test/app-packages/model-evaluation").toPath(),
- Networking.disable)) {
+ JDisc.fromPath(new File("src/test/app-packages/model-evaluation").toPath(),
+ Networking.disable)) {
assertLoadedModels(jdisc);
}
}
@Test
- public void testCreateApplicationInstanceWithModelEvaluation() {
+ void testCreateApplicationInstanceWithModelEvaluation() {
assumeTrue(OnnxEvaluator.isRuntimeAvailable());
try (Application application =
- Application.fromApplicationPackage(new File("src/test/app-packages/model-evaluation"),
- Networking.disable)) {
+ Application.fromApplicationPackage(new File("src/test/app-packages/model-evaluation"),
+ Networking.disable)) {
assertLoadedModels(application.getJDisc("default"));
}
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
index e5019d6b54f..b10d62e72e0 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerProcessingTest.java
@@ -7,13 +7,14 @@ import com.yahoo.component.ComponentSpecification;
import com.yahoo.container.Container;
import com.yahoo.processing.Request;
import com.yahoo.processing.Response;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -36,13 +37,13 @@ public class ContainerProcessingTest {
return xml;
}
- @Before
+ @BeforeEach
public void resetContainer() {
Container.resetInstance();
}
@Test
- public void requireThatBasicProcessingWorks() {
+ void requireThatBasicProcessingWorks() {
try (JDisc container = getContainerWithRot13()) {
Processing processing = container.processing();
@@ -55,10 +56,10 @@ public class ContainerProcessingTest {
}
@Test
- public void requireThatBasicProcessingDoesNotTruncateBigResponse() {
- int SIZE = 50*1000;
+ void requireThatBasicProcessingDoesNotTruncateBigResponse() {
+ int SIZE = 50 * 1000;
StringBuilder foo = new StringBuilder();
- for (int j = 0 ; j < SIZE ; j++) {
+ for (int j = 0; j < SIZE; j++) {
foo.append('b');
}
@@ -69,13 +70,13 @@ public class ContainerProcessingTest {
container.handleRequest(
new com.yahoo.application.container.handler.Request("http://foo/processing/?chain=foo&title=" + foo.toString()));
- assertEquals(SIZE+26, response.getBody().length);
+ assertEquals(SIZE + 26, response.getBody().length);
}
}
}
@Test
- public void processing_and_rendering_works() throws Exception {
+ void processing_and_rendering_works() throws Exception {
try (JDisc container = getContainerWithRot13()) {
Processing processing = container.processing();
@@ -90,27 +91,36 @@ public class ContainerProcessingTest {
}
}
- @Test(expected = IllegalArgumentException.class)
- public void requireThatUnknownChainThrows() {
- try (JDisc container = getContainerWithRot13()) {
- container.processing().process(ComponentSpecification.fromString("unknown"), new Request());
- }
+ @Test
+ void requireThatUnknownChainThrows() {
+ assertThrows(IllegalArgumentException.class, () -> {
+ try (JDisc container = getContainerWithRot13()) {
+ container.processing().process(ComponentSpecification.fromString("unknown"), new Request());
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatDocprocFails() {
- try (JDisc container = getContainerWithRot13()) {
- container.documentProcessing();
- }
+ @Test
+ void requireThatDocprocFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = getContainerWithRot13()) {
+ container.documentProcessing();
+ }
+
+ });
}
- @Test(expected = UnsupportedOperationException.class)
- public void requireThatSearchFails() {
- try (JDisc container = getContainerWithRot13()) {
- container.search();
- }
+ @Test
+ void requireThatSearchFails() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = getContainerWithRot13()) {
+ container.search();
+ }
+
+ });
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java b/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
index 911d57a7d6e..24cae99b5ab 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerRequestTest.java
@@ -11,12 +11,13 @@ import com.yahoo.application.container.handlers.HeaderEchoRequestHandler;
import com.yahoo.application.container.handlers.ThrowingInWriteRequestHandler;
import com.yahoo.application.container.handlers.WriteException;
import com.yahoo.text.Utf8;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.charset.CharacterCodingException;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Einar M R Rosenvinge
@@ -37,7 +38,7 @@ public class ContainerRequestTest {
}
@Test
- public void requireThatRequestBodyWorks() throws CharacterCodingException {
+ void requireThatRequestBodyWorks() throws CharacterCodingException {
String DATA = "we have no bananas today";
Request req = new Request("http://banana/echo", DATA.getBytes(Utf8.getCharset()));
@@ -50,7 +51,7 @@ public class ContainerRequestTest {
}
@Test
- public void requireThatCustomRequestHeadersWork() {
+ void requireThatCustomRequestHeadersWork() {
Request req = new Request("http://banana/echo");
req.getHeaders().add("X-Foo", "Bar");
@@ -62,26 +63,31 @@ public class ContainerRequestTest {
}
}
- @Test(expected = WriteException.class)
- public void requireThatRequestHandlerThatThrowsInWriteWorks() {
- String DATA = "we have no bananas today";
- Request req = new Request("http://banana/throwwrite", DATA.getBytes(Utf8.getCharset()));
+ @Test
+ void requireThatRequestHandlerThatThrowsInWriteWorks() {
+ assertThrows(WriteException.class, () -> {
+ String DATA = "we have no bananas today";
+ Request req = new Request("http://banana/throwwrite", DATA.getBytes(Utf8.getCharset()));
- try (JDisc container = JDisc.fromServicesXml(getXML(ThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/throwwrite"), Networking.disable)) {
- Response response = container.handleRequest(req);
- req.toString();
- }
+ try (JDisc container = JDisc.fromServicesXml(getXML(ThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/throwwrite"), Networking.disable)) {
+ Response response = container.handleRequest(req);
+ req.toString();
+ }
+ });
}
- @Test(expected = DelayedWriteException.class)
- public void requireThatRequestHandlerThatThrowsDelayedInWriteWorks() {
- String DATA = "we have no bananas today";
- Request req = new Request("http://banana/delayedthrowwrite", DATA.getBytes(Utf8.getCharset()));
+ @Test
+ void requireThatRequestHandlerThatThrowsDelayedInWriteWorks() {
+ assertThrows(DelayedWriteException.class, () -> {
+ String DATA = "we have no bananas today";
+ Request req = new Request("http://banana/delayedthrowwrite", DATA.getBytes(Utf8.getCharset()));
- try (JDisc container = JDisc.fromServicesXml(getXML(DelayedThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/delayedthrowwrite"), Networking.disable)) {
- Response response = container.handleRequest(req);
- req.toString();
- }
+ try (JDisc container = JDisc.fromServicesXml(getXML(DelayedThrowingInWriteRequestHandler.class.getCanonicalName(), "http://*/delayedthrowwrite"), Networking.disable)) {
+ Response response = container.handleRequest(req);
+ req.toString();
+ }
+
+ });
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java b/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
index e1e520bccc9..465bdef87a3 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerSchemaTest.java
@@ -6,12 +6,13 @@ import com.yahoo.application.container.searchers.AddHitSearcher;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
-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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author gjoranv
@@ -20,7 +21,7 @@ import static org.junit.Assert.assertTrue;
public class ContainerSchemaTest {
@Test
- public void processing_and_rendering_works() throws Exception {
+ void processing_and_rendering_works() throws Exception {
final String searcherId = AddHitSearcher.class.getName();
try (JDisc container = containerWithSearch(searcherId)) {
@@ -32,7 +33,7 @@ public class ContainerSchemaTest {
}
@Test
- public void searching_works() {
+ void searching_works() {
final String searcherId = AddHitSearcher.class.getName();
try (JDisc container = containerWithSearch(searcherId)) {
@@ -54,11 +55,14 @@ public class ContainerSchemaTest {
"</container>", Networking.disable);
}
- @Test(expected = UnsupportedOperationException.class)
- public void retrieving_search_from_container_without_search_is_illegal() {
- try (JDisc container = JDisc.fromServicesXml("<container version=\"1.0\" />", Networking.disable)) {
- container.search(); // throws
- }
+ @Test
+ void retrieving_search_from_container_without_search_is_illegal() {
+ assertThrows(UnsupportedOperationException.class, () -> {
+ try (JDisc container = JDisc.fromServicesXml("<container version=\"1.0\" />", Networking.disable)) {
+ container.search(); // throws
+ }
+
+ });
}
}
diff --git a/application/src/test/java/com/yahoo/application/container/ContainerTest.java b/application/src/test/java/com/yahoo/application/container/ContainerTest.java
index fda8e0c597a..31e0b71d186 100644
--- a/application/src/test/java/com/yahoo/application/container/ContainerTest.java
+++ b/application/src/test/java/com/yahoo/application/container/ContainerTest.java
@@ -10,17 +10,17 @@ import com.yahoo.application.container.handlers.TestHandler;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import java.nio.charset.CharacterCodingException;
import java.nio.file.FileSystems;
import static com.yahoo.application.container.JDisc.fromServicesXml;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Tony Vaagenes
@@ -30,7 +30,7 @@ import static org.junit.Assert.fail;
public class ContainerTest {
@Test
- public void container_can_be_used_as_top_level_element() {
+ void container_can_be_used_as_top_level_element() {
try (JDisc container = fromServicesXml("<container version=\"1.0\">" + //
"<search />" + //
"</container>", Networking.disable)) {
@@ -39,7 +39,7 @@ public class ContainerTest {
}
@Test
- public void container_id_can_be_set() {
+ void container_id_can_be_set() {
try (JDisc container = fromServicesXml("<container version=\"1.0\" id=\"my-service-id\">" + //
"<search />" + //
"</container>", Networking.disable)) {
@@ -48,7 +48,7 @@ public class ContainerTest {
}
@Test
- public void container_can_be_embedded_in_services_tag() {
+ void container_can_be_embedded_in_services_tag() {
try (JDisc container = fromServicesXml("<services>" + //
"<container version=\"1.0\" id=\"my-service-id\">" + //
"<search />" + //
@@ -58,9 +58,10 @@ public class ContainerTest {
}
}
+ // container is unused inside the try block
@Test
- @SuppressWarnings("try") // container is unused inside the try block
- public void multiple_container_elements_gives_exception() {
+ @SuppressWarnings("try")
+ void multiple_container_elements_gives_exception() {
try (JDisc container = fromServicesXml("<services>" + //
"<container version=\"1.0\" id=\"id1\" />" + //
"<container version=\"1.0\" />" + //
@@ -72,7 +73,7 @@ public class ContainerTest {
}
@Test
- public void handleRequest_yields_response_from_correct_request_handler() {
+ void handleRequest_yields_response_from_correct_request_handler() {
final String handlerClass = TestHandler.class.getName();
try (JDisc container = fromServicesXml("<container version=\"1.0\">" + //
"<handler id=\"test-handler\" class=\"" + handlerClass + "\">" + //
@@ -89,7 +90,7 @@ public class ContainerTest {
}
@Test
- public void load_searcher_from_bundle() {
+ void load_searcher_from_bundle() {
try (JDisc container = JDisc.fromPath(FileSystems.getDefault().getPath("src/test/app-packages/searcher-app"),
Networking.disable)) {
Result result = container.search().process(ComponentSpecification.fromString("default"),
@@ -99,7 +100,7 @@ public class ContainerTest {
}
@Test
- public void document_types_can_be_accessed() throws Exception {
+ void document_types_can_be_accessed() throws Exception {
try (Application application = new ApplicationBuilder().documentType("example", EXAMPLE_DOCUMENT)
.servicesXml(CONTAINER_WITH_DOCUMENT_PROCESSING).build()) {
JDisc container = application.getJDisc("container");
@@ -109,7 +110,7 @@ public class ContainerTest {
}
@Test
- public void annotation_types_can_be_accessed() throws Exception {
+ void annotation_types_can_be_accessed() throws Exception {
try (Application application = new ApplicationBuilder().documentType("example", "search example {\n" + //
" " + EXAMPLE_DOCUMENT + "\n" + //
" annotation exampleAnnotation {}\n" + //
@@ -121,9 +122,9 @@ public class ContainerTest {
}
}
- @Ignore // Enable this when static state has been removed.
+ @Disabled // Enable this when static state has been removed.
@Test
- public void multiple_containers_can_be_run_in_parallel() throws Exception {
+ void multiple_containers_can_be_run_in_parallel() throws Exception {
try (JDisc jdisc1 = jdiscWithHttp(); JDisc jdisc2 = jdiscWithHttp()) {
sendRequest(jdisc1);
sendRequest(jdisc2);
diff --git a/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java b/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java
index d88d69f247e..19d5176c108 100644
--- a/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java
+++ b/application/src/test/java/com/yahoo/application/container/handler/HeadersTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.container.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
import java.util.Collection;
@@ -12,12 +12,13 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-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.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
@@ -27,7 +28,7 @@ import static org.junit.Assert.fail;
public class HeadersTestCase {
@Test
- public void requireThatSizeWorksAsExpected() {
+ void requireThatSizeWorksAsExpected() {
Headers headers = new Headers();
assertEquals(0, headers.size());
headers.add("foo", "bar");
@@ -43,7 +44,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatIsEmptyWorksAsExpected() {
+ void requireThatIsEmptyWorksAsExpected() {
Headers headers = new Headers();
assertTrue(headers.isEmpty());
headers.add("foo", "bar");
@@ -53,7 +54,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsKeyWorksAsExpected() {
+ void requireThatContainsKeyWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.containsKey("foo"));
assertFalse(headers.containsKey("FOO"));
@@ -63,7 +64,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsValueWorksAsExpected() {
+ void requireThatContainsValueWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.containsValue(Arrays.asList("bar")));
headers.add("foo", "bar");
@@ -71,7 +72,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsWorksAsExpected() {
+ void requireThatContainsWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.contains("foo", "bar"));
assertFalse(headers.contains("FOO", "bar"));
@@ -85,7 +86,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatContainsIgnoreCaseWorksAsExpected() {
+ void requireThatContainsIgnoreCaseWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.containsIgnoreCase("foo", "bar"));
assertFalse(headers.containsIgnoreCase("FOO", "bar"));
@@ -99,7 +100,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatAddStringWorksAsExpected() {
+ void requireThatAddStringWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.add("foo", "bar");
@@ -109,7 +110,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatAddListWorksAsExpected() {
+ void requireThatAddListWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.add("foo", Arrays.asList("bar"));
@@ -119,7 +120,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatAddAllWorksAsExpected() {
+ void requireThatAddAllWorksAsExpected() {
Headers headers = new Headers();
headers.add("foo", "bar");
headers.add("bar", "baz");
@@ -136,7 +137,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatPutStringWorksAsExpected() {
+ void requireThatPutStringWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.put("foo", "bar");
@@ -146,7 +147,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatPutListWorksAsExpected() {
+ void requireThatPutListWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.put("foo", Arrays.asList("bar"));
@@ -156,7 +157,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatPutAllWorksAsExpected() {
+ void requireThatPutAllWorksAsExpected() {
Headers headers = new Headers();
headers.add("foo", "bar");
headers.add("bar", "baz");
@@ -173,7 +174,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatRemoveWorksAsExpected() {
+ void requireThatRemoveWorksAsExpected() {
Headers headers = new Headers();
headers.put("foo", Arrays.asList("bar", "baz"));
assertEquals(Arrays.asList("bar", "baz"), headers.get("foo"));
@@ -183,7 +184,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatRemoveStringWorksAsExpected() {
+ void requireThatRemoveStringWorksAsExpected() {
Headers headers = new Headers();
headers.put("foo", Arrays.asList("bar", "baz"));
assertEquals(Arrays.asList("bar", "baz"), headers.get("foo"));
@@ -196,7 +197,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatClearWorksAsExpected() {
+ void requireThatClearWorksAsExpected() {
Headers headers = new Headers();
headers.add("foo", "bar");
headers.add("bar", "baz");
@@ -208,7 +209,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatGetWorksAsExpected() {
+ void requireThatGetWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.get("foo"));
headers.add("foo", "bar");
@@ -216,7 +217,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatGetFirstWorksAsExpected() {
+ void requireThatGetFirstWorksAsExpected() {
Headers headers = new Headers();
assertNull(headers.getFirst("foo"));
headers.add("foo", Arrays.asList("bar", "baz"));
@@ -224,7 +225,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatIsTrueWorksAsExpected() {
+ void requireThatIsTrueWorksAsExpected() {
Headers headers = new Headers();
assertFalse(headers.isTrue("foo"));
headers.put("foo", Arrays.asList("true"));
@@ -242,7 +243,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatKeySetWorksAsExpected() {
+ void requireThatKeySetWorksAsExpected() {
Headers headers = new Headers();
assertEquals(Collections.<Set<String>>emptySet(), headers.keySet());
headers.add("foo", "bar");
@@ -252,7 +253,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatValuesWorksAsExpected() {
+ void requireThatValuesWorksAsExpected() {
Headers headers = new Headers();
assertTrue(headers.values().isEmpty());
headers.add("foo", "bar");
@@ -268,7 +269,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntrySetWorksAsExpected() {
+ void requireThatEntrySetWorksAsExpected() {
Headers headers = new Headers();
assertEquals(Collections.emptySet(), headers.entrySet());
headers.put("foo", Arrays.asList("bar", "baz"));
@@ -282,7 +283,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntriesWorksAsExpected() {
+ void requireThatEntriesWorksAsExpected() {
Headers headers = new Headers();
assertEquals(Collections.emptyList(), headers.entries());
headers.put("foo", Arrays.asList("bar", "baz"));
@@ -301,7 +302,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntryIsUnmodifiable() {
+ void requireThatEntryIsUnmodifiable() {
Headers headers = new Headers();
headers.put("foo", "bar");
Map.Entry<String, String> entry = headers.entries().get(0);
@@ -314,7 +315,7 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEntriesAreUnmodifiable() {
+ void requireThatEntriesAreUnmodifiable() {
Headers headers = new Headers();
headers.put("foo", "bar");
List<Map.Entry<String, String>> entries = headers.entries();
@@ -333,25 +334,25 @@ public class HeadersTestCase {
}
@Test
- public void requireThatEqualsWorksAsExpected() {
+ void requireThatEqualsWorksAsExpected() {
Headers lhs = new Headers();
Headers rhs = new Headers();
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
lhs.add("foo", "bar");
- assertFalse(lhs.equals(rhs));
+ assertNotEquals(lhs, rhs);
rhs.add("foo", "bar");
- assertTrue(lhs.equals(rhs));
+ assertEquals(lhs, rhs);
}
@Test
- public void requireThatHashCodeWorksAsExpected() {
+ void requireThatHashCodeWorksAsExpected() {
Headers lhs = new Headers();
Headers rhs = new Headers();
- assertTrue(lhs.hashCode() == rhs.hashCode());
+ assertEquals(lhs.hashCode(), rhs.hashCode());
lhs.add("foo", "bar");
assertTrue(lhs.hashCode() != rhs.hashCode());
rhs.add("foo", "bar");
- assertTrue(lhs.hashCode() == rhs.hashCode());
+ assertEquals(lhs.hashCode(), rhs.hashCode());
}
private static class MyEntry implements Map.Entry<String, String> {
diff --git a/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java b/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
index edd2acb630d..b0971c141d6 100644
--- a/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.java
+++ b/application/src/test/java/com/yahoo/application/container/handler/ResponseTestCase.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.application.container.handler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* @author Einar M R Rosenvinge
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertNotNull;
public class ResponseTestCase {
@Test
- public void requireThatCharsetParsingWorks() {
+ void requireThatCharsetParsingWorks() {
assertEquals("utf-8", Response.charset("text/foobar").toString().toLowerCase());
assertEquals("utf-8", Response.charset("adsf").toString().toLowerCase());
assertEquals("utf-8", Response.charset("").toString().toLowerCase());
@@ -26,7 +26,7 @@ public class ResponseTestCase {
}
@Test
- public void testDefaultResponseBody() {
+ void testDefaultResponseBody() {
Response res1 = new Response();
Response res2 = new Response(new byte[0]);