diff options
Diffstat (limited to 'clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http')
4 files changed, 47 insertions, 49 deletions
diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java index 2583c3392c4..41328494f52 100644 --- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java +++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpRequestTest.java @@ -1,11 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.clustercontroller.utils.communication.http; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; public class HttpRequestTest { @@ -21,7 +19,7 @@ public class HttpRequestTest { } @Test - public void testEquality() { + void testEquality() { assertEquals(createRequest(), createRequest()); assertNotSame(createRequest(), createRequest().setHost("localhost")); assertNotSame(createRequest(), createRequest().setPort(40)); @@ -31,16 +29,16 @@ public class HttpRequestTest { } @Test - public void testVerifyComplete() { + void testVerifyComplete() { // To be a complete request, an HTTP request must include: // - A path // - The HTTP operation type - try{ + try { new HttpRequest().setPath("/foo").verifyComplete(); assertTrue(false); } catch (IllegalStateException e) { } - try{ + try { new HttpRequest().setHttpOperation(HttpRequest.HttpOp.GET).verifyComplete(); assertTrue(false); } catch (IllegalStateException e) { @@ -49,7 +47,7 @@ public class HttpRequestTest { } @Test - public void testMerge() { + void testMerge() { { HttpRequest base = new HttpRequest() .setHttpOperation(HttpRequest.HttpOp.POST) @@ -92,25 +90,25 @@ public class HttpRequestTest { } @Test - public void testNonExistingHeader() { + void testNonExistingHeader() { assertEquals("foo", new HttpRequest().getHeader("asd", "foo")); assertEquals("foo", new HttpRequest().addHttpHeader("bar", "foo").getHeader("asd", "foo")); } @Test - public void testOption() { + void testOption() { assertEquals("bar", new HttpRequest().addUrlOption("foo", "bar").getOption("foo", "foo")); assertEquals("foo", new HttpRequest().getOption("asd", "foo")); } @Test - public void testToString() { + void testToString() { assertEquals("GET? http://localhost:8080/", - new HttpRequest() - .setScheme("http") - .setHost("localhost") - .setPort(8080) - .toString(true)); + new HttpRequest() + .setScheme("http") + .setHost("localhost") + .setPort(8080) + .toString(true)); assertEquals("POST http://localhost/", new HttpRequest() .setScheme("http") @@ -127,7 +125,7 @@ public class HttpRequestTest { } @Test - public void testNothingButGetCoverage() { + void testNothingButGetCoverage() { assertEquals(false, new HttpRequest().equals(new Object())); new HttpRequest().getHeaders(); new HttpRequest().setUrlOptions(new HttpRequest().getUrlOptions()); diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java index 59fd4521efb..3a08d735a4e 100644 --- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.java +++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/HttpResultTest.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.clustercontroller.utils.communication.http; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class HttpResultTest { @Test - public void testSuccess() { + void testSuccess() { assertEquals(false, new HttpResult().setHttpCode(199, "foo").isSuccess()); assertEquals(true, new HttpResult().setHttpCode(200, "foo").isSuccess()); assertEquals(true, new HttpResult().setHttpCode(299, "foo").isSuccess()); @@ -16,7 +16,7 @@ public class HttpResultTest { } @Test - public void testToString() { + void testToString() { assertEquals("HTTP 200/OK", new HttpResult().setContent("Foo").toString()); assertEquals("HTTP 200/OK\n\nFoo", new HttpResult().setContent("Foo").toString(true)); assertEquals("HTTP 200/OK", new HttpResult().toString(true)); @@ -24,7 +24,7 @@ public class HttpResultTest { } @Test - public void testNothingButGetCoverage() { + void testNothingButGetCoverage() { new HttpResult().getHeaders(); } diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java index 2e8f9ea9b58..19fc27669af 100644 --- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java +++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/JsonHttpResultTest.java @@ -3,31 +3,31 @@ package com.yahoo.vespa.clustercontroller.utils.communication.http; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class JsonHttpResultTest { @Test - public void testCopyConstructor() { + void testCopyConstructor() { assertEquals("{}", new JsonHttpResult(new HttpResult()).getJson().toString()); } @Test - public void testOutput() { + void testOutput() { assertEquals("HTTP 200/OK\n" - + "\n" - + "JSON: {\"foo\": 3}", - new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : 3 }")).toString(true)); + + "\n" + + "JSON: {\"foo\": 3}", + new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : 3 }")).toString(true)); assertEquals("HTTP 200/OK\n" - + "\n" - + "{ \"foo\" : }", + + "\n" + + "{ \"foo\" : }", new JsonHttpResult(new HttpResult().setContent("{ \"foo\" : }")).toString(true)); } @Test - public void testNonJsonOutput() { + void testNonJsonOutput() { JsonHttpResult result = new JsonHttpResult(); result.setContent("Foo"); StringBuilder sb = new StringBuilder(); @@ -36,7 +36,7 @@ public class JsonHttpResultTest { } @Test - public void testInvalidJsonOutput() { + void testInvalidJsonOutput() { JsonHttpResult result = new JsonHttpResult(); result.setJson(new JSONObject() { @Override diff --git a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java index 2c9d9296aae..52b632c6eb8 100644 --- a/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.java +++ b/clustercontroller-utils/src/test/java/com/yahoo/vespa/clustercontroller/utils/communication/http/writer/HttpWriterTest.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.vespa.clustercontroller.utils.communication.http.writer; -import org.junit.Test; +import org.junit.jupiter.api.Test; -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; public class HttpWriterTest { @@ -19,34 +19,34 @@ public class HttpWriterTest { + "</html>\n"; @Test - public void testStructure() { + void testStructure() { HttpWriter writer = new HttpWriter(); String header = defaultHeader.replace(defaultTitle, "Untitled page"); assertEquals(header + defaultFooter, writer.toString()); } @Test - public void testTitle() { + void testTitle() { HttpWriter writer = new HttpWriter().addTitle(defaultTitle); assertEquals(defaultHeader + defaultFooter, writer.toString()); } @Test - public void testParagraph() { + void testParagraph() { String paragraph = "This is a paragraph"; String paragraph2 = "More text"; HttpWriter writer = new HttpWriter().addTitle(defaultTitle).write(paragraph).write(paragraph2); String content = " <p>\n" - + " " + paragraph + "\n" - + " </p>\n" - + " <p>\n" - + " " + paragraph2 + "\n" - + " </p>\n"; + + " " + paragraph + "\n" + + " </p>\n" + + " <p>\n" + + " " + paragraph2 + "\n" + + " </p>\n"; assertEquals(defaultHeader + content + defaultFooter, writer.toString()); } @Test - public void testLink() { + void testLink() { String name = "My link"; String link = "/foo/bar?hmm"; HttpWriter writer = new HttpWriter().addTitle(defaultTitle).writeLink(name, link); @@ -55,15 +55,15 @@ public class HttpWriterTest { } @Test - public void testErrors() { - try{ + void testErrors() { + try { HttpWriter writer = new HttpWriter().addTitle(defaultTitle); writer.toString(); writer.write("foo"); assertTrue(false); } catch (IllegalStateException e) { } - try{ + try { new HttpWriter().write("foo").addTitle("bar"); assertTrue(false); } catch (IllegalStateException e) { |