diff options
Diffstat (limited to 'jdisc_core')
93 files changed, 1046 insertions, 1016 deletions
diff --git a/jdisc_core/pom.xml b/jdisc_core/pom.xml index 0ed5e17b2ba..0e261f9dbef 100644 --- a/jdisc_core/pom.xml +++ b/jdisc_core/pom.xml @@ -51,6 +51,30 @@ <artifactId>testutil</artifactId> <version>${project.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + </exclusion> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> </dependency> <dependency> <groupId>aopalliance</groupId> diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/AbstractResourceTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/AbstractResourceTestCase.java index edde64c5e58..0de164ed693 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/AbstractResourceTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/AbstractResourceTestCase.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.jdisc; -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.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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -14,7 +14,7 @@ import static org.junit.Assert.fail; public class AbstractResourceTestCase { @Test - public void requireThatDestroyIsCalledWhenReleased() { + void requireThatDestroyIsCalledWhenReleased() { MyResource res = new MyResource(); assertFalse(res.destroyed); res.release(); @@ -22,7 +22,7 @@ public class AbstractResourceTestCase { } @Test - public void requireThatDestroyIsCalledWhenRetainCountReachesZero() { + void requireThatDestroyIsCalledWhenRetainCountReachesZero() { MyResource res = new MyResource(); assertEquals(1, res.retainCount()); assertFalse(res.destroyed); @@ -37,7 +37,7 @@ public class AbstractResourceTestCase { } @Test - public void requireThatDestroyIsCalledWhenRetainCountReachesZeroOppositeOrder() { + void requireThatDestroyIsCalledWhenRetainCountReachesZeroOppositeOrder() { MyResource res = new MyResource(); assertEquals(1, res.retainCount()); assertFalse(res.destroyed); @@ -52,7 +52,7 @@ public class AbstractResourceTestCase { } @Test - public void requireThatReleaseCanOnlyBeCalledOnceEvenWhenReferenceCountIsPositive() { + void requireThatReleaseCanOnlyBeCalledOnceEvenWhenReferenceCountIsPositive() { MyResource res = new MyResource(); final ResourceReference secondReference = res.refer(); res.release(); @@ -66,7 +66,7 @@ public class AbstractResourceTestCase { } @Test - public void requireThatSecondaryReferenceCanOnlyBeClosedOnceEvenWhenReferenceCountIsPositive() { + void requireThatSecondaryReferenceCanOnlyBeClosedOnceEvenWhenReferenceCountIsPositive() { MyResource res = new MyResource(); final ResourceReference secondReference = res.refer(); secondReference.close(); @@ -80,7 +80,7 @@ public class AbstractResourceTestCase { } @Test - public void requireThatReleaseAfterDestroyThrows() { + void requireThatReleaseAfterDestroyThrows() { MyResource res = new MyResource(); res.release(); assertTrue(res.destroyed); @@ -101,7 +101,7 @@ public class AbstractResourceTestCase { } @Test - public void requireThatReferAfterDestroyThrows() { + void requireThatReferAfterDestroyThrows() { MyResource res = new MyResource(); res.release(); assertTrue(res.destroyed); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/ContainerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/ContainerTestCase.java index 184f7b4d77d..2a4360be0d7 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/ContainerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/ContainerTestCase.java @@ -4,12 +4,12 @@ package com.yahoo.jdisc; import com.google.inject.AbstractModule; import com.yahoo.jdisc.service.BindingSetNotFoundException; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** @@ -18,7 +18,7 @@ import static org.junit.Assert.assertSame; public class ContainerTestCase { @Test - public void requireThatNewRequestsReferenceSameSnapshot() throws Exception { + void requireThatNewRequestsReferenceSameSnapshot() throws Exception { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); driver.activateContainer(driver.newContainerBuilder()); Request foo = new Request(driver, URI.create("http://foo")); @@ -31,7 +31,7 @@ public class ContainerTestCase { } @Test - public void requireThatInjectionWorks() throws BindingSetNotFoundException { + void requireThatInjectionWorks() throws BindingSetNotFoundException { final Object foo = new Object(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/HeaderFieldsTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/HeaderFieldsTestCase.java index 2fa5700f87b..70de99b191b 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/HeaderFieldsTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/HeaderFieldsTestCase.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.jdisc; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collection; @@ -11,12 +11,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; /** @@ -25,7 +26,7 @@ import static org.junit.Assert.fail; public class HeaderFieldsTestCase { @Test - public void requireThatSizeWorksAsExpected() { + void requireThatSizeWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertEquals(0, headers.size()); headers.add("foo", "bar"); @@ -41,7 +42,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatIsEmptyWorksAsExpected() { + void requireThatIsEmptyWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertTrue(headers.isEmpty()); headers.add("foo", "bar"); @@ -51,7 +52,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatContainsKeyWorksAsExpected() { + void requireThatContainsKeyWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertFalse(headers.containsKey("foo")); assertFalse(headers.containsKey("FOO")); @@ -61,7 +62,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatContainsValueWorksAsExpected() { + void requireThatContainsValueWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertFalse(headers.containsValue(Arrays.asList("bar"))); headers.add("foo", "bar"); @@ -69,7 +70,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatContainsWorksAsExpected() { + void requireThatContainsWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertFalse(headers.contains("foo", "bar")); assertFalse(headers.contains("FOO", "bar")); @@ -83,7 +84,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatContainsIgnoreCaseWorksAsExpected() { + void requireThatContainsIgnoreCaseWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertFalse(headers.containsIgnoreCase("foo", "bar")); assertFalse(headers.containsIgnoreCase("FOO", "bar")); @@ -97,7 +98,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatAddStringWorksAsExpected() { + void requireThatAddStringWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.add("foo", "bar"); @@ -107,7 +108,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatAddListWorksAsExpected() { + void requireThatAddListWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.add("foo", Arrays.asList("bar")); @@ -117,7 +118,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatAddAllWorksAsExpected() { + void requireThatAddAllWorksAsExpected() { HeaderFields headers = new HeaderFields(); headers.add("foo", "bar"); headers.add("bar", "baz"); @@ -134,7 +135,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatPutStringWorksAsExpected() { + void requireThatPutStringWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.put("foo", "bar"); @@ -144,7 +145,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatPutListWorksAsExpected() { + void requireThatPutListWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.put("foo", Arrays.asList("bar")); @@ -154,7 +155,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatPutAllWorksAsExpected() { + void requireThatPutAllWorksAsExpected() { HeaderFields headers = new HeaderFields(); headers.add("foo", "bar"); headers.add("bar", "baz"); @@ -171,7 +172,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatRemoveWorksAsExpected() { + void requireThatRemoveWorksAsExpected() { HeaderFields headers = new HeaderFields(); headers.put("foo", Arrays.asList("bar", "baz")); assertEquals(Arrays.asList("bar", "baz"), headers.get("foo")); @@ -181,7 +182,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatRemoveStringWorksAsExpected() { + void requireThatRemoveStringWorksAsExpected() { HeaderFields headers = new HeaderFields(); headers.put("foo", Arrays.asList("bar", "baz")); assertEquals(Arrays.asList("bar", "baz"), headers.get("foo")); @@ -194,7 +195,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatClearWorksAsExpected() { + void requireThatClearWorksAsExpected() { HeaderFields headers = new HeaderFields(); headers.add("foo", "bar"); headers.add("bar", "baz"); @@ -206,7 +207,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatGetWorksAsExpected() { + void requireThatGetWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.add("foo", "bar"); @@ -214,7 +215,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatGetFirstWorksAsExpected() { + void requireThatGetFirstWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.getFirst("foo")); headers.add("foo", Arrays.asList("bar", "baz")); @@ -222,7 +223,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatIsTrueWorksAsExpected() { + void requireThatIsTrueWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertFalse(headers.isTrue("foo")); headers.put("foo", Arrays.asList("true")); @@ -240,7 +241,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatKeySetWorksAsExpected() { + void requireThatKeySetWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertTrue(headers.keySet().isEmpty()); headers.add("foo", "bar"); @@ -250,7 +251,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatValuesWorksAsExpected() { + void requireThatValuesWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertTrue(headers.values().isEmpty()); headers.add("foo", "bar"); @@ -266,7 +267,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatEntrySetWorksAsExpected() { + void requireThatEntrySetWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertTrue(headers.entrySet().isEmpty()); headers.put("foo", Arrays.asList("bar", "baz")); @@ -280,7 +281,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatEntriesWorksAsExpected() { + void requireThatEntriesWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertTrue(headers.entries().isEmpty()); headers.put("foo", Arrays.asList("bar", "baz")); @@ -299,7 +300,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatEntryIsUnmodifiable() { + void requireThatEntryIsUnmodifiable() { HeaderFields headers = new HeaderFields(); headers.put("foo", "bar"); Map.Entry<String, String> entry = headers.entries().get(0); @@ -312,7 +313,7 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatEntriesAreUnmodifiable() { + void requireThatEntriesAreUnmodifiable() { HeaderFields headers = new HeaderFields(); headers.put("foo", "bar"); List<Map.Entry<String, String>> entries = headers.entries(); @@ -331,25 +332,25 @@ public class HeaderFieldsTestCase { } @Test - public void requireThatEqualsWorksAsExpected() { + void requireThatEqualsWorksAsExpected() { HeaderFields lhs = new HeaderFields(); HeaderFields rhs = new HeaderFields(); - 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() { HeaderFields lhs = new HeaderFields(); HeaderFields rhs = new HeaderFields(); - 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/jdisc_core/src/test/java/com/yahoo/jdisc/ProxyRequestHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/ProxyRequestHandlerTestCase.java index 017db9d39da..c6b959e1c37 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/ProxyRequestHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/ProxyRequestHandlerTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; @@ -16,13 +16,13 @@ import java.util.logging.Handler; import java.util.logging.LogRecord; import java.util.logging.Logger; -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.assertSame; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -31,7 +31,7 @@ import static org.junit.Assert.fail; public class ProxyRequestHandlerTestCase { @Test - public void requireThatRequestHandlerIsProxied() { + void requireThatRequestHandlerIsProxied() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Request request = newRequest(driver, requestHandler); @@ -54,7 +54,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatRequestContentCompletedIsProxied() { + void requireThatRequestContentCompletedIsProxied() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newInstance(); Request request = newRequest(driver, requestHandler); @@ -90,7 +90,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatRequestContentFailedIsProxied() { + void requireThatRequestContentFailedIsProxied() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newInstance(); Request request = newRequest(driver, requestHandler); @@ -128,7 +128,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatNullRequestContentIsProxied() { + void requireThatNullRequestContentIsProxied() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newNullContent(); Request request = newRequest(driver, requestHandler); @@ -140,7 +140,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatRequestWriteCompletionCanOnlyBeCalledOnce() { + void requireThatRequestWriteCompletionCanOnlyBeCalledOnce() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newInstance(); Request request = newRequest(driver, requestHandler); @@ -178,7 +178,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatRequestCloseCompletionCanOnlyBeCalledOnce() { + void requireThatRequestCloseCompletionCanOnlyBeCalledOnce() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newInstance(); Request request = newRequest(driver, requestHandler); @@ -214,7 +214,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatResponseContentCompletedIsProxied() { + void requireThatResponseContentCompletedIsProxied() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Request request = newRequest(driver, requestHandler); @@ -251,7 +251,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatResponseContentFailedIsProxied() { + void requireThatResponseContentFailedIsProxied() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Request request = newRequest(driver, requestHandler); @@ -290,7 +290,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatNullResponseContentIsProxied() { + void requireThatNullResponseContentIsProxied() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Request request = newRequest(driver, requestHandler); @@ -308,7 +308,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatResponseWriteCompletionCanOnlyBeCalledOnce() { + void requireThatResponseWriteCompletionCanOnlyBeCalledOnce() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); MyResponseHandler responseHandler = MyResponseHandler.newInstance(); @@ -347,7 +347,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatResponseCloseCompletionCanOnlyBeCalledOnce() { + void requireThatResponseCloseCompletionCanOnlyBeCalledOnce() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); MyResponseHandler responseHandler = MyResponseHandler.newInstance(); @@ -383,7 +383,7 @@ public class ProxyRequestHandlerTestCase { } @Test - public void requireThatUncaughtCompletionFailureIsLogged() { + void requireThatUncaughtCompletionFailureIsLogged() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = MyRequestHandler.newInstance(); Request request = newRequest(driver, requestHandler); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java index 9b42ea19c81..42fc772f28b 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencedResourceTestCase.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.jdisc; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -13,7 +13,7 @@ import static org.mockito.Mockito.verify; */ public class ReferencedResourceTestCase { @Test - public void requireThatGettersMatchConstructor() { + void requireThatGettersMatchConstructor() { final SharedResource resource = mock(SharedResource.class); final ResourceReference reference = mock(ResourceReference.class); final ReferencedResource<SharedResource> referencedResource = new ReferencedResource<>(resource, reference); @@ -22,7 +22,7 @@ public class ReferencedResourceTestCase { } @Test - public void requireThatCloseCallsReferenceClose() { + void requireThatCloseCallsReferenceClose() { final SharedResource resource = mock(SharedResource.class); final ResourceReference reference = mock(ResourceReference.class); final ReferencedResource<SharedResource> referencedResource = new ReferencedResource<>(resource, reference); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencesTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencesTestCase.java index 7a561e7fc89..efe48e1e528 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencesTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/ReferencesTestCase.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.jdisc; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -12,7 +12,7 @@ import static org.mockito.Mockito.verify; */ public class ReferencesTestCase { @Test - public void requireThatFromResourceCallsReleaseOnResource() { + void requireThatFromResourceCallsReleaseOnResource() { final SharedResource resource = mock(SharedResource.class); final ResourceReference reference = References.fromResource(resource); reference.close(); @@ -20,7 +20,7 @@ public class ReferencesTestCase { } @Test - public void requireThatNoopReferenceCanBeCalledMultipleTimes() { + void requireThatNoopReferenceCanBeCalledMultipleTimes() { References.NOOP_REFERENCE.close(); References.NOOP_REFERENCE.close(); } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/RequestTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/RequestTestCase.java index 0d665e297da..4b2bb327442 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/RequestTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/RequestTestCase.java @@ -12,19 +12,19 @@ import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.BindingSetNotFoundException; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.TimeUnit; -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.assertSame; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -33,7 +33,7 @@ import static org.junit.Assert.fail; public class RequestTestCase { @Test - public void requireThatAccessorsWork() throws BindingSetNotFoundException { + void requireThatAccessorsWork() throws BindingSetNotFoundException { MyTimer timer = new MyTimer(); timer.currentTime = 69; @@ -58,7 +58,7 @@ public class RequestTestCase { } @Test - public void requireThatCancelWorks() { + void requireThatCancelWorks() { MyTimer timer = new MyTimer(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(timer); Request request = newRequest(driver); @@ -70,7 +70,7 @@ public class RequestTestCase { } @Test - public void requireThatDefaultTimeoutIsInfinite() { + void requireThatDefaultTimeoutIsInfinite() { MyTimer timer = new MyTimer(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(timer); Request request = newRequest(driver); @@ -84,7 +84,7 @@ public class RequestTestCase { } @Test - public void requireThatTimeRemainingUsesTimer() { + void requireThatTimeRemainingUsesTimer() { MyTimer timer = new MyTimer(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(timer); Request request = newRequest(driver); @@ -93,14 +93,14 @@ public class RequestTestCase { ++timer.currentTime) { assertEquals(request.getTimeout(TimeUnit.MILLISECONDS) - timer.currentTime, - request.timeRemaining(TimeUnit.MILLISECONDS).longValue()); + request.timeRemaining(TimeUnit.MILLISECONDS).longValue()); } request.release(); assertTrue(driver.close()); } @Test - public void requireThatTimeoutCausesCancel() { + void requireThatTimeoutCausesCancel() { MyTimer timer = new MyTimer(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(timer); Request request = newRequest(driver); @@ -113,7 +113,7 @@ public class RequestTestCase { } @Test - public void requireThatCancelIsTrueIfParentIsCancelled() { + void requireThatCancelIsTrueIfParentIsCancelled() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); Request parent = newRequest(driver); Request child = new Request(parent, URI.create("http://localhost/")); @@ -125,7 +125,7 @@ public class RequestTestCase { } @Test - public void requireThatDestroyReleasesContainer() { + void requireThatDestroyReleasesContainer() { final MyContainer container = new MyContainer(); Request request = new Request(new CurrentContainer() { @@ -140,7 +140,7 @@ public class RequestTestCase { } @Test - public void requireThatServerConnectResolvesToServerBinding() { + void requireThatServerConnectResolvesToServerBinding() { MyContainer container = new MyContainer(); Request request = new Request(container, URI.create("http://localhost/")); request.connect(new MyResponseHandler()); @@ -149,7 +149,7 @@ public class RequestTestCase { } @Test - public void requireThatClientConnectResolvesToClientBinding() { + void requireThatClientConnectResolvesToClientBinding() { MyContainer container = new MyContainer(); Request serverReq = new Request(container, URI.create("http://localhost/")); Request clientReq = new Request(serverReq, URI.create("http://localhost/")); @@ -159,7 +159,7 @@ public class RequestTestCase { } @Test - public void requireThatNullTimeoutManagerThrowsException() { + void requireThatNullTimeoutManagerThrowsException() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); Request request = newRequest(driver); @@ -175,7 +175,7 @@ public class RequestTestCase { } @Test - public void requireThatTimeoutManagerCanNotBeReplaced() { + void requireThatTimeoutManagerCanNotBeReplaced() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); Request request = newRequest(driver); @@ -193,7 +193,7 @@ public class RequestTestCase { } @Test - public void requireThatSetTimeoutCallsTimeoutManager() { + void requireThatSetTimeoutCallsTimeoutManager() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); Request request = newRequest(driver); @@ -207,7 +207,7 @@ public class RequestTestCase { } @Test - public void requireThatSetTimeoutManagerPropagatesCurrentTimeout() { + void requireThatSetTimeoutManagerPropagatesCurrentTimeout() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); Request request = newRequest(driver); @@ -221,7 +221,7 @@ public class RequestTestCase { } @Test - public void requireThatUriIsNormalized() { + void requireThatUriIsNormalized() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); driver.activateContainer(driver.newContainerBuilder()); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/ResponseTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/ResponseTestCase.java index b3fbbceb06a..ec5079a31ab 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/ResponseTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/ResponseTestCase.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.jdisc; -import org.junit.Test; +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.assertTrue; /** @@ -14,7 +14,7 @@ import static org.junit.Assert.assertTrue; public class ResponseTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { Response response = new Response(69); assertEquals(69, response.getStatus()); response.setStatus(96); @@ -27,7 +27,7 @@ public class ResponseTestCase { } @Test - public void requireThatStatusCodesDoNotChange() { + void requireThatStatusCodesDoNotChange() { assertEquals(100, Response.Status.CONTINUE); assertEquals(101, Response.Status.SWITCHING_PROTOCOLS); assertEquals(102, Response.Status.PROCESSING); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/AbstractApplicationTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/AbstractApplicationTestCase.java index 3a6aa03ad45..03d5728679f 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/AbstractApplicationTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/AbstractApplicationTestCase.java @@ -4,15 +4,15 @@ package com.yahoo.jdisc.application; import com.google.inject.Inject; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -21,27 +21,27 @@ import static org.junit.Assert.assertTrue; public class AbstractApplicationTestCase { @Test - public void requireThatContainerApiIsAvailable() { + void requireThatContainerApiIsAvailable() { TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class); - MyApplication app = (MyApplication)driver.application(); + MyApplication app = (MyApplication) driver.application(); app.activateContainer(app.newContainerBuilder()); assertNotNull(app.container()); assertTrue(driver.close()); } @Test - public void requireThatDestroySignalsTermination() { + void requireThatDestroySignalsTermination() { TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class); - MyApplication app = (MyApplication)driver.application(); + MyApplication app = (MyApplication) driver.application(); assertFalse(app.isTerminated()); assertTrue(driver.close()); assertTrue(app.isTerminated()); } @Test - public void requireThatTerminationCanBeWaitedForWithTimeout() throws InterruptedException { + void requireThatTerminationCanBeWaitedForWithTimeout() throws InterruptedException { TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class); - final MyApplication app = (MyApplication)driver.application(); + final MyApplication app = (MyApplication) driver.application(); final CountDownLatch latch = new CountDownLatch(1); Executors.newSingleThreadExecutor().execute(new Runnable() { @@ -61,9 +61,9 @@ public class AbstractApplicationTestCase { } @Test - public void requireThatTerminationCanBeWaitedForWithoutTimeout() throws InterruptedException { + void requireThatTerminationCanBeWaitedForWithoutTimeout() throws InterruptedException { TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class); - final MyApplication app = (MyApplication)driver.application(); + final MyApplication app = (MyApplication) driver.application(); final CountDownLatch latch = new CountDownLatch(1); Executors.newSingleThreadExecutor().execute(new Runnable() { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java index 63331d2014d..1ac091fcc68 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ApplicationNotReadyTestCase.java @@ -4,11 +4,11 @@ package com.yahoo.jdisc.application; import com.google.inject.Inject; import com.google.inject.ProvisionException; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -17,7 +17,7 @@ import static org.junit.Assert.fail; public class ApplicationNotReadyTestCase { @Test - public void requireThatExceptionIsThrown() { + void requireThatExceptionIsThrown() { try { TestDriver.newInjectedApplicationInstanceWithoutOsgi(MyApplication.class); fail(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingMatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingMatchTestCase.java index 5c0942fbf37..7ea8e84228d 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingMatchTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingMatchTestCase.java @@ -1,13 +1,13 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.application; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -16,7 +16,7 @@ import static org.junit.Assert.fail; public class BindingMatchTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { Object obj = new Object(); UriPattern pattern = new UriPattern("http://*/*"); BindingMatch<Object> match = new BindingMatch<>( @@ -31,7 +31,7 @@ public class BindingMatchTestCase { } @Test - public void requireThatConstructorArgumentsCanNotBeNull() { + void requireThatConstructorArgumentsCanNotBeNull() { try { new BindingMatch<>(null, null, null); fail(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingRepositoryTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingRepositoryTestCase.java index 95ba6cde595..92a85cfdc4a 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingRepositoryTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingRepositoryTestCase.java @@ -7,19 +7,19 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.test.NonWorkingRequestHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -27,7 +27,7 @@ import static org.junit.Assert.fail; public class BindingRepositoryTestCase { @Test - public void requireThatRepositoryCanBeActivated() { + void requireThatRepositoryCanBeActivated() { BindingRepository<Object> bindings = new BindingRepository<>(); bindings.bind("http://host/path", new Object()); @@ -41,7 +41,7 @@ public class BindingRepositoryTestCase { } @Test - public void requireThatActivationIsSnapshotOfRepository() { + void requireThatActivationIsSnapshotOfRepository() { BindingRepository<Object> bindings = new BindingRepository<>(); bindings.bind("http://host/path", new Object()); @@ -57,7 +57,7 @@ public class BindingRepositoryTestCase { } @Test - public void requireThatObjectsCanBeBound() { + void requireThatObjectsCanBeBound() { BindingRepository<Object> bindings = new BindingRepository<>(); Object foo = new Object(); Object bar = new Object(); @@ -79,7 +79,7 @@ public class BindingRepositoryTestCase { } @Test - public void requireThatPatternCannotBeStolen() { + void requireThatPatternCannotBeStolen() { final String pattern = "http://host/path"; final RequestHandler originallyBoundHandler = new NonWorkingRequestHandler(); @@ -92,7 +92,7 @@ public class BindingRepositoryTestCase { } @Test - public void requireThatBindAllMethodWorks() { + void requireThatBindAllMethodWorks() { Object foo = new Object(); Object bar = new Object(); Object baz = new Object(); @@ -122,7 +122,7 @@ public class BindingRepositoryTestCase { } @Test - public void requireThatPutAllMethodWorks() { + void requireThatPutAllMethodWorks() { Object foo = new Object(); Object bar = new Object(); Object baz = new Object(); @@ -153,7 +153,7 @@ public class BindingRepositoryTestCase { } @Test - public void requireThatPutNullThrowsException() { + void requireThatPutNullThrowsException() { try { new BindingRepository<>().put(null, new Object()); fail(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingSetTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingSetTestCase.java index 3b7d8aafcab..504810dc2ed 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingSetTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BindingSetTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.jdisc.application; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.test.NonWorkingRequestHandler; import static com.yahoo.vespa.defaults.Defaults.getDefaults; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; @@ -14,12 +14,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -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.assertSame; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue; public class BindingSetTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); handlers.put(new UriPattern("http://host/foo"), foo); @@ -51,7 +51,7 @@ public class BindingSetTestCase { } @Test - public void requireThatSimpleResolutionWorks() { + void requireThatSimpleResolutionWorks() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); handlers.put(new UriPattern("http://host/foo"), foo); @@ -72,7 +72,7 @@ public class BindingSetTestCase { } @Test - public void requireThatPatternResolutionWorks() { + void requireThatPatternResolutionWorks() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); handlers.put(new UriPattern("http://host/*"), foo); @@ -94,7 +94,7 @@ public class BindingSetTestCase { } @Test - public void requireThatPatternResolutionWorksForWildCards() { + void requireThatPatternResolutionWorksForWildCards() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); handlers.put(new UriPattern("http://host:*/bar"), foo); @@ -125,7 +125,7 @@ public class BindingSetTestCase { } @Test - public void requireThatPatternResolutionWorksForFilters() { + void requireThatPatternResolutionWorksForFilters() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); handlers.put(new UriPattern("http://*/filtered/*"), foo); @@ -139,7 +139,7 @@ public class BindingSetTestCase { } @Test - public void requireThatTreeSplitCanBeBoundForSchemes() { + void requireThatTreeSplitCanBeBoundForSchemes() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler httpfoo = new NonWorkingRequestHandler(); RequestHandler httpsfoo = new NonWorkingRequestHandler(); @@ -152,7 +152,7 @@ public class BindingSetTestCase { } @Test - public void requireThatTreeSplitCanBeBoundForHosts() { + void requireThatTreeSplitCanBeBoundForHosts() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler foobar = new NonWorkingRequestHandler(); @@ -165,7 +165,7 @@ public class BindingSetTestCase { } @Test - public void requireThatTreeSplitCanBeBoundForPorts() { + void requireThatTreeSplitCanBeBoundForPorts() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo8080 = new NonWorkingRequestHandler(); RequestHandler foo80 = new NonWorkingRequestHandler(); @@ -181,7 +181,7 @@ public class BindingSetTestCase { } @Test - public void requireThatTreeSplitCanBeBoundForPaths() { + void requireThatTreeSplitCanBeBoundForPaths() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler foobar = new NonWorkingRequestHandler(); @@ -194,7 +194,7 @@ public class BindingSetTestCase { } @Test - public void requireThatTreeSplitCanBeBoundForWildcards() { + void requireThatTreeSplitCanBeBoundForWildcards() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo8080 = new NonWorkingRequestHandler(); RequestHandler foo80 = new NonWorkingRequestHandler(); @@ -213,7 +213,7 @@ public class BindingSetTestCase { } @Test - public void requireThatTreeWorksForURIWithQueryOrFragments() { + void requireThatTreeWorksForURIWithQueryOrFragments() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); handlers.put(new UriPattern("http://*/application/v1/session"), foo); @@ -226,7 +226,7 @@ public class BindingSetTestCase { } @Test - public void requireThatTreeWorksForURIWithPathWildCards() { + void requireThatTreeWorksForURIWithPathWildCards() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler foo1 = new NonWorkingRequestHandler(); @@ -303,7 +303,7 @@ public class BindingSetTestCase { } @Test - public void requireThatPathOverPortWorks() { + void requireThatPathOverPortWorks() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler applicationStatus = new NonWorkingRequestHandler(); RequestHandler search = new NonWorkingRequestHandler(); @@ -327,7 +327,7 @@ public class BindingSetTestCase { } @Test - public void requireThatPathOverPortsDoNotWorkOverStricterPatterns() { + void requireThatPathOverPortsDoNotWorkOverStricterPatterns() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler bar = new NonWorkingRequestHandler(); @@ -339,7 +339,7 @@ public class BindingSetTestCase { } @Test - public void requireThatSchemeOrderOverHost() { + void requireThatSchemeOrderOverHost() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler bar = new NonWorkingRequestHandler(); @@ -352,7 +352,7 @@ public class BindingSetTestCase { } @Test - public void requireThatPortsAreOrdered() { + void requireThatPortsAreOrdered() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler bar = new NonWorkingRequestHandler(); @@ -370,7 +370,7 @@ public class BindingSetTestCase { } @Test - public void requireThatPathsAreOrdered() { + void requireThatPathsAreOrdered() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler bar = new NonWorkingRequestHandler(); @@ -388,7 +388,7 @@ public class BindingSetTestCase { } @Test - public void requireThatStrictPatternsOrderBeforeWildcards() { + void requireThatStrictPatternsOrderBeforeWildcards() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler fooScheme = new NonWorkingRequestHandler(); @@ -436,7 +436,7 @@ public class BindingSetTestCase { } @Test - public void requireThatToStringMethodWorks() { + void requireThatToStringMethodWorks() { Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>(); RequestHandler foo = new NonWorkingRequestHandler(); RequestHandler bar = new NonWorkingRequestHandler(); @@ -449,7 +449,7 @@ public class BindingSetTestCase { @Test - public void requireThatPatternsAreOrderedMoreSpecificToLess() { + void requireThatPatternsAreOrderedMoreSpecificToLess() { assertOrder("3://host/path", "2://host/path", "1://host/path"); assertOrder("http://3/path", "http://2/path", "http://1/path"); assertOrder("http://host:3/path", "http://host:2/path", "http://host:1/path"); @@ -459,19 +459,19 @@ public class BindingSetTestCase { assertOrder("http://host:*/3", "http://host:2/2", "http://host:1/1"); assertOrder("http://host/*/3/2/", "http://host/*/1/2", "http://host/*/2/*"); assertOrder("http://host:69/path", - "http://host/*", - "http://*:69/path", - "http://*/path", - "http://*:69/*", - "http://*/*", - "*://host/path", - "*://*/path", - "*://*/*"); + "http://host/*", + "http://*:69/path", + "http://*/path", + "http://*:69/*", + "http://*/*", + "*://host/path", + "*://*/path", + "*://*/*"); assertOrder("http://*/HelloWorld", - "http://*:4080/state/v1/*", - "http://*:4083/*", - "http://*:4081/*", - "http://*:4080/*"); + "http://*:4080/state/v1/*", + "http://*:4083/*", + "http://*:4081/*", + "http://*:4080/*"); } private static void assertOrder(String... expected) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BundleInstallationExceptionTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BundleInstallationExceptionTestCase.java index 681ca4dea98..d16f13814c1 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/BundleInstallationExceptionTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/BundleInstallationExceptionTestCase.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.jdisc.application; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.osgi.framework.Bundle; @@ -9,9 +9,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -20,7 +20,7 @@ import static org.junit.Assert.fail; public class BundleInstallationExceptionTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { Throwable t = new Throwable("foo"); Collection<Bundle> bundles = new LinkedList<>(); bundles.add(Mockito.mock(Bundle.class)); @@ -31,7 +31,7 @@ public class BundleInstallationExceptionTestCase { } @Test - public void requireThatBundlesCollectionIsDefensivelyCopied() { + void requireThatBundlesCollectionIsDefensivelyCopied() { Collection<Bundle> bundles = new LinkedList<>(); bundles.add(Mockito.mock(Bundle.class)); BundleInstallationException e = new BundleInstallationException(bundles, new Throwable()); @@ -40,9 +40,9 @@ public class BundleInstallationExceptionTestCase { } @Test - public void requireThatBundlesCollectionIsUnmodifiable() { + void requireThatBundlesCollectionIsUnmodifiable() { BundleInstallationException e = new BundleInstallationException(Arrays.asList(Mockito.mock(Bundle.class)), - new Throwable()); + new Throwable()); try { e.installedBundles().add(Mockito.mock(Bundle.class)); fail(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerBuilderTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerBuilderTestCase.java index 288b46c995f..a31c72584a5 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerBuilderTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerBuilderTestCase.java @@ -5,18 +5,18 @@ import com.google.inject.AbstractModule; import com.google.inject.Key; import com.google.inject.name.Names; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URISyntaxException; import java.util.Arrays; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -25,7 +25,7 @@ import static org.junit.Assert.fail; public class ContainerBuilderTestCase { @Test - public void requireThatAccessorsWork() throws URISyntaxException { + void requireThatAccessorsWork() throws URISyntaxException { final Object obj = new Object(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { @@ -47,7 +47,7 @@ public class ContainerBuilderTestCase { } @Test - public void requireThatContainerThreadFactoryIsBound() { + void requireThatContainerThreadFactoryIsBound() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); assertSame(ContainerThread.Factory.class, builder.getInstance(ThreadFactory.class).getClass()); @@ -55,7 +55,7 @@ public class ContainerBuilderTestCase { } @Test - public void requireThatThreadFactoryCanBeReconfigured() { + void requireThatThreadFactoryCanBeReconfigured() { final ThreadFactory factory = Executors.defaultThreadFactory(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); @@ -71,7 +71,7 @@ public class ContainerBuilderTestCase { } @Test - public void requireThatBindingSetsAreCreatedOnDemand() { + void requireThatBindingSetsAreCreatedOnDemand() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); BindingRepository<?> repo = builder.serverBindings("foo"); @@ -87,12 +87,12 @@ public class ContainerBuilderTestCase { } @Test - public void requireThatSafeClassCastWorks() { + void requireThatSafeClassCastWorks() { ContainerBuilder.safeClassCast(Integer.class, Integer.class); } @Test - public void requireThatSafeClassCastThrowsIllegalArgument() { + void requireThatSafeClassCastThrowsIllegalArgument() { try { ContainerBuilder.safeClassCast(Integer.class, Double.class); fail(); @@ -102,7 +102,7 @@ public class ContainerBuilderTestCase { } @Test - public void requireThatSafeStringSplitWorks() { + void requireThatSafeStringSplitWorks() { assertTrue(ContainerBuilder.safeStringSplit(new Object(), ",").isEmpty()); assertTrue(ContainerBuilder.safeStringSplit("", ",").isEmpty()); assertTrue(ContainerBuilder.safeStringSplit(" \f\n\r\t", ",").isEmpty()); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerThreadTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerThreadTestCase.java index c7780808bf6..4d17b285926 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerThreadTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ContainerThreadTestCase.java @@ -2,13 +2,13 @@ package com.yahoo.jdisc.application; import com.yahoo.jdisc.Metric; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; /** @@ -17,14 +17,14 @@ import static org.junit.Assert.assertSame; public class ContainerThreadTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { MetricConsumer consumer = new MyConsumer(); ContainerThread thread = new ContainerThread(new MyTask(), consumer); assertSame(consumer, thread.consumer()); } @Test - public void requireThatTaskIsRun() throws InterruptedException { + void requireThatTaskIsRun() throws InterruptedException { MyTask task = new MyTask(); ContainerThread thread = new ContainerThread(task, null); thread.start(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/GlobPatternTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/GlobPatternTestCase.java index abe47662970..8a01406940f 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/GlobPatternTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/GlobPatternTestCase.java @@ -1,18 +1,18 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.application; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -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.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; /** * @author Simon Thoresen Hult @@ -20,7 +20,7 @@ import static org.junit.Assert.assertTrue; public class GlobPatternTestCase { @Test - public void requireThatCompileCreatesExpectedParts() { + void requireThatCompileCreatesExpectedParts() { assertToString("foo"); assertToString("*foo"); assertToString("*oo"); @@ -38,7 +38,7 @@ public class GlobPatternTestCase { } @Test - public void requireThatGlobMatcherWorks() { + void requireThatGlobMatcherWorks() { assertMatch("foo", "foo", Collections.<String>emptyList()); assertNotMatch("foo", "bar"); @@ -81,7 +81,7 @@ public class GlobPatternTestCase { } @Test - public void requireThatGlobPatternOrdersMoreSpecificFirst() { + void requireThatGlobPatternOrdersMoreSpecificFirst() { assertCompareEq("foo", "foo"); assertCompareLt("foo", "foo*"); assertCompareLt("foo", "*foo"); @@ -112,15 +112,15 @@ public class GlobPatternTestCase { } @Test - public void requireThatEqualsIsImplemented() { - assertTrue(GlobPattern.compile("foo").equals(GlobPattern.compile("foo"))); - assertFalse(GlobPattern.compile("foo").equals(GlobPattern.compile("bar"))); + void requireThatEqualsIsImplemented() { + assertEquals(GlobPattern.compile("foo"), GlobPattern.compile("foo")); + assertNotEquals(GlobPattern.compile("foo"), GlobPattern.compile("bar")); } @Test - public void requireThatHashCodeIsImplemented() { - assertTrue(GlobPattern.compile("foo").hashCode() == GlobPattern.compile("foo").hashCode()); - assertFalse(GlobPattern.compile("foo").hashCode() == GlobPattern.compile("bar").hashCode()); + void requireThatHashCodeIsImplemented() { + assertEquals(GlobPattern.compile("foo").hashCode(), GlobPattern.compile("foo").hashCode()); + assertNotNull(GlobPattern.compile("bar").hashCode()); } private static void assertCompareLt(String lhs, String rhs) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/GuiceRepositoryTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/GuiceRepositoryTestCase.java index 11857163970..9e100e3346a 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/GuiceRepositoryTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/GuiceRepositoryTestCase.java @@ -10,18 +10,18 @@ import com.google.inject.Module; import com.google.inject.PrivateModule; import com.google.inject.name.Named; import com.google.inject.name.Names; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Iterator; import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -30,7 +30,7 @@ import static org.junit.Assert.fail; public class GuiceRepositoryTestCase { @Test - public void requireThatInstallWorks() { + void requireThatInstallWorks() { GuiceRepository guice = new GuiceRepository(); StringBinding module = new StringBinding("fooKey", "fooVal"); guice.install(module); @@ -43,7 +43,7 @@ public class GuiceRepositoryTestCase { } @Test - public void requireThatInstallAllWorks() { + void requireThatInstallAllWorks() { GuiceRepository guice = new GuiceRepository(); StringBinding foo = new StringBinding("fooKey", "fooVal"); StringBinding bar = new StringBinding("barKey", "barVal"); @@ -60,7 +60,7 @@ public class GuiceRepositoryTestCase { } @Test - public void requireThatUninstallWorks() { + void requireThatUninstallWorks() { GuiceRepository guice = new GuiceRepository(); StringBinding module = new StringBinding("fooKey", "fooVal"); guice.install(module); @@ -72,7 +72,7 @@ public class GuiceRepositoryTestCase { } @Test - public void requireThatUninstallAllWorks() { + void requireThatUninstallAllWorks() { GuiceRepository guice = new GuiceRepository(); StringBinding foo = new StringBinding("fooKey", "fooVal"); StringBinding bar = new StringBinding("barKey", "barVal"); @@ -95,7 +95,7 @@ public class GuiceRepositoryTestCase { } @Test - public void requireThatBindingsCanBeOverridden() { + void requireThatBindingsCanBeOverridden() { GuiceRepository guice = new GuiceRepository(); guice.install(new StringBinding("fooKey", "fooVal1")); assertBinding(guice, "fooKey", "fooVal1"); @@ -104,7 +104,7 @@ public class GuiceRepositoryTestCase { } @Test - public void requireThatModulesAreOnlyEvaluatedOnce() { + void requireThatModulesAreOnlyEvaluatedOnce() { GuiceRepository guice = new GuiceRepository(); EvalCounter foo = new EvalCounter(); EvalCounter bar = new EvalCounter(); @@ -119,18 +119,18 @@ public class GuiceRepositoryTestCase { } @Test - public void requireThatPrivateModulesWorks() { + void requireThatPrivateModulesWorks() { GuiceRepository guice = new GuiceRepository(); List<Named> names = Arrays.asList(Names.named("A"), Names.named("B")); - for (Named name: names) { + for (Named name : names) { guice.install(createPrivateInjectNameModule(name)); } Injector injector = guice.getInjector(); - for (Named name: names) { + for (Named name : names) { NameHolder nameHolder = injector.getInstance(Key.get(NameHolder.class, name)); assertEquals(name, nameHolder.name); } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/MetricImplTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/MetricImplTestCase.java index 29c51760347..33897d8eacc 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/MetricImplTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/MetricImplTestCase.java @@ -5,7 +5,7 @@ import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.yahoo.jdisc.Metric; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -14,8 +14,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -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; /** @@ -24,13 +24,13 @@ import static org.junit.Assert.assertTrue; public class MetricImplTestCase { @Test - public void requireThatClassIsInjectedByDefault() { + void requireThatClassIsInjectedByDefault() { Metric metric = Guice.createInjector().getInstance(Metric.class); assertTrue(metric instanceof MetricImpl); } @Test - public void requireThatConsumerIsOptional() { + void requireThatConsumerIsOptional() { Injector injector = Guice.createInjector(); Metric metric = injector.getInstance(Metric.class); metric.set("foo", 6, null); @@ -38,7 +38,7 @@ public class MetricImplTestCase { } @Test - public void requireThatConsumerIsCalled() throws InterruptedException { + void requireThatConsumerIsCalled() throws InterruptedException { final MyConsumer consumer = new MyConsumer(); Injector injector = Guice.createInjector(new AbstractModule() { @@ -57,7 +57,7 @@ public class MetricImplTestCase { } @Test - public void requireThatWorkerMetricHasPrecedence() throws InterruptedException { + void requireThatWorkerMetricHasPrecedence() throws InterruptedException { final MyConsumer globalConsumer = new MyConsumer(); Injector injector = Guice.createInjector(new AbstractModule() { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiHeaderTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiHeaderTestCase.java index da1ab024ede..111ae868e05 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiHeaderTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiHeaderTestCase.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.jdisc.application; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -12,7 +12,7 @@ import static org.junit.Assert.assertEquals; public class OsgiHeaderTestCase { @Test - public void requireThatOsgiHeadersDoNotChange() { + void requireThatOsgiHeadersDoNotChange() { assertEquals("X-JDisc-Application", OsgiHeader.APPLICATION); assertEquals("X-JDisc-Preinstall-Bundle", OsgiHeader.PREINSTALL_BUNDLE); assertEquals("X-JDisc-Privileged-Activator", OsgiHeader.PRIVILEGED_ACTIVATOR); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiRepositoryTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiRepositoryTestCase.java index b57fc5ae31f..49d76172c39 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiRepositoryTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/OsgiRepositoryTestCase.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.jdisc.application; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -12,7 +12,7 @@ import static org.junit.Assert.assertTrue; public class OsgiRepositoryTestCase { @Test - public void requireNothingSinceIntegrationModuleTestsThis() { + void requireNothingSinceIntegrationModuleTestsThis() { assertTrue(true); } } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ResourcePoolTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ResourcePoolTestCase.java index b94ff063fc7..d422a6c45e5 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ResourcePoolTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ResourcePoolTestCase.java @@ -6,12 +6,12 @@ import com.google.inject.Key; import com.yahoo.jdisc.AbstractResource; import com.yahoo.jdisc.ResourceReference; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +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.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -20,7 +20,7 @@ import static org.junit.Assert.fail; public class ResourcePoolTestCase { @Test - public void requireThatAddReturnsArgument() { + void requireThatAddReturnsArgument() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyResource foo = new MyResource(); assertSame(foo, new ResourcePool(driver.newContainerBuilder()).add(foo)); @@ -28,7 +28,7 @@ public class ResourcePoolTestCase { } @Test - public void requireThatAddDoesNotRetainArgument() { + void requireThatAddDoesNotRetainArgument() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyResource foo = new MyResource(); assertEquals(1, foo.retainCount()); @@ -38,12 +38,12 @@ public class ResourcePoolTestCase { } @Test - public void requireThatAddCanBeUsedWithoutContainerBuilder() { + void requireThatAddCanBeUsedWithoutContainerBuilder() { new ResourcePool().add(new MyResource()); } @Test - public void requireThatRetainReturnsArgument() { + void requireThatRetainReturnsArgument() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyResource foo = new MyResource(); assertSame(foo, new ResourcePool(driver.newContainerBuilder()).retain(foo)); @@ -51,7 +51,7 @@ public class ResourcePoolTestCase { } @Test - public void requireThatRetainRetainsArgument() { + void requireThatRetainRetainsArgument() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyResource foo = new MyResource(); assertEquals(1, foo.retainCount()); @@ -61,12 +61,12 @@ public class ResourcePoolTestCase { } @Test - public void requireThatRetainCanBeUsedWithoutContainerBuilder() { + void requireThatRetainCanBeUsedWithoutContainerBuilder() { new ResourcePool().retain(new MyResource()); } @Test - public void requireThatGetReturnsBoundInstance() { + void requireThatGetReturnsBoundInstance() { final MyResource foo = new MyResource(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { @@ -82,7 +82,7 @@ public class ResourcePoolTestCase { } @Test - public void requireThatGetDoesNotRetainArgument() { + void requireThatGetDoesNotRetainArgument() { final MyResource foo = new MyResource(); assertEquals(1, foo.retainCount()); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { @@ -101,7 +101,7 @@ public class ResourcePoolTestCase { } @Test - public void requireThatGetCanNotBeUsedWithoutContainerBuilder() { + void requireThatGetCanNotBeUsedWithoutContainerBuilder() { ResourcePool pool = new ResourcePool(); try { pool.get(MyResource.class); @@ -118,7 +118,7 @@ public class ResourcePoolTestCase { } @Test - public void requireThatResourcesAreReleasedOnDestroy() { + void requireThatResourcesAreReleasedOnDestroy() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ResourcePool pool = new ResourcePool(driver.newContainerBuilder()); @@ -152,7 +152,7 @@ public class ResourcePoolTestCase { } @Test - public void requireThatAutoCloseCallsRelease() throws Exception { + void requireThatAutoCloseCallsRelease() throws Exception { MyResource foo = new MyResource(); assertEquals(1, foo.retainCount()); try (ResourcePool pool = new ResourcePool()) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ServerRepositoryTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ServerRepositoryTestCase.java index a5d7184e31a..cb3a81277f3 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/ServerRepositoryTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/ServerRepositoryTestCase.java @@ -3,15 +3,15 @@ package com.yahoo.jdisc.application; import com.yahoo.jdisc.NoopSharedResource; import com.yahoo.jdisc.service.ServerProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Iterator; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Simon Thoresen Hult @@ -19,7 +19,7 @@ import static org.junit.Assert.assertTrue; public class ServerRepositoryTestCase { @Test - public void requireThatInstallWorks() { + void requireThatInstallWorks() { ServerRepository servers = newServerRepository(); MyServer server = new MyServer(); servers.install(server); @@ -31,7 +31,7 @@ public class ServerRepositoryTestCase { } @Test - public void requireThatInstallAllWorks() { + void requireThatInstallAllWorks() { ServerRepository servers = newServerRepository(); ServerProvider foo = new MyServer(); ServerProvider bar = new MyServer(); @@ -46,7 +46,7 @@ public class ServerRepositoryTestCase { } @Test - public void requireThatUninstallWorks() { + void requireThatUninstallWorks() { ServerRepository servers = newServerRepository(); ServerProvider server = new MyServer(); servers.install(server); @@ -55,7 +55,7 @@ public class ServerRepositoryTestCase { } @Test - public void requireThatUninstallAllWorks() { + void requireThatUninstallAllWorks() { ServerRepository servers = newServerRepository(); ServerProvider foo = new MyServer(); ServerProvider bar = new MyServer(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java index 32327ace4f4..7a67aeda5f8 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.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.jdisc.application; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; @@ -9,11 +9,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import static org.junit.Assert.assertEquals; -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.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; /** * @author Simon Thoresen Hult @@ -23,7 +23,7 @@ public class UriPatternTestCase { private static final List<String> NO_GROUPS = Collections.emptyList(); @Test - public void requireThatIllegalPatternsAreDetected() { + void requireThatIllegalPatternsAreDetected() { assertIllegalPattern("scheme"); assertIllegalPattern("scheme://"); assertIllegalPattern("scheme://host"); @@ -36,13 +36,13 @@ public class UriPatternTestCase { } @Test - public void requireThatNoPortImpliesWildcard() { + void requireThatNoPortImpliesWildcard() { assertEquals(new UriPattern("scheme://host/path"), - new UriPattern("scheme://host:*/path")); + new UriPattern("scheme://host:*/path")); } @Test - public void requireThatPatternMatches() { + void requireThatPatternMatches() { // scheme matching UriPattern pattern = new UriPattern("bar://host:69/path"); assertNotMatch(pattern, "foobar://host:69/path"); @@ -124,7 +124,7 @@ public class UriPatternTestCase { } @Test - public void requireThatUriWithoutPathDoesNotThrowException() { + void requireThatUriWithoutPathDoesNotThrowException() { UriPattern pattern = new UriPattern("scheme://host/path"); assertNotMatch(pattern, "scheme://host"); @@ -133,123 +133,123 @@ public class UriPatternTestCase { } @Test - public void requireThatOnlySchemeHostPortAndPathIsMatched() { + void requireThatOnlySchemeHostPortAndPathIsMatched() { UriPattern pattern = new UriPattern("scheme://host:69/path"); assertMatch(pattern, "scheme://host:69/path?foo", NO_GROUPS); assertMatch(pattern, "scheme://host:69/path?foo#bar", NO_GROUPS); } @Test - public void requireThatHostSupportsWildcard() { + void requireThatHostSupportsWildcard() { UriPattern pattern = new UriPattern("scheme://*.host/path"); assertMatch(pattern, "scheme://a.host/path", Arrays.asList("a")); assertMatch(pattern, "scheme://a.b.host/path", Arrays.asList("a.b")); } @Test - public void requireThatSchemesAreOrdered() { + void requireThatSchemesAreOrdered() { assertCompareLt("b://host:69/path", - "a://host:69/path"); + "a://host:69/path"); } @Test - public void requireThatSchemeOrdersBeforeHost() { + void requireThatSchemeOrdersBeforeHost() { assertCompareLt("b://*:69/path", - "a://host:69/path"); + "a://host:69/path"); } @Test - public void requireThatHostsAreOrdered() { + void requireThatHostsAreOrdered() { assertCompareLt("scheme://b:69/path", - "scheme://a:69/path"); + "scheme://a:69/path"); } @Test - public void requireThatHostOrdersBeforePath() { + void requireThatHostOrdersBeforePath() { assertCompareLt("scheme://b:69/*", - "scheme://a:69/path"); + "scheme://a:69/path"); } @Test - public void requireThatPortsAreOrdered() { + void requireThatPortsAreOrdered() { for (int i = 1; i < 69; ++i) { assertCompareEq("scheme://host:" + i + "/path", - "scheme://host:" + i + "/path"); + "scheme://host:" + i + "/path"); assertCompareLt("scheme://host:" + (i + 1) + "/path", - "scheme://host:" + i + "/path"); + "scheme://host:" + i + "/path"); assertCompareLt("scheme://host:" + i + "/path", - "scheme://host:*/path"); + "scheme://host:*/path"); } } @Test - public void requireThatPathsAreOrdered() { + void requireThatPathsAreOrdered() { assertCompareLt("scheme://host:69/b", - "scheme://host:69/a"); + "scheme://host:69/a"); } @Test - public void requireThatPathOrdersBeforePort() { + void requireThatPathOrdersBeforePort() { assertCompareLt("scheme://host:*/b", - "scheme://host:69/a"); + "scheme://host:69/a"); } @Test - public void requireThatEqualPatternsOrderEqual() { + void requireThatEqualPatternsOrderEqual() { assertCompareEq("scheme://host:69/path", - "scheme://host:69/path"); + "scheme://host:69/path"); assertCompareEq("*://host:69/path", - "*://host:69/path"); + "*://host:69/path"); assertCompareEq("scheme://*:69/path", - "scheme://*:69/path"); + "scheme://*:69/path"); assertCompareEq("scheme://host:*/path", - "scheme://host:*/path"); + "scheme://host:*/path"); assertCompareEq("scheme://host:69/*", - "scheme://host:69/*"); + "scheme://host:69/*"); } @Test - public void requireThatStrictPatternsOrderBeforeWildcards() { + void requireThatStrictPatternsOrderBeforeWildcards() { assertCompareLt("scheme://host:69/path", - "*://host:69/path"); + "*://host:69/path"); assertCompareLt("scheme://a:69/path", - "scheme://*:69/path"); + "scheme://*:69/path"); assertCompareLt("scheme://a:69/path", - "scheme://*a:69/path"); + "scheme://*a:69/path"); assertCompareLt("scheme://*aa:69/path", - "scheme://*a:69/path"); + "scheme://*a:69/path"); assertCompareLt("scheme://host:69/path", - "scheme://host:*/path"); + "scheme://host:*/path"); assertCompareLt("scheme://host:69/a", - "scheme://host:69/*"); + "scheme://host:69/*"); assertCompareLt("scheme://host:69/a", - "scheme://host:69/a*"); + "scheme://host:69/a*"); assertCompareLt("scheme://host:69/aa*", - "scheme://host:69/a*"); + "scheme://host:69/a*"); assertCompareLt("scheme://*:69/path", - "*://host:69/path"); + "*://host:69/path"); assertCompareLt("scheme://host:*/path", - "scheme://*:69/path"); + "scheme://*:69/path"); assertCompareLt("scheme://host:*/path", - "scheme://host:69/*"); + "scheme://host:69/*"); assertCompareLt("scheme://host:69/foo", - "scheme://host:69/*"); + "scheme://host:69/*"); assertCompareLt("scheme://host:69/foo/bar", - "scheme://host:69/foo/*"); + "scheme://host:69/foo/*"); assertCompareLt("scheme://host:69/foo/bar/baz", - "scheme://host:69/foo/bar/*"); + "scheme://host:69/foo/bar/*"); } @Test - public void requireThatLongPatternsOrderBeforeShort() { + void requireThatLongPatternsOrderBeforeShort() { assertCompareLt("scheme://host:69/foo/bar", - "scheme://host:69/foo"); + "scheme://host:69/foo"); assertCompareLt("scheme://host:69/foo/bar/baz", - "scheme://host:69/foo/bar"); + "scheme://host:69/foo/bar"); } @Test - public void requireThatHttpsSchemeIsHandledAsHttp() { + void requireThatHttpsSchemeIsHandledAsHttp() { UriPattern httpPattern = new UriPattern("http://host:80/path"); assertMatch(httpPattern, "https://host:80/path", NO_GROUPS); @@ -258,7 +258,7 @@ public class UriPatternTestCase { } @Test - public void requireThatUrlEncodingIsNotDoneForPath() { + void requireThatUrlEncodingIsNotDoneForPath() { UriPattern encodedSlashPattern = new UriPattern("http://host:80/one%2Fpath"); assertMatch(encodedSlashPattern, "http://host:80/one%2Fpath", NO_GROUPS); assertNotMatch(encodedSlashPattern, "http://host:80/one/path"); @@ -304,7 +304,7 @@ public class UriPatternTestCase { assertTrue(rhsCmp < 0); return 1; } - assertTrue(rhsCmp == 0); + assertEquals(rhsCmp, 0); return 0; } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/BindingMatchingTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/BindingMatchingTestCase.java index d6f49c6a038..9dfe0ece0be 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/BindingMatchingTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/BindingMatchingTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.jdisc.benchmark; import com.yahoo.jdisc.application.BindingRepository; import com.yahoo.jdisc.application.BindingSet; import com.yahoo.jdisc.application.UriPattern; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; @@ -33,7 +33,7 @@ public class BindingMatchingTestCase { private static final ExecutorService executor = Executors.newFixedThreadPool(MAX_THREADS); @Test - public void runThroughtputMeasurements() throws Exception { + void runThroughtputMeasurements() throws Exception { System.err.format("%15s%15s%15s%15s%15s%15s%15s%15s\n", "No. of Bindings", "1 thread", "2 thread", "4 thread", "8 thread", "16 thread", "32 thread", "64 thread"); for (int numBindings : Arrays.asList(1, 10, 25, 50, 100, 250)) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/LatencyTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/LatencyTestCase.java index 0ac453d2502..131b4187c2a 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/LatencyTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/LatencyTestCase.java @@ -10,14 +10,14 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; import java.util.Random; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Simon Thoresen Hult @@ -27,7 +27,7 @@ public class LatencyTestCase { private static final int NUM_REQUESTS = 100; @Test - public void runLatencyMeasurements() { + void runLatencyMeasurements() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); MyRequestHandler foo = new MyRequestHandler("foo"); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/ThroughputTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/ThroughputTestCase.java index 23d94114a38..8e369b0aba6 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/ThroughputTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/ThroughputTestCase.java @@ -13,7 +13,7 @@ import com.yahoo.jdisc.handler.ResponseDispatch; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.Iterator; @@ -26,7 +26,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Simon Thoresen Hult @@ -45,7 +45,7 @@ public class ThroughputTestCase { private static long preventOptimization = 0; @Test - public void runUnthreadedMeasurementsWithWorkload() throws Exception { + void runUnthreadedMeasurementsWithWorkload() throws Exception { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); runMeasurements(driver, new UnthreadedHandler(MAX_LOOPS)); // warmup @@ -75,7 +75,7 @@ public class ThroughputTestCase { } @Test - public void runThreadedMeasurements() throws Exception { + void runThreadedMeasurements() throws Exception { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); runMeasurements(driver, new ThreadedHandler()); // warmup diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/UriMatchingTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/UriMatchingTestCase.java index e822bd20536..e20d2b6ff5e 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/UriMatchingTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/benchmark/UriMatchingTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.jdisc.benchmark; import com.yahoo.jdisc.application.UriPattern; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; @@ -19,7 +19,7 @@ public class UriMatchingTestCase { private static long preventOptimization = 0; @Test - public void requireThatUriPatternMatchingIsFast() { + void requireThatUriPatternMatchingIsFast() { List<String> inputs = Arrays.asList( "other://host/", "scheme://other/", diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/client/AbstractClientApplicationTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/client/AbstractClientApplicationTestCase.java index 5534a97a10c..3362726ddc7 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/client/AbstractClientApplicationTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/client/AbstractClientApplicationTestCase.java @@ -6,7 +6,7 @@ import com.google.inject.Inject; import com.yahoo.jdisc.application.BundleInstaller; import com.yahoo.jdisc.application.ContainerActivator; import com.yahoo.jdisc.service.CurrentContainer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; @@ -16,8 +16,8 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -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 Simon Thoresen Hult @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; public class AbstractClientApplicationTestCase { @Test - public void requireThatApplicationCanBeShutdown() throws Exception { + void requireThatApplicationCanBeShutdown() throws Exception { MyDriver driver = newDriver(); assertFalse(driver.awaitDone(100, TimeUnit.MILLISECONDS)); assertTrue(driver.awaitApp(600, TimeUnit.SECONDS)); @@ -35,7 +35,7 @@ public class AbstractClientApplicationTestCase { } @Test - public void requireThatShutdownCanBeWaitedForWithTimeout() throws Exception { + void requireThatShutdownCanBeWaitedForWithTimeout() throws Exception { final MyDriver driver = newDriver(); assertFalse(driver.awaitDone(100, TimeUnit.MILLISECONDS)); assertTrue(driver.awaitApp(600, TimeUnit.SECONDS)); @@ -57,7 +57,7 @@ public class AbstractClientApplicationTestCase { } @Test - public void requireThatShutdownCanBeWaitedForWithoutTimeout() throws Exception { + void requireThatShutdownCanBeWaitedForWithoutTimeout() throws Exception { final MyDriver driver = newDriver(); assertFalse(driver.awaitDone(100, TimeUnit.MILLISECONDS)); assertTrue(driver.awaitApp(600, TimeUnit.SECONDS)); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/client/ClientDriverTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/client/ClientDriverTestCase.java index cd7d5552287..159d8ef8f44 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/client/ClientDriverTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/client/ClientDriverTestCase.java @@ -3,9 +3,9 @@ package com.yahoo.jdisc.client; import com.google.inject.AbstractModule; import com.google.inject.Inject; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -14,14 +14,14 @@ import static org.junit.Assert.assertEquals; public class ClientDriverTestCase { @Test - public void requireThatApplicationInstanceInjectionWorks() throws Exception { + void requireThatApplicationInstanceInjectionWorks() throws Exception { MyModule module = new MyModule(); ClientDriver.runApplication(new MyApplication(module)); assertEquals(5, module.state); } @Test - public void requireThatApplicationClassInjectionWorks() throws Exception { + void requireThatApplicationClassInjectionWorks() throws Exception { MyModule module = new MyModule(); ClientDriver.runApplication(MyApplication.class, module); assertEquals(5, module.state); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerTestCase.java index cf1fa62b102..4232b6ed087 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ActiveContainerTestCase.java @@ -14,12 +14,13 @@ import com.yahoo.jdisc.test.TestDriver; import java.util.Iterator; import java.util.Map; -import org.junit.Test; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Simon Thoresen Hult @@ -27,7 +28,7 @@ import static org.junit.Assert.assertSame; public class ActiveContainerTestCase { @Test - public void requireThatGuiceAccessorWorks() { + void requireThatGuiceAccessorWorks() { final Object obj = new Object(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { @@ -42,7 +43,7 @@ public class ActiveContainerTestCase { } @Test - public void requireThatServerAccessorWorks() { + void requireThatServerAccessorWorks() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); ServerProvider foo = new NonWorkingServerProvider(); @@ -61,7 +62,7 @@ public class ActiveContainerTestCase { } @Test - public void requireThatServerBindingAccessorWorks() { + void requireThatServerBindingAccessorWorks() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); RequestHandler foo = new NonWorkingRequestHandler(); @@ -103,7 +104,7 @@ public class ActiveContainerTestCase { } @Test - public void requireThatClientBindingAccessorWorks() { + void requireThatClientBindingAccessorWorks() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); RequestHandler foo = new NonWorkingRequestHandler(); @@ -145,7 +146,7 @@ public class ActiveContainerTestCase { } @Test - public void requireThatDefaultBindingsAreAlwaysCreated() { + void requireThatDefaultBindingsAreAlwaysCreated() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); ActiveContainer container = new ActiveContainer(builder); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationConfigModuleTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationConfigModuleTestCase.java index d17c5b183d8..8a1d155df2c 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationConfigModuleTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationConfigModuleTestCase.java @@ -15,9 +15,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.junit.Test; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -25,7 +26,7 @@ import static org.junit.Assert.assertEquals; public class ApplicationConfigModuleTestCase { @Test - public void requireThatEntriesAreBoundWithLowerCaseKeys() { + void requireThatEntriesAreBoundWithLowerCaseKeys() { Map<String, String> config = new HashMap<>(); config.put("foo_key", "foo"); config.put("BAR_key", "bar"); @@ -38,7 +39,7 @@ public class ApplicationConfigModuleTestCase { } @Test - public void requireThatEntriesAreBoundWithUnmodifiedValue() { + void requireThatEntriesAreBoundWithUnmodifiedValue() { Map<String, String> config = new HashMap<>(); config.put("foo", "foo_val"); config.put("bar", "BAR_val"); @@ -51,7 +52,7 @@ public class ApplicationConfigModuleTestCase { } @Test - public void requireThatUpperCaseKeysPrecedeLowerCaseKeys() { + void requireThatUpperCaseKeysPrecedeLowerCaseKeys() { Map<String, String> config = new HashMap<>(); config.put("foo", "lower-case"); assertBinding(config, "foo", "lower-case"); @@ -67,7 +68,7 @@ public class ApplicationConfigModuleTestCase { } @Test - public void requireThatNullFileNameThrowsException() throws IOException { + void requireThatNullFileNameThrowsException() throws IOException { try { ApplicationConfigModule.newInstanceFromFile(null); fail(); @@ -77,7 +78,7 @@ public class ApplicationConfigModuleTestCase { } @Test - public void requireThatFileNotFoundThrowsException() throws IOException { + void requireThatFileNotFoundThrowsException() throws IOException { try { ApplicationConfigModule.newInstanceFromFile("/file/not/found"); fail(); @@ -87,7 +88,7 @@ public class ApplicationConfigModuleTestCase { } @Test - public void requireThatPropertieFilesCanBeRead() throws IOException { + void requireThatPropertieFilesCanBeRead() throws IOException { Properties props = new Properties(); props.put("foo_key", "foo_val"); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java index 3bd60832ca3..87a0d4d0e18 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationEnvironmentModuleTestCase.java @@ -10,7 +10,7 @@ import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.application.OsgiFramework; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.NonWorkingOsgiFramework; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.LinkedList; import java.util.List; @@ -18,8 +18,8 @@ import java.util.Map; import java.util.concurrent.ThreadFactory; import static java.util.Collections.emptyList; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Simon Thoresen Hult @@ -27,7 +27,7 @@ import static org.junit.Assert.assertTrue; public class ApplicationEnvironmentModuleTestCase { @Test - public void requireThatBindingsExist() { + void requireThatBindingsExist() { List<Class<?>> expected = new LinkedList<>(); expected.add(ContainerActivator.class); expected.add(ContainerBuilder.class); @@ -49,10 +49,10 @@ public class ApplicationEnvironmentModuleTestCase { } @Test - public void requireThatContainerBuilderCanBeInjected() { + void requireThatContainerBuilderCanBeInjected() { ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), emptyList()); assertNotNull(new ApplicationEnvironmentModule(loader).containerBuilder()); assertNotNull(Guice.createInjector(new ApplicationEnvironmentModule(loader)) - .getInstance(ContainerBuilder.class)); + .getInstance(ContainerBuilder.class)); } } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationLoaderTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationLoaderTestCase.java index e5d335beb38..301f0fc571e 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationLoaderTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationLoaderTestCase.java @@ -16,7 +16,7 @@ import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.NonWorkingOsgiFramework; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.BundleContext; import java.nio.ByteBuffer; @@ -27,12 +27,12 @@ import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -41,9 +41,9 @@ import static org.junit.Assert.fail; public class ApplicationLoaderTestCase { @Test - public void requireThatStartFailsWithoutApplication() throws Exception { + void requireThatStartFailsWithoutApplication() throws Exception { ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), - Collections.<Module>emptyList()); + Collections.<Module>emptyList()); try { loader.init(null, false); loader.start(); @@ -54,25 +54,25 @@ public class ApplicationLoaderTestCase { } @Test - public void requireThatStopDoesNotFailWithoutStart() throws Exception { + void requireThatStopDoesNotFailWithoutStart() throws Exception { ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), - Collections.<Module>emptyList()); + Collections.<Module>emptyList()); loader.stop(); loader.destroy(); } @Test - public void requireThatDestroyDoesNotFailWithActiveContainer() throws Exception { + void requireThatDestroyDoesNotFailWithActiveContainer() throws Exception { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); assertNull(driver.activateContainer(driver.newContainerBuilder())); assertTrue(driver.close()); } @Test - public void requireThatApplicationStartExceptionUnsetsAndDestroysApplication() throws Exception { + void requireThatApplicationStartExceptionUnsetsAndDestroysApplication() throws Exception { MyApplication app = MyApplication.newStartException(); ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), - Arrays.asList(new MyApplicationModule(app))); + Arrays.asList(new MyApplicationModule(app))); loader.init(null, false); try { loader.start(); @@ -94,10 +94,10 @@ public class ApplicationLoaderTestCase { } @Test - public void requireThatApplicationStopExceptionDestroysApplication() throws Exception { + void requireThatApplicationStopExceptionDestroysApplication() throws Exception { MyApplication app = MyApplication.newStopException(); ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), - Arrays.asList(new MyApplicationModule(app))); + Arrays.asList(new MyApplicationModule(app))); loader.init(null, false); loader.start(); try { @@ -110,7 +110,7 @@ public class ApplicationLoaderTestCase { } @Test - public void requireThatApplicationDestroyIsCalledAfterContainerTermination() throws InterruptedException { + void requireThatApplicationDestroyIsCalledAfterContainerTermination() throws InterruptedException { MyApplication app = MyApplication.newInstance(); TestDriver driver = TestDriver.newInjectedApplicationInstance(app); ContainerBuilder builder = driver.newContainerBuilder(); @@ -125,7 +125,7 @@ public class ApplicationLoaderTestCase { } @Test - public void requireThatContainerActivatorReturnsPrev() throws Exception { + void requireThatContainerActivatorReturnsPrev() throws Exception { TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.newInstance()); assertNull(driver.activateContainer(driver.newContainerBuilder())); assertNotNull(driver.activateContainer(null)); @@ -133,7 +133,7 @@ public class ApplicationLoaderTestCase { } @Test - public void requireThatOsgiServicesAreRegistered() { + void requireThatOsgiServicesAreRegistered() { TestDriver driver = TestDriver.newSimpleApplicationInstance(); BundleContext ctx = driver.osgiFramework().bundleContext(); Object service = ctx.getService(ctx.getServiceReference(CurrentContainer.class.getName())); @@ -142,7 +142,7 @@ public class ApplicationLoaderTestCase { } @Test - public void requireThatThreadFactoryCanBeBound() { + void requireThatThreadFactoryCanBeBound() { final ThreadFactory factory = Executors.defaultThreadFactory(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationRestartTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationRestartTestCase.java index 941067ff27d..cf283fa3ae3 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationRestartTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationRestartTestCase.java @@ -11,7 +11,7 @@ import com.yahoo.jdisc.handler.CompletionHandler; import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.test.NonWorkingOsgiFramework; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; @@ -19,8 +19,8 @@ import java.util.Arrays; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -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; /** @@ -29,7 +29,7 @@ import static org.junit.Assert.assertTrue; public class ApplicationRestartTestCase { @Test - public void requireThatStopStartDoesNotBreakShutdown() throws Exception { + void requireThatStopStartDoesNotBreakShutdown() throws Exception { ApplicationLoader loader = newApplicationLoader(); loader.init(null, false); loader.start(); @@ -40,7 +40,7 @@ public class ApplicationRestartTestCase { } @Test - public void requireThatDestroyInitDoesNotBreakShutdown() throws Exception { + void requireThatDestroyInitDoesNotBreakShutdown() throws Exception { ApplicationLoader loader = newApplicationLoader(); loader.init(null, false); loader.start(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationShutdownTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationShutdownTestCase.java index 3f906263867..fb88f5567e7 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationShutdownTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ApplicationShutdownTestCase.java @@ -10,14 +10,14 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.TimeUnit; -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 Simon Thoresen Hult @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; public class ApplicationShutdownTestCase { @Test - public void requireThatStopWaitsForPreviousContainer() throws Exception { + void requireThatStopWaitsForPreviousContainer() throws Exception { Context ctx = new Context(); MyRequestHandler requestHandler = new MyRequestHandler(); ctx.activateContainer(requestHandler); @@ -38,7 +38,7 @@ public class ApplicationShutdownTestCase { } @Test - public void requireThatStopWaitsForAllPreviousContainers() { + void requireThatStopWaitsForAllPreviousContainers() { Context ctx = new Context(); MyRequestHandler requestHandlerA = new MyRequestHandler(); ctx.activateContainer(requestHandlerA); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/BundleLocationResolverTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/BundleLocationResolverTestCase.java index 86f7f5875a7..f65fb849836 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/BundleLocationResolverTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/BundleLocationResolverTestCase.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.jdisc.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.IOException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Simon Thoresen Hult @@ -14,13 +14,13 @@ import static org.junit.Assert.assertEquals; public class BundleLocationResolverTestCase { @Test - public void requireThatDollarsAreIncludedInLocation() { + void requireThatDollarsAreIncludedInLocation() { assertLocation("scheme:$foo", "scheme:$foo"); assertLocation("scheme:foo$bar", "scheme:foo$bar"); } @Test - public void requireThatCurlyBracesAreIncludedInLocation() { + void requireThatCurlyBracesAreIncludedInLocation() { assertLocation("scheme:{foo", "scheme:{foo"); assertLocation("scheme:foo{", "scheme:foo{"); assertLocation("scheme:foo{bar", "scheme:foo{bar"); @@ -32,14 +32,14 @@ public class BundleLocationResolverTestCase { } @Test - public void requireThatUnterminatedPropertiesAreIncludedInLocation() { + void requireThatUnterminatedPropertiesAreIncludedInLocation() { assertLocation("scheme:${foo", "scheme:${foo"); assertLocation("scheme:foo${", "scheme:foo${"); assertLocation("scheme:foo${bar", "scheme:foo${bar"); } @Test - public void requireThatAllSystemPropertiesAreExpanded() throws IOException { + void requireThatAllSystemPropertiesAreExpanded() throws IOException { assertCanonicalPath("", "${foo}"); assertCanonicalPath("barcox", "${foo}bar${baz}cox"); assertCanonicalPath("foobaz", "foo${bar}baz${cox}"); @@ -50,18 +50,18 @@ public class BundleLocationResolverTestCase { System.setProperty("requireThatAllSystemPropertiesAreExpanded.cox", "COX"); assertCanonicalPath("FOO", "${requireThatAllSystemPropertiesAreExpanded.foo}"); assertCanonicalPath("FOObarBAZcox", "${requireThatAllSystemPropertiesAreExpanded.foo}bar" + - "${requireThatAllSystemPropertiesAreExpanded.baz}cox"); + "${requireThatAllSystemPropertiesAreExpanded.baz}cox"); assertCanonicalPath("fooBARbazCOX", "foo${requireThatAllSystemPropertiesAreExpanded.bar}" + - "baz${requireThatAllSystemPropertiesAreExpanded.cox}"); + "baz${requireThatAllSystemPropertiesAreExpanded.cox}"); } @Test - public void requireThatUnschemedLocationsAreExpandedToBundleLocationProperty() throws IOException { + void requireThatUnschemedLocationsAreExpandedToBundleLocationProperty() throws IOException { assertCanonicalPath(BundleLocationResolver.BUNDLE_PATH + "foo", "foo"); } @Test - public void requireThatFileSchemedLocationsAreCanonicalized() throws IOException { + void requireThatFileSchemedLocationsAreCanonicalized() throws IOException { assertCanonicalPath("", "file:"); assertCanonicalPath("foo", "file:foo"); assertCanonicalPath("foo", "file:./foo"); @@ -71,7 +71,7 @@ public class BundleLocationResolverTestCase { } @Test - public void requireThatOtherSchemedLocationsAreUntouched() { + void requireThatOtherSchemedLocationsAreUntouched() { assertLocation("foo:", "foo:"); assertLocation("foo:bar", "foo:bar"); assertLocation("foo:bar/baz", "foo:bar/baz"); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogFormatterTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogFormatterTestCase.java index f8a982d02cf..64130ddc125 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogFormatterTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogFormatterTestCase.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.jdisc.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.osgi.framework.Bundle; import org.osgi.framework.ServiceReference; @@ -13,7 +13,7 @@ import java.io.StringWriter; import java.io.Writer; import java.time.Instant; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -27,178 +27,178 @@ public class ConsoleLogFormatterTestCase { // TODO: Should (at least) use ConsoleLogFormatter.ABSENCE_REPLACEMENT instead of literal '-'. See ticket 7128315. @Test - public void requireThatMillisecondsArePadded() { + void requireThatMillisecondsArePadded() { for (int i = 0; i < 10000; ++i) { LogEntry entry = new MyEntry(i, 0, null); Instant instant = Instant.ofEpochMilli(i); assertEquals(String.format("%d.%06d\t-\t-\t-\t-\tunknown\t", instant.getEpochSecond(), instant.getNano() / 1000), - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } } @Test - public void requireThatHostNameIsIncluded() { + void requireThatHostNameIsIncluded() { assertEquals("0.000000\thostName\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter("hostName", null, null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter("hostName", null, null).formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatHostNameIsOptional() { + void requireThatHostNameIsOptional() { assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, null, null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, null, null).formatEntry(SIMPLE_ENTRY)); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter("", null, null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter("", null, null).formatEntry(SIMPLE_ENTRY)); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(" ", null, null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(" ", null, null).formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatProcessIdIsIncluded() { + void requireThatProcessIdIsIncluded() { assertEquals("0.000000\t-\tprocessId\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, "processId", null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, "processId", null).formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatProcessIdIsOptional() { + void requireThatProcessIdIsOptional() { assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, null, null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, null, null).formatEntry(SIMPLE_ENTRY)); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, "", null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, "", null).formatEntry(SIMPLE_ENTRY)); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, " ", null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, " ", null).formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatProcessIdIncludesThreadIdWhenAvailable() { + void requireThatProcessIdIncludesThreadIdWhenAvailable() { LogEntry entry = new MyEntry(0, 0, null).putProperty("THREAD_ID", "threadId"); assertEquals("0.000000\t-\tprocessId/threadId\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, "processId", null).formatEntry(entry)); + new ConsoleLogFormatter(null, "processId", null).formatEntry(entry)); } @Test - public void requireThatServiceNameIsIncluded() { + void requireThatServiceNameIsIncluded() { assertEquals("0.000000\t-\t-\tserviceName\t-\tunknown\t", - new ConsoleLogFormatter(null, null, "serviceName").formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, null, "serviceName").formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatServiceNameIsOptional() { + void requireThatServiceNameIsOptional() { assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, null, null).formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, null, null).formatEntry(SIMPLE_ENTRY)); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, null, "").formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, null, "").formatEntry(SIMPLE_ENTRY)); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - new ConsoleLogFormatter(null, null, " ").formatEntry(SIMPLE_ENTRY)); + new ConsoleLogFormatter(null, null, " ").formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatBundleNameIsIncluded() { + void requireThatBundleNameIsIncluded() { LogEntry entry = new MyEntry(0, 0, null).setBundleSymbolicName("bundleName"); assertEquals("0.000000\t-\t-\t-\tbundleName\tunknown\t", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatBundleNameIsOptional() { + void requireThatBundleNameIsOptional() { assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - SIMPLE_FORMATTER.formatEntry(SIMPLE_ENTRY)); + SIMPLE_FORMATTER.formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatLoggerNameIsIncluded() { + void requireThatLoggerNameIsIncluded() { LogEntry entry = new MyEntry(0, 0, null).putProperty("LOGGER_NAME", "loggerName"); assertEquals("0.000000\t-\t-\t-\t/loggerName\tunknown\t", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatLoggerNameIsOptional() { + void requireThatLoggerNameIsOptional() { assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - SIMPLE_FORMATTER.formatEntry(SIMPLE_ENTRY)); + SIMPLE_FORMATTER.formatEntry(SIMPLE_ENTRY)); } @Test - public void requireThatBundleAndLoggerNameIsCombined() { + void requireThatBundleAndLoggerNameIsCombined() { LogEntry entry = new MyEntry(0, 0, null).setBundleSymbolicName("bundleName") - .putProperty("LOGGER_NAME", "loggerName"); + .putProperty("LOGGER_NAME", "loggerName"); assertEquals("0.000000\t-\t-\t-\tbundleName/loggerName\tunknown\t", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatLevelNameIsIncluded() { + void requireThatLevelNameIsIncluded() { ConsoleLogFormatter formatter = SIMPLE_FORMATTER; assertEquals("0.000000\t-\t-\t-\t-\terror\t", - formatter.formatEntry(new MyEntry(0, LogService.LOG_ERROR, null))); + formatter.formatEntry(new MyEntry(0, LogService.LOG_ERROR, null))); assertEquals("0.000000\t-\t-\t-\t-\twarning\t", - formatter.formatEntry(new MyEntry(0, LogService.LOG_WARNING, null))); + formatter.formatEntry(new MyEntry(0, LogService.LOG_WARNING, null))); assertEquals("0.000000\t-\t-\t-\t-\tinfo\t", - formatter.formatEntry(new MyEntry(0, LogService.LOG_INFO, null))); + formatter.formatEntry(new MyEntry(0, LogService.LOG_INFO, null))); assertEquals("0.000000\t-\t-\t-\t-\tdebug\t", - formatter.formatEntry(new MyEntry(0, LogService.LOG_DEBUG, null))); + formatter.formatEntry(new MyEntry(0, LogService.LOG_DEBUG, null))); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - formatter.formatEntry(new MyEntry(0, 69, null))); + formatter.formatEntry(new MyEntry(0, 69, null))); } @Test - public void requireThatMessageIsIncluded() { + void requireThatMessageIsIncluded() { LogEntry entry = new MyEntry(0, 0, "message"); assertEquals("0.000000\t-\t-\t-\t-\tunknown\tmessage", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatMessageIsOptional() { + void requireThatMessageIsOptional() { LogEntry entry = new MyEntry(0, 0, null); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatMessageIsEscaped() { + void requireThatMessageIsEscaped() { LogEntry entry = new MyEntry(0, 0, "\\\n\r\t"); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t\\\\\\n\\r\\t", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatExceptionIsIncluded() { + void requireThatExceptionIsIncluded() { Throwable t = new Throwable(); LogEntry entry = new MyEntry(0, 0, null).setException(t); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t\\n" + formatThrowable(t), - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatExceptionIsEscaped() { + void requireThatExceptionIsEscaped() { Throwable t = new Throwable("\\\n\r\t"); LogEntry entry = new MyEntry(0, 0, null).setException(t); assertEquals("0.000000\t-\t-\t-\t-\tunknown\t\\n" + formatThrowable(t), - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatExceptionIsSimplifiedForInfoEntries() { + void requireThatExceptionIsSimplifiedForInfoEntries() { Throwable t = new Throwable("exception"); LogEntry entry = new MyEntry(0, LogService.LOG_INFO, "entry").setException(t); assertEquals("0.000000\t-\t-\t-\t-\tinfo\tentry: exception", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatSimplifiedExceptionIsEscaped() { + void requireThatSimplifiedExceptionIsEscaped() { Throwable t = new Throwable("\\\n\r\t"); LogEntry entry = new MyEntry(0, LogService.LOG_INFO, "entry").setException(t); assertEquals("0.000000\t-\t-\t-\t-\tinfo\tentry: \\\\\\n\\r\\t", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } @Test - public void requireThatSimplifiedExceptionMessageIsOptional() { + void requireThatSimplifiedExceptionMessageIsOptional() { Throwable t = new Throwable(); LogEntry entry = new MyEntry(0, LogService.LOG_INFO, "entry").setException(t); assertEquals("0.000000\t-\t-\t-\t-\tinfo\tentry: java.lang.Throwable", - SIMPLE_FORMATTER.formatEntry(entry)); + SIMPLE_FORMATTER.formatEntry(entry)); } private static String formatThrowable(Throwable t) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogListenerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogListenerTestCase.java index 5f7f7e733fa..0efefc21a2f 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogListenerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogListenerTestCase.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.jdisc.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.Bundle; import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogEntry; @@ -11,7 +11,7 @@ import org.osgi.service.log.LogService; import java.io.ByteArrayOutputStream; import java.io.PrintStream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Vikas Panwar @@ -22,7 +22,7 @@ public class ConsoleLogListenerTestCase { private static final String PROCESS_ID = ConsoleLogListener.getProcessId(); @Test - public void requireThatLogLevelParserKnowsOsgiLogLevels() { + void requireThatLogLevelParserKnowsOsgiLogLevels() { assertEquals(LogService.LOG_ERROR, ConsoleLogListener.parseLogLevel("ERROR")); assertEquals(LogService.LOG_WARNING, ConsoleLogListener.parseLogLevel("WARNING")); assertEquals(LogService.LOG_INFO, ConsoleLogListener.parseLogLevel("INFO")); @@ -30,31 +30,31 @@ public class ConsoleLogListenerTestCase { } @Test - public void requireThatLogLevelParserKnowsOff() { + void requireThatLogLevelParserKnowsOff() { assertEquals(Integer.MIN_VALUE, ConsoleLogListener.parseLogLevel("OFF")); } @Test - public void requireThatLogLevelParserKnowsAll() { + void requireThatLogLevelParserKnowsAll() { assertEquals(Integer.MAX_VALUE, ConsoleLogListener.parseLogLevel("ALL")); } @Test - public void requireThatLogLevelParserKnowsIntegers() { + void requireThatLogLevelParserKnowsIntegers() { for (int i = -69; i < 69; ++i) { assertEquals(i, ConsoleLogListener.parseLogLevel(String.valueOf(i))); } } @Test - public void requireThatLogLevelParserErrorsReturnDefault() { + void requireThatLogLevelParserErrorsReturnDefault() { assertEquals(ConsoleLogListener.DEFAULT_LOG_LEVEL, ConsoleLogListener.parseLogLevel(null)); assertEquals(ConsoleLogListener.DEFAULT_LOG_LEVEL, ConsoleLogListener.parseLogLevel("")); assertEquals(ConsoleLogListener.DEFAULT_LOG_LEVEL, ConsoleLogListener.parseLogLevel("foo")); } @Test - public void requireThatLogEntryWithLevelAboveThresholdIsNotOutput() { + void requireThatLogEntryWithLevelAboveThresholdIsNotOutput() { ByteArrayOutputStream out = new ByteArrayOutputStream(); LogListener listener = new ConsoleLogListener(new PrintStream(out), null, "5"); for (int i = 0; i < 10; ++i) { @@ -62,12 +62,12 @@ public class ConsoleLogListenerTestCase { } // TODO: Should use ConsoleLogFormatter.ABSENCE_REPLACEMENT instead of literal '-'. See ticket 7128315. assertEquals("0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\tunknown\tmessage\n" + - "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\terror\tmessage\n" + - "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\twarning\tmessage\n" + - "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\tinfo\tmessage\n" + - "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\tdebug\tmessage\n" + - "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\tunknown\tmessage\n", - out.toString()); + "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\terror\tmessage\n" + + "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\twarning\tmessage\n" + + "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\tinfo\tmessage\n" + + "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\tdebug\tmessage\n" + + "0.000000\t" + HOSTNAME + "\t" + PROCESS_ID + "\t-\t-\tunknown\tmessage\n", + out.toString()); } private static class MyEntry implements LogEntry { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogManagerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogManagerTestCase.java index 4172d6d907a..fb5ee147bd8 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogManagerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ConsoleLogManagerTestCase.java @@ -2,17 +2,17 @@ package com.yahoo.jdisc.core; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import org.osgi.service.log.LogListener; import org.osgi.service.log.LogReaderService; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -21,7 +21,7 @@ import static org.junit.Assert.fail; public class ConsoleLogManagerTestCase { @Test - public void requireThatManagerCanNotBeInstalledTwice() throws BundleException { + void requireThatManagerCanNotBeInstalledTwice() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.start(); @@ -38,7 +38,7 @@ public class ConsoleLogManagerTestCase { } @Test - public void requireThatManagerCanBeUninstalledTwice() throws BundleException { + void requireThatManagerCanBeUninstalledTwice() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.start(); @@ -52,7 +52,7 @@ public class ConsoleLogManagerTestCase { } @Test - public void requireThatLogReaderServicesAreTracked() throws BundleException { + void requireThatLogReaderServicesAreTracked() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.start(); BundleContext ctx = felix.bundleContext(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerResourceTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerResourceTestCase.java index a1610c81331..ca78bea85b4 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerResourceTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerResourceTestCase.java @@ -10,13 +10,13 @@ import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.ServerProvider; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.util.concurrent.atomic.AtomicInteger; -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; /** @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; public class ContainerResourceTestCase { @Test - public void requireThatBoundRequestHandlersAreRetainedOnActivate() { + void requireThatBoundRequestHandlersAreRetainedOnActivate() { MyRequestHandler foo = new MyRequestHandler(); MyRequestHandler bar = new MyRequestHandler(); @@ -43,7 +43,7 @@ public class ContainerResourceTestCase { } @Test - public void requireThatBoundRequestHandlersAreReleasedOnTermination() { + void requireThatBoundRequestHandlersAreReleasedOnTermination() { MyRequestHandler handler = new MyRequestHandler(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); @@ -62,7 +62,7 @@ public class ContainerResourceTestCase { } @Test - public void requireThatServerProvidersAreRetainedOnActivate() { + void requireThatServerProvidersAreRetainedOnActivate() { MyServerProvider foo = new MyServerProvider(); MyServerProvider bar = new MyServerProvider(); @@ -80,7 +80,7 @@ public class ContainerResourceTestCase { } @Test - public void requireThatServerProvidersAreReleasedOnTermination() { + void requireThatServerProvidersAreReleasedOnTermination() { MyServerProvider server = new MyServerProvider(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerShutdownTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerShutdownTestCase.java index cf247040c41..458ce3200fc 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerShutdownTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerShutdownTestCase.java @@ -11,14 +11,14 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -26,7 +26,7 @@ import static org.junit.Assert.fail; public class ContainerShutdownTestCase { @Test - public void requireThatContainerBlocksTermination() { + void requireThatContainerBlocksTermination() { Context ctx = Context.newInstance(); Container container = ctx.driver.newReference(URI.create("http://host/path")); assertFalse(ctx.shutdown()); @@ -36,7 +36,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatNewRequestBlocksTermination() { + void requireThatNewRequestBlocksTermination() { Context ctx = Context.newPendingRequest(MyRequestHandler.newInstance()); assertFalse(ctx.shutdown()); ctx.request.release(); @@ -45,7 +45,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatOpenRequestBlocksTermination() { + void requireThatOpenRequestBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -58,7 +58,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponsePendingBlocksTermination() { + void requireThatResponsePendingBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ctx.request.connect(MyResponseHandler.newEagerCompletion()).close(null); @@ -70,7 +70,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatOpenResponseBlocksTermination() { + void requireThatOpenResponseBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ctx.request.connect(MyResponseHandler.newEagerCompletion()).close(null); @@ -83,7 +83,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestExceptionDoesNotBlockTermination() { + void requireThatRequestExceptionDoesNotBlockTermination() { Context ctx = Context.newPendingRequest(MyRequestHandler.newRequestException()); try { ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -97,7 +97,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestExceptionWithEagerHandleResponseBlocksTermination() { + void requireThatRequestExceptionWithEagerHandleResponseBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newRequestExceptionWithEagerHandleResponse(); Context ctx = Context.newPendingRequest(requestHandler); try { @@ -114,7 +114,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestExceptionWithEagerCloseResponseDoesNotBlockTermination() { + void requireThatRequestExceptionWithEagerCloseResponseDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newRequestExceptionWithEagerCloseResponse(); Context ctx = Context.newPendingRequest(requestHandler); try { @@ -129,7 +129,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatNullRequestContentBlocksTermination() { + void requireThatNullRequestContentBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newNullContent(); Context ctx = Context.newPendingRequest(requestHandler); ctx.request.connect(MyResponseHandler.newEagerCompletion()).close(null); @@ -142,7 +142,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatNullRequestContentWithEagerHandleResponseBlocksTermination() { + void requireThatNullRequestContentWithEagerHandleResponseBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newNullContentWithEagerHandleResponse(); Context ctx = Context.newPendingRequest(requestHandler); ctx.request.connect(MyResponseHandler.newEagerCompletion()).close(null); @@ -154,7 +154,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatNullRequestContentWithEagerCloseResponseBlocksTermination() { + void requireThatNullRequestContentWithEagerCloseResponseBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newNulContentWithEagerCloseResponse(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -166,7 +166,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestContentWriteFailedDoesNotBlockTermination() { + void requireThatRequestContentWriteFailedDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerFail(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -179,7 +179,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestContentWriteExceptionDoesNotBlockTermination() { + void requireThatRequestContentWriteExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newContentWriteExceptionWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -197,7 +197,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestContentWriteExceptionDoesNotForceTermination() { + void requireThatRequestContentWriteExceptionDoesNotForceTermination() { MyRequestHandler requestHandler = MyRequestHandler.newContentWriteExceptionWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -216,7 +216,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestContentWriteExceptionWithCompletionDoesNotBlockTermination() { + void requireThatRequestContentWriteExceptionWithCompletionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newContentWriteExceptionWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -234,7 +234,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestContentCloseFailedDoesNotBlockTermination() { + void requireThatRequestContentCloseFailedDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerFail(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -246,7 +246,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestContentCloseExceptionDoesNotBlockTermination() { + void requireThatRequestContentCloseExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newContentCloseException(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -263,7 +263,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestContentCloseExceptionWithCompletionDoesNotBlockTermination() { + void requireThatRequestContentCloseExceptionWithCompletionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newContentCloseException(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -280,7 +280,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestWriteCompletionBlocksTermination() { + void requireThatRequestWriteCompletionBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCloseResponse(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -295,7 +295,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestWriteCompletionExceptionDoesNotBlockTermination() { + void requireThatRequestWriteCompletionExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCloseResponse(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -315,7 +315,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestCloseCompletionBlocksTermination() { + void requireThatRequestCloseCompletionBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCloseResponse(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -328,7 +328,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatRequestCloseCompletionExceptionDoesNotBlockTermination() { + void requireThatRequestCloseCompletionExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCloseResponse(); Context ctx = Context.newPendingRequest(requestHandler); ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion()); @@ -346,7 +346,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatNullResponseContentBlocksTermination() { + void requireThatNullResponseContentBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerRespondWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newNullContent(); @@ -360,7 +360,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseExceptionDoesNotBlockTermination() { + void requireThatResponseExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ctx.request.connect(MyResponseHandler.newResponseException()).close(null); @@ -376,7 +376,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseContentWriteFailedDoesNotBlockTermination() { + void requireThatResponseContentWriteFailedDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newEagerFail(); @@ -390,7 +390,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseContentCloseFailedDoesNotBlockTermination() { + void requireThatResponseContentCloseFailedDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newEagerFail(); @@ -403,7 +403,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseContentWriteExceptionDoesNotBlockTermination() { + void requireThatResponseContentWriteExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newContentWriteException(); @@ -423,7 +423,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseContentWriteExceptionDoesNotForceTermination() { + void requireThatResponseContentWriteExceptionDoesNotForceTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newContentWriteException(); @@ -444,7 +444,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseContentWriteExceptionWithCompletionDoesNotBlockTermination() { + void requireThatResponseContentWriteExceptionWithCompletionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newContentWriteException(); @@ -464,7 +464,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseContentCloseExceptionDoesNotBlockTermination() { + void requireThatResponseContentCloseExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ctx.request.connect(MyResponseHandler.newContentCloseException()).close(null); @@ -480,7 +480,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseContentCloseExceptionWithCompletionDoesNotBlockTermination() { + void requireThatResponseContentCloseExceptionWithCompletionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); ctx.request.connect(MyResponseHandler.newContentCloseException()).close(null); @@ -496,7 +496,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseWriteCompletionBlocksTermination() { + void requireThatResponseWriteCompletionBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerRespondWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newInstance(); @@ -513,7 +513,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseWriteCompletionExceptionDoesNotBlockTermination() { + void requireThatResponseWriteCompletionExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerRespondWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newInstance(); @@ -535,7 +535,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseCloseCompletionBlocksTermination() { + void requireThatResponseCloseCompletionBlocksTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerRespondWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newInstance(); @@ -550,7 +550,7 @@ public class ContainerShutdownTestCase { } @Test - public void requireThatResponseCloseCompletionExceptionDoesNotBlockTermination() { + void requireThatResponseCloseCompletionExceptionDoesNotBlockTermination() { MyRequestHandler requestHandler = MyRequestHandler.newEagerRespondWithEagerCompletion(); Context ctx = Context.newPendingRequest(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newInstance(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerSnapshotTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerSnapshotTestCase.java index dc1f3c7609e..2f93832b503 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerSnapshotTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerSnapshotTestCase.java @@ -11,16 +11,16 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -29,7 +29,7 @@ import static org.junit.Assert.assertTrue; public class ContainerSnapshotTestCase { @Test - public void requireThatServerHandlerCanBeResolved() { + void requireThatServerHandlerCanBeResolved() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.serverBindings().bind("http://foo/*", MyRequestHandler.newInstance()); @@ -59,7 +59,7 @@ public class ContainerSnapshotTestCase { } @Test - public void requireThatClientHandlerCanBeResolved() { + void requireThatClientHandlerCanBeResolved() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.clientBindings().bind("http://foo/*", MyRequestHandler.newInstance()); @@ -89,7 +89,7 @@ public class ContainerSnapshotTestCase { } @Test - public void requireThatClientBindingsAreUsed() { + void requireThatClientBindingsAreUsed() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.clientBindings().bind("http://host/path", MyRequestHandler.newInstance()); @@ -101,7 +101,7 @@ public class ContainerSnapshotTestCase { } @Test - public void requireThatBindingMatchIsSetByResolveHandler() { + void requireThatBindingMatchIsSetByResolveHandler() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.serverBindings().bind("http://*/*", MyRequestHandler.newInstance()); @@ -121,7 +121,7 @@ public class ContainerSnapshotTestCase { } @Test - public void requireThatNewRequestHasSameSnapshot() { + void requireThatNewRequestHasSameSnapshot() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); driver.activateContainer(driver.newContainerBuilder()); Request foo = new Request(driver, URI.create("http://host/foo")); @@ -133,7 +133,7 @@ public class ContainerSnapshotTestCase { } @Test - public void requireThatActiveInjectorIsUsed() { + void requireThatActiveInjectorIsUsed() { final Object obj = new Object(); TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerTerminationTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerTerminationTestCase.java index de22a49895f..110ea9745b6 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerTerminationTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerTerminationTestCase.java @@ -4,11 +4,11 @@ package com.yahoo.jdisc.core; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.application.DeactivatedContainer; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Simon Thoresen Hult @@ -16,14 +16,14 @@ import static org.junit.Assert.assertTrue; public class ContainerTerminationTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { Object obj = new Object(); ContainerTermination termination = new ContainerTermination(obj); assertSame(obj, termination.appContext()); } @Test - public void requireThatAppContextIsFromBuilder() { + void requireThatAppContextIsFromBuilder() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); Object obj = new Object(); @@ -35,7 +35,7 @@ public class ContainerTerminationTestCase { } @Test - public void requireThatEarlyTerminationIsNotified() { + void requireThatEarlyTerminationIsNotified() { ContainerTermination termination = new ContainerTermination(null); termination.run(); MyTask task = new MyTask(); @@ -44,7 +44,7 @@ public class ContainerTerminationTestCase { } @Test - public void requireThatLaterTerminationIsNotified() { + void requireThatLaterTerminationIsNotified() { ContainerTermination termination = new ContainerTermination(null); MyTask task = new MyTask(); termination.notifyTermination(task); @@ -54,7 +54,7 @@ public class ContainerTerminationTestCase { } @Test - public void requireThatNotifyCanOnlyBeCalledOnce() { + void requireThatNotifyCanOnlyBeCalledOnce() { ContainerTermination termination = new ContainerTermination(null); termination.notifyTermination(new MyTask()); try { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerWatchdogTest.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerWatchdogTest.java index e72b01d8b8f..d669961e728 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerWatchdogTest.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ContainerWatchdogTest.java @@ -4,14 +4,14 @@ package com.yahoo.jdisc.core; import com.yahoo.jdisc.Metric; import com.yahoo.jdisc.test.TestDriver; import com.yahoo.test.ManualClock; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.time.Duration; import java.time.Instant; import java.util.Map; import java.util.concurrent.ScheduledExecutorService; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; /** @@ -20,7 +20,7 @@ import static org.mockito.Mockito.mock; public class ContainerWatchdogTest { @Test - public void watchdog_counts_stale_container() { + void watchdog_counts_stale_container() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ManualClock clock = new ManualClock(Instant.EPOCH); DummyMetric metric = new DummyMetric(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/DefaultBindingSelectorTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/DefaultBindingSelectorTestCase.java index 66c92aa138a..50db994c4d3 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/DefaultBindingSelectorTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/DefaultBindingSelectorTestCase.java @@ -4,12 +4,12 @@ package com.yahoo.jdisc.core; import com.google.inject.Guice; import com.yahoo.jdisc.application.BindingSet; import com.yahoo.jdisc.application.BindingSetSelector; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -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; /** @@ -18,13 +18,13 @@ import static org.junit.Assert.assertTrue; public class DefaultBindingSelectorTestCase { @Test - public void requireThatClassIsInjectedByDefault() { + void requireThatClassIsInjectedByDefault() { BindingSetSelector selector = Guice.createInjector().getInstance(BindingSetSelector.class); assertTrue(selector instanceof DefaultBindingSelector); } @Test - public void requireThatDefaultSetIsAlwaysSelected() { + void requireThatDefaultSetIsAlwaysSelected() { DefaultBindingSelector selector = new DefaultBindingSelector(); assertEquals(BindingSet.DEFAULT, selector.select(null)); for (int i = 0; i < 69; ++i) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java index 1cd8db67476..e9aba0893f9 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ExportPackagesIT.java @@ -1,12 +1,12 @@ package com.yahoo.jdisc.core; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.nio.file.Paths; import java.util.Arrays; import java.util.List; import java.util.Properties; @@ -15,8 +15,8 @@ import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Integration tests for {@link ExportPackages}. @@ -49,22 +49,22 @@ public class ExportPackagesIT { "javax.activation.jar" ).map(f -> JAR_PATH + f).toList(); - @ClassRule - public static TemporaryFolder tempFolder = new TemporaryFolder(); + @TempDir + public static File tempFolder; @Test - public void exported_packages_are_not_changed_unintentionally() throws Exception { + void exported_packages_are_not_changed_unintentionally() throws Exception { Properties actualProperties = getPropertiesFromFile(createPropertiesFile()); String actualValue = actualProperties.getProperty(ExportPackages.EXPORT_PACKAGES); - assertNotNull("Missing exportPackages property in file.", actualValue); + assertNotNull(actualValue, "Missing exportPackages property in file."); Properties expectedProperties = getPropertiesFromFile(expectedExportPackages); String expectedValue = expectedProperties.getProperty(ExportPackages.EXPORT_PACKAGES); - assertNotNull("Missing exportPackages property in file.", expectedValue); + assertNotNull(expectedValue, "Missing exportPackages property in file."); Set<String> actualPackages = getPackages(actualValue); Set<String> expectedPackages = getPackages(expectedValue); - if (! actualPackages.equals(expectedPackages)) { + if (!actualPackages.equals(expectedPackages)) { StringBuilder message = getDiff(actualPackages, expectedPackages); message.append("\n\nIf this test fails due to an intentional change in exported packages, run the following command:\n") .append("$ cp jdisc_core/target/classes/exportPackages.properties jdisc_core/src/test/resources/") @@ -116,7 +116,7 @@ public class ExportPackagesIT { } private static File createPropertiesFile() throws IOException { - File file = tempFolder.newFile(ExportPackages.PROPERTIES_FILE); + File file = Paths.get(tempFolder.toString(), ExportPackages.PROPERTIES_FILE).toFile(); String[] args = Stream.concat(Stream.of(file.getAbsolutePath()), RE_EXPORTED_BUNDLES.stream()).toArray(String[]::new); ExportPackages.main(args); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixFrameworkTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixFrameworkTestCase.java index fb663afa23f..d1cb59dbc30 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixFrameworkTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixFrameworkTestCase.java @@ -2,10 +2,10 @@ package com.yahoo.jdisc.core; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.BundleException; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -14,20 +14,20 @@ import static org.junit.Assert.fail; public class FelixFrameworkTestCase { @Test - public void requireThatLifecycleWorks() throws BundleException { + void requireThatLifecycleWorks() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.start(); felix.stop(); } @Test - public void requireThatStopWithoutStartDoesNotThrowException() throws BundleException { + void requireThatStopWithoutStartDoesNotThrowException() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.stop(); } @Test - public void requireThatInstallCanThrowException() throws BundleException { + void requireThatInstallCanThrowException() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.start(); try { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixParamsTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixParamsTestCase.java index 490470b4fdf..6c488f8b735 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixParamsTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/FelixParamsTestCase.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.jdisc.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.Constants; import java.util.Arrays; @@ -9,9 +9,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Simon Thoresen Hult @@ -19,7 +19,7 @@ import static org.junit.Assert.assertTrue; public class FelixParamsTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { FelixParams params = new FelixParams(); params.setCachePath("foo"); assertEquals("foo", params.getCachePath()); @@ -28,7 +28,7 @@ public class FelixParamsTestCase { } @Test - public void requireThatSystemPackagesAreNotReplaced() { + void requireThatSystemPackagesAreNotReplaced() { String systemPackages = ExportPackages.getSystemPackages(); FelixParams params = new FelixParams(systemPackages); @@ -46,7 +46,7 @@ public class FelixParamsTestCase { } @Test - public void requireThatExportsAreIncludedInConfig() { + void requireThatExportsAreIncludedInConfig() { FelixParams params = new FelixParams(); Map<String, String> config = params.toConfig(); assertNotNull(config); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java index 7c07623814e..626cae67c41 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogHandlerTestCase.java @@ -1,12 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; import java.time.Instant; -import java.util.Arrays; import java.util.Enumeration; import java.util.ResourceBundle; import java.util.logging.Handler; @@ -14,11 +13,11 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * @author Simon Thoresen Hult @@ -26,7 +25,7 @@ import static org.junit.Assert.assertTrue; public class OsgiLogHandlerTestCase { @Test - public void requireThatLogRecordsArePublishedToLogService() { + void requireThatLogRecordsArePublishedToLogService() { MyLogService logService = new MyLogService(); Logger log = newLogger(logService); @@ -43,7 +42,7 @@ public class OsgiLogHandlerTestCase { } @Test - public void requireThatStadardLogLevelsAreConverted() { + void requireThatStadardLogLevelsAreConverted() { assertLogLevel(LogService.LOG_ERROR, Level.SEVERE); assertLogLevel(LogService.LOG_WARNING, Level.WARNING); assertLogLevel(LogService.LOG_INFO, Level.INFO); @@ -54,7 +53,7 @@ public class OsgiLogHandlerTestCase { } @Test - public void requireThatCustomLogLevelsAreConverted() { + void requireThatCustomLogLevelsAreConverted() { for (int i = Level.ALL.intValue() - 69; i < Level.OFF.intValue() + 69; ++i) { int expectedLevel; if (i >= Level.SEVERE.intValue()) { @@ -71,7 +70,7 @@ public class OsgiLogHandlerTestCase { } @Test - public void requireThatJdk14PropertiesAreAvailableThroughServiceReference() { + void requireThatJdk14PropertiesAreAvailableThroughServiceReference() { MyLogService logService = new MyLogService(); Logger log = newLogger(logService); @@ -93,19 +92,19 @@ public class OsgiLogHandlerTestCase { ServiceReference<?> ref = logService.lastServiceReference; assertNotNull(ref); - assertTrue(Arrays.equals(new String[] { "LEVEL", - "LOGGER_NAME", - "MESSAGE", - "MILLIS", - "PARAMETERS", - "RESOURCE_BUNDLE", - "RESOURCE_BUNDLE_NAME", - "SEQUENCE_NUMBER", - "SOURCE_CLASS_NAME", - "SOURCE_METHOD_NAME", - "THREAD_ID", - "THROWN" }, - ref.getPropertyKeys())); + assertArrayEquals(new String[]{"LEVEL", + "LOGGER_NAME", + "MESSAGE", + "MILLIS", + "PARAMETERS", + "RESOURCE_BUNDLE", + "RESOURCE_BUNDLE_NAME", + "SEQUENCE_NUMBER", + "SOURCE_CLASS_NAME", + "SOURCE_METHOD_NAME", + "THREAD_ID", + "THROWN"}, + ref.getPropertyKeys()); assertEquals(Level.INFO, ref.getProperty("LEVEL")); assertEquals("loggerName", ref.getProperty("LOGGER_NAME")); assertEquals("message", ref.getProperty("MESSAGE")); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogManagerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogManagerTestCase.java index be4c0ada514..7b5af97ca13 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogManagerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogManagerTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.jdisc.core; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; @@ -13,9 +13,9 @@ import org.osgi.service.log.LogService; import java.util.logging.Level; import java.util.logging.Logger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** @@ -24,7 +24,7 @@ import static org.junit.Assert.assertSame; public class OsgiLogManagerTestCase { @Test - public void requireThatAllLogMethodsAreImplemented() throws BundleException { + void requireThatAllLogMethodsAreImplemented() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.start(); @@ -55,7 +55,7 @@ public class OsgiLogManagerTestCase { } @Test - public void requireThatLogManagerWritesToAllRegisteredLogServices() throws BundleException { + void requireThatLogManagerWritesToAllRegisteredLogServices() throws BundleException { FelixFramework felix = TestDriver.newOsgiFramework(); felix.start(); @@ -122,7 +122,7 @@ public class OsgiLogManagerTestCase { } @Test - public void requireThatRootLoggerModificationCanBeDisabled() throws BundleException { + void requireThatRootLoggerModificationCanBeDisabled() throws BundleException { Logger logger = Logger.getLogger(""); logger.setLevel(Level.WARNING); @@ -134,7 +134,7 @@ public class OsgiLogManagerTestCase { } @Test - public void requireThatRootLoggerLevelIsModifiedIfNoLoggerConfigIsGiven() { + void requireThatRootLoggerLevelIsModifiedIfNoLoggerConfigIsGiven() { Logger logger = Logger.getLogger(""); logger.setLevel(Level.WARNING); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceTestCase.java index 15377d7ae37..bfdaad9450f 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/OsgiLogServiceTestCase.java @@ -3,15 +3,15 @@ package com.yahoo.jdisc.core; import com.yahoo.jdisc.application.OsgiFramework; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import org.osgi.service.log.LogReaderService; import org.osgi.service.log.LogService; import org.osgi.util.tracker.ServiceTracker; -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; /** @@ -20,12 +20,12 @@ import static org.junit.Assert.fail; public class OsgiLogServiceTestCase { @Test - public void requireThatLogServiceIsRegistered() throws BundleException, InterruptedException { + void requireThatLogServiceIsRegistered() throws BundleException, InterruptedException { OsgiFramework osgi = TestDriver.newOsgiFramework(); osgi.start(); - ServiceTracker<?,?> logs = newTracker(osgi, LogService.class); - ServiceTracker<?,?> logReaders = newTracker(osgi, LogReaderService.class); + ServiceTracker<?, ?> logs = newTracker(osgi, LogService.class); + ServiceTracker<?, ?> logReaders = newTracker(osgi, LogReaderService.class); assertEquals(1, logs.getTrackingCount()); assertEquals(1, logReaders.getTrackingCount()); @@ -38,7 +38,7 @@ public class OsgiLogServiceTestCase { } @Test - public void requireThatLogServiceCanNotBeStartedTwice() throws BundleException { + void requireThatLogServiceCanNotBeStartedTwice() throws BundleException { OsgiFramework osgi = TestDriver.newOsgiFramework(); osgi.start(); @@ -57,7 +57,7 @@ public class OsgiLogServiceTestCase { } @Test - public void requireThatLogServiceCanNotBeStoppedTwice() throws BundleException { + void requireThatLogServiceCanNotBeStoppedTwice() throws BundleException { OsgiFramework osgi = TestDriver.newOsgiFramework(); osgi.start(); @@ -77,7 +77,7 @@ public class OsgiLogServiceTestCase { } @Test - public void requireThatUnstartedLogServiceCanNotBeStopped() throws BundleException { + void requireThatUnstartedLogServiceCanNotBeStopped() throws BundleException { try { new OsgiLogService().stop(); fail(); @@ -87,7 +87,7 @@ public class OsgiLogServiceTestCase { } @Test - public void requireThatLogServiceCanNotStartWithoutBundleContext() throws BundleException { + void requireThatLogServiceCanNotStartWithoutBundleContext() throws BundleException { try { new OsgiLogService().start(null); fail(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ScheduledQueueTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ScheduledQueueTestCase.java index 163111c641d..cd963caa8d2 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/ScheduledQueueTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/ScheduledQueueTestCase.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.jdisc.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.LinkedList; @@ -11,9 +11,9 @@ import java.util.Queue; import static com.yahoo.jdisc.core.ScheduledQueue.MILLIS_PER_SLOT; import static com.yahoo.jdisc.core.ScheduledQueue.NUM_SLOTS; import static com.yahoo.jdisc.core.ScheduledQueue.NUM_SLOTS_UNDILATED; -import static org.junit.Assert.assertEquals; -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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -21,21 +21,21 @@ import static org.junit.Assert.fail; public class ScheduledQueueTestCase { @Test - public void requireThatSlotMaskPreventsOverflow() { + void requireThatSlotMaskPreventsOverflow() { for (int slot = 0; slot < NUM_SLOTS * 2; ++slot) { assertTrue((slot & ScheduledQueue.SLOT_MASK) < NUM_SLOTS); } } @Test - public void requireThatIterShiftDiscardsSlotBits() { + void requireThatIterShiftDiscardsSlotBits() { for (int slot = 0; slot < NUM_SLOTS * 2; ++slot) { assertEquals(slot / NUM_SLOTS, slot >> ScheduledQueue.ITER_SHIFT); } } @Test - public void requireThatNewEntryDoesNotAcceptNull() { + void requireThatNewEntryDoesNotAcceptNull() { ScheduledQueue queue = new ScheduledQueue(0); try { queue.newEntry(null); @@ -46,7 +46,7 @@ public class ScheduledQueueTestCase { } @Test - public void requireThatEntriesCanBeScheduled() { + void requireThatEntriesCanBeScheduled() { ScheduledQueue queue = new ScheduledQueue(0); Object foo = new Object(); ScheduledQueue.Entry entry = queue.newEntry(foo); @@ -57,7 +57,7 @@ public class ScheduledQueueTestCase { } @Test - public void requireThatEntriesCanBeRescheduled() { + void requireThatEntriesCanBeRescheduled() { ScheduledQueue queue = new ScheduledQueue(0); Object foo = new Object(); ScheduledQueue.Entry entry = queue.newEntry(foo); @@ -69,7 +69,7 @@ public class ScheduledQueueTestCase { } @Test - public void requireThatEntriesCanBeUnscheduled() { + void requireThatEntriesCanBeUnscheduled() { ScheduledQueue queue = new ScheduledQueue(0); Object foo = new Object(); ScheduledQueue.Entry entry = queue.newEntry(foo); @@ -80,7 +80,7 @@ public class ScheduledQueueTestCase { } @Test - public void requireThatDrainToOnlyDrainsExpiredEntries() { + void requireThatDrainToOnlyDrainsExpiredEntries() { ScheduledQueue queue = new ScheduledQueue(0); Object foo = scheduleAt(queue, 100); Object bar = scheduleAt(queue, 300); @@ -93,7 +93,7 @@ public class ScheduledQueueTestCase { } @Test - public void requireThatEntriesDoNotExpireMoreThanOnce() { + void requireThatEntriesDoNotExpireMoreThanOnce() { ScheduledQueue queue = new ScheduledQueue(0); Object foo = scheduleAt(queue, NUM_SLOTS * MILLIS_PER_SLOT + 50); @@ -108,7 +108,7 @@ public class ScheduledQueueTestCase { } @Test - public void requireThatNegativeScheduleTranslatesToNow() { + void requireThatNegativeScheduleTranslatesToNow() { ScheduledQueue queue = new ScheduledQueue(0); Object foo = scheduleAt(queue, -100); @@ -116,7 +116,7 @@ public class ScheduledQueueTestCase { } @Test - public void requireThatDrainToPerformsTimeDilationWhenOverloaded() { + void requireThatDrainToPerformsTimeDilationWhenOverloaded() { ScheduledQueue queue = new ScheduledQueue(0); List<Object> payloads = new LinkedList<>(); for (int i = 1; i <= NUM_SLOTS_UNDILATED + 1; ++i) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/SystemTimerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/SystemTimerTestCase.java index 52e25877402..dc6d3b30cb2 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/SystemTimerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/SystemTimerTestCase.java @@ -3,9 +3,9 @@ package com.yahoo.jdisc.core; import com.google.inject.Guice; import com.yahoo.jdisc.Timer; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -14,13 +14,13 @@ import static org.junit.Assert.assertTrue; public class SystemTimerTestCase { @Test - public void requireThatClassIsInjectedByDefault() { + void requireThatClassIsInjectedByDefault() { Timer timer = Guice.createInjector().getInstance(Timer.class); assertTrue(timer instanceof SystemTimer); } @Test - public void requireThatSystemTimerIsSane() { + void requireThatSystemTimerIsSane() { long before = System.currentTimeMillis(); long millis = new SystemTimer().currentTimeMillis(); long after = System.currentTimeMillis(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/core/TimeoutManagerImplTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/core/TimeoutManagerImplTestCase.java index 75ebad12158..0308abebd8a 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/core/TimeoutManagerImplTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/core/TimeoutManagerImplTestCase.java @@ -19,7 +19,7 @@ import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.NonWorkingRequest; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; @@ -28,13 +28,13 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -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.assertSame; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -44,35 +44,35 @@ public class TimeoutManagerImplTestCase { private static final String REQUEST_URI = "http://host/path"; @Test - public void requireThatDefaultIsNoTimeout() { + void requireThatDefaultIsNoTimeout() { Context ctx = new Context(MyRequestHandler.newEagerResponse()); assertNull(ctx.dispatchRequest(null, MyResponseHandler.newInstance())); assertTrue(ctx.close()); } @Test - public void requireThatTimeoutCanBeSetByServerProvider() { + void requireThatTimeoutCanBeSetByServerProvider() { Context ctx = new Context(MyRequestHandler.newEagerResponse()); assertEquals(Long.valueOf(69), ctx.dispatchRequest(69L, MyResponseHandler.newInstance())); assertTrue(ctx.close()); } @Test - public void requireThatTimeoutCanBeSetByRequestHandler() { + void requireThatTimeoutCanBeSetByRequestHandler() { Context ctx = new Context(MyRequestHandler.newTimeoutWithEagerResponse(69)); assertEquals(Long.valueOf(69), ctx.dispatchRequest(null, MyResponseHandler.newInstance())); assertTrue(ctx.close()); } @Test - public void requireThatTimeoutRequestHandlerTimeoutHasPrecedence() { + void requireThatTimeoutRequestHandlerTimeoutHasPrecedence() { Context ctx = new Context(MyRequestHandler.newTimeoutWithEagerResponse(6)); assertEquals(Long.valueOf(6), ctx.dispatchRequest(9L, MyResponseHandler.newInstance())); assertTrue(ctx.close()); } @Test - public void requireThatResponseCancelsTimeout() throws InterruptedException { + void requireThatResponseCancelsTimeout() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newEagerResponse()); assertEquals(Response.Status.OK, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); assertEquals(Response.Status.OK, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); @@ -80,7 +80,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatNullRequestContentCanTimeout() throws InterruptedException { + void requireThatNullRequestContentCanTimeout() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newNullContent()); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); @@ -88,7 +88,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatTimeoutWorksAfterRequestDenied() throws InterruptedException { + void requireThatTimeoutWorksAfterRequestDenied() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newFirstRequestDenied()); try { ctx.dispatchRequest(null, MyResponseHandler.newInstance()); @@ -101,7 +101,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatTimeoutWorksAfterResponseDenied() throws InterruptedException { + void requireThatTimeoutWorksAfterResponseDenied() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newInstance()); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newResponseDenied())); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); @@ -109,7 +109,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatTimeoutWorksAfterResponseThrowsException() throws InterruptedException { + void requireThatTimeoutWorksAfterResponseThrowsException() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newInstance()); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newThrowException())); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); @@ -117,7 +117,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatTimeoutWorksAfterResponseInterruptsThread() throws InterruptedException { + void requireThatTimeoutWorksAfterResponseInterruptsThread() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newInstance()); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newInterruptThread())); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); @@ -125,7 +125,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatTimeoutOccursInOrder() throws InterruptedException { + void requireThatTimeoutOccursInOrder() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newInstance()); MyResponseHandler foo = MyResponseHandler.newInstance(); ctx.dispatchRequest(300L, foo); @@ -152,7 +152,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatResponseHandlerIsWellBehavedAfterTimeout() throws InterruptedException { + void requireThatResponseHandlerIsWellBehavedAfterTimeout() throws InterruptedException { Context ctx = new Context(MyRequestHandler.newInstance()); assertEquals(Response.Status.GATEWAY_TIMEOUT, ctx.awaitResponse(69L, MyResponseHandler.newInstance())); @@ -172,11 +172,11 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatManagedHandlerForwardsAllCalls() throws InterruptedException { + void requireThatManagedHandlerForwardsAllCalls() throws InterruptedException { Request request = NonWorkingRequest.newInstance(REQUEST_URI); MyRequestHandler requestHandler = MyRequestHandler.newInstance(); TimeoutManagerImpl timeoutManager = new TimeoutManagerImpl(Executors.defaultThreadFactory(), - new SystemTimer()); + new SystemTimer()); RequestHandler managedHandler = timeoutManager.manageHandler(requestHandler); MyResponseHandler responseHandler = MyResponseHandler.newInstance(); @@ -219,7 +219,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatTimeoutOccursAtExpectedTime() throws InterruptedException { + void requireThatTimeoutOccursAtExpectedTime() throws InterruptedException { final Context ctx = new Context(MyRequestHandler.newInstance()); final MyResponseHandler responseHandler = MyResponseHandler.newInstance(); @@ -251,7 +251,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatQueueEntryIsRemovedWhenResponseHandlerIsCalledBeforeTimeout() { + void requireThatQueueEntryIsRemovedWhenResponseHandlerIsCalledBeforeTimeout() { Context ctx = new Context(MyRequestHandler.newInstance()); ctx.dispatchRequest(69L, MyResponseHandler.newInstance()); assertTrue(ctx.awaitQueueSize(1, 600, TimeUnit.SECONDS)); @@ -261,7 +261,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatNoEntryIsMadeIfTimeoutIsNull() { + void requireThatNoEntryIsMadeIfTimeoutIsNull() { Context ctx = new Context(MyRequestHandler.newInstance()); ctx.dispatchRequest(null, MyResponseHandler.newInstance()); assertFalse(ctx.awaitQueueSize(1, 100, TimeUnit.MILLISECONDS)); @@ -271,7 +271,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatNoEntryIsMadeIfHandleRequestCallsHandleResponse() { + void requireThatNoEntryIsMadeIfHandleRequestCallsHandleResponse() { Context ctx = new Context(MyRequestHandler.newEagerResponse()); ctx.dispatchRequest(69L, MyResponseHandler.newInstance()); assertFalse(ctx.awaitQueueSize(1, 100, TimeUnit.MILLISECONDS)); @@ -280,7 +280,7 @@ public class TimeoutManagerImplTestCase { } @Test - public void requireThatNoEntryIsMadeIfTimeoutHandlerHasBeenSet() { + void requireThatNoEntryIsMadeIfTimeoutHandlerHasBeenSet() { final Context ctx = new Context(MyRequestHandler.newInstance()); new RequestDispatch() { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java index 4951ff72ffd..7578e3213dd 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractContentOutputStreamTestCase.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.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -11,8 +11,8 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -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; /** @@ -21,15 +21,15 @@ import static org.junit.Assert.assertTrue; public class AbstractContentOutputStreamTestCase { @Test - public void requireThatStreamCanBeWrittenTo() throws IOException { + void requireThatStreamCanBeWrittenTo() throws IOException { MyOutputStream out = new MyOutputStream(); int len = 2 * AbstractContentOutputStream.BUFFERSIZE; for (int i = 0; i < len; ++i) { out.write(69); - out.write(new byte[] { }); - out.write(new byte[] { 6, 9 }); - out.write(new byte[] { 6, 69, 9 }, 1, 0); // zero length - out.write(new byte[] { 6, 69, 9 }, 1, 1); + out.write(new byte[]{}); + out.write(new byte[]{6, 9}); + out.write(new byte[]{6, 69, 9}, 1, 0); // zero length + out.write(new byte[]{6, 69, 9}, 1, 1); } out.close(); @@ -45,7 +45,7 @@ public class AbstractContentOutputStreamTestCase { } @Test - public void requireThatBigBuffersAreWrittenInOrder() throws IOException { + void requireThatBigBuffersAreWrittenInOrder() throws IOException { MyOutputStream out = new MyOutputStream(); out.write(6); out.write(new byte[2 * AbstractContentOutputStream.BUFFERSIZE]); @@ -62,7 +62,7 @@ public class AbstractContentOutputStreamTestCase { } @Test - public void requireThatEmptyBuffersAreNotFlushed() throws Exception { + void requireThatEmptyBuffersAreNotFlushed() throws Exception { MyOutputStream out = new MyOutputStream(); out.close(); assertTrue(out.writes.isEmpty()); @@ -70,9 +70,9 @@ public class AbstractContentOutputStreamTestCase { } @Test - public void requireThatNoExcessiveBytesAreWritten() throws Exception { + void requireThatNoExcessiveBytesAreWritten() throws Exception { MyOutputStream out = new MyOutputStream(); - out.write(new byte[] { 6, 9 }); + out.write(new byte[]{6, 9}); out.close(); InputStream in = out.toInputStream(); @@ -85,7 +85,7 @@ public class AbstractContentOutputStreamTestCase { } @Test - public void requireThatWrittenArraysAreCopied() throws Exception { + void requireThatWrittenArraysAreCopied() throws Exception { MyOutputStream out = new MyOutputStream(); byte[] buf = new byte[1]; for (byte b = 0; b < 127; ++b) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java index 6b5382b8bba..14ff6d87555 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/AbstractRequestHandlerTestCase.java @@ -6,18 +6,18 @@ import com.yahoo.jdisc.Response; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.test.NonWorkingRequest; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; import java.util.concurrent.TimeUnit; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -28,7 +28,7 @@ public class AbstractRequestHandlerTestCase { private static final int NUM_REQUESTS = 666; @Test - public void requireThatHandleTimeoutIsImplemented() throws Exception { + void requireThatHandleTimeoutIsImplemented() throws Exception { FutureResponse handler = new FutureResponse(); new AbstractRequestHandler() { @@ -43,7 +43,7 @@ public class AbstractRequestHandlerTestCase { } @Test - public void requireThatHelloWorldWorks() throws InterruptedException { + void requireThatHelloWorldWorks() throws InterruptedException { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.serverBindings().bind("http://localhost/", new HelloWorldHandler()); @@ -62,7 +62,7 @@ public class AbstractRequestHandlerTestCase { } @Test - public void requireThatEchoWorks() throws InterruptedException { + void requireThatEchoWorks() throws InterruptedException { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.serverBindings().bind("http://localhost/", new EchoHandler()); @@ -83,7 +83,7 @@ public class AbstractRequestHandlerTestCase { } @Test - public void requireThatForwardWorks() throws InterruptedException { + void requireThatForwardWorks() throws InterruptedException { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.serverBindings().bind("http://localhost/", new ForwardHandler()); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java index 7d76e9de7e2..03fd4368be9 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BindingNotFoundTestCase.java @@ -4,12 +4,12 @@ package com.yahoo.jdisc.handler; import com.yahoo.jdisc.Request; import com.yahoo.jdisc.Response; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -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; /** @@ -18,14 +18,14 @@ import static org.junit.Assert.fail; public class BindingNotFoundTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { URI uri = URI.create("http://host/path"); BindingNotFoundException e = new BindingNotFoundException(uri); assertEquals(uri, e.uri()); } @Test - public void requireThatBindingNotFoundIsThrown() { + void requireThatBindingNotFoundIsThrown() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); driver.activateContainer(driver.newContainerBuilder()); Request request = new Request(driver, URI.create("http://host/path")); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java index 651c24648a1..96c6edbdcf5 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BlockingContentWriterTestCase.java @@ -1,15 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.concurrent.*; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -17,7 +17,7 @@ import static org.junit.Assert.assertTrue; public class BlockingContentWriterTestCase { @Test - public void requireThatContentChannelIsNotNull() { + void requireThatContentChannelIsNotNull() { try { new BlockingContentWriter(null); fail(); @@ -27,7 +27,7 @@ public class BlockingContentWriterTestCase { } @Test - public void requireThatWriteDeliversBuffer() throws InterruptedException { + void requireThatWriteDeliversBuffer() throws InterruptedException { MyContent content = MyContent.newNonBlockingContent(); BlockingContentWriter writer = new BlockingContentWriter(content); ByteBuffer buf = ByteBuffer.allocate(69); @@ -36,7 +36,7 @@ public class BlockingContentWriterTestCase { } @Test - public void requireThatWriteIsBlocking() throws Exception { + void requireThatWriteIsBlocking() throws Exception { MyContent content = MyContent.newBlockingContent(); BlockingContentWriter writer = new BlockingContentWriter(content); FutureTask<Boolean> task = new FutureTask<>(new WriteTask(writer, ByteBuffer.allocate(69))); @@ -53,7 +53,7 @@ public class BlockingContentWriterTestCase { } @Test - public void requireThatWriteExceptionIsThrown() throws Exception { + void requireThatWriteExceptionIsThrown() throws Exception { Throwable throwMe = new RuntimeException(); try { new BlockingContentWriter(MyContent.newFailedContent(throwMe)).write(ByteBuffer.allocate(69)); @@ -76,7 +76,7 @@ public class BlockingContentWriterTestCase { } @Test - public void requireThatCloseIsBlocking() throws Exception { + void requireThatCloseIsBlocking() throws Exception { MyContent content = MyContent.newBlockingContent(); BlockingContentWriter writer = new BlockingContentWriter(content); FutureTask<Boolean> task = new FutureTask<>(new CloseTask(writer)); @@ -93,7 +93,7 @@ public class BlockingContentWriterTestCase { } @Test - public void requireThatCloseExceptionIsThrown() throws Exception { + void requireThatCloseExceptionIsThrown() throws Exception { Throwable throwMe = new RuntimeException(); try { new BlockingContentWriter(MyContent.newFailedContent(throwMe)).close(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java index 705d6d008b0..3824c0eb928 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/BufferedContentChannelTestCase.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.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.LinkedList; @@ -9,11 +9,11 @@ import java.util.List; import java.util.Random; import java.util.concurrent.*; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals; public class BufferedContentChannelTestCase { @Test - public void requireThatIsConnectedWorks() { + void requireThatIsConnectedWorks() { MyContent target = new MyContent(); BufferedContentChannel content = new BufferedContentChannel(); assertFalse(content.isConnected()); @@ -30,7 +30,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatConnectToNullThrowsException() { + void requireThatConnectToNullThrowsException() { BufferedContentChannel content = new BufferedContentChannel(); try { content.connectTo(null); @@ -41,7 +41,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatWriteAfterCloseThrowsException() { + void requireThatWriteAfterCloseThrowsException() { BufferedContentChannel content = new BufferedContentChannel(); content.close(null); try { @@ -53,7 +53,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatCloseAfterCloseThrowsException() { + void requireThatCloseAfterCloseThrowsException() { BufferedContentChannel content = new BufferedContentChannel(); content.close(null); try { @@ -65,7 +65,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatConnecToAfterConnecToThrowsException() { + void requireThatConnecToAfterConnecToThrowsException() { BufferedContentChannel content = new BufferedContentChannel(); content.connectTo(new MyContent()); try { @@ -77,7 +77,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatWriteBeforeConnectToWritesToTarget() { + void requireThatWriteBeforeConnectToWritesToTarget() { BufferedContentChannel content = new BufferedContentChannel(); ByteBuffer buf = ByteBuffer.allocate(69); MyCompletion completion = new MyCompletion(); @@ -89,7 +89,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatWriteAfterConnectToWritesToTarget() { + void requireThatWriteAfterConnectToWritesToTarget() { MyContent target = new MyContent(); BufferedContentChannel content = new BufferedContentChannel(); content.connectTo(target); @@ -101,7 +101,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatCloseBeforeConnectToClosesTarget() { + void requireThatCloseBeforeConnectToClosesTarget() { BufferedContentChannel content = new BufferedContentChannel(); MyCompletion completion = new MyCompletion(); content.close(completion); @@ -112,7 +112,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatCloseAfterConnectToClosesTarget() { + void requireThatCloseAfterConnectToClosesTarget() { MyContent target = new MyContent(); BufferedContentChannel content = new BufferedContentChannel(); content.connectTo(target); @@ -123,7 +123,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatIsConnectedIsTrueWhenConnectedBeforeClose() { + void requireThatIsConnectedIsTrueWhenConnectedBeforeClose() { BufferedContentChannel content = new BufferedContentChannel(); assertFalse(content.isConnected()); content.connectTo(new MyContent()); @@ -133,7 +133,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatIsConnectedIsTrueWhenClosedBeforeConnected() { + void requireThatIsConnectedIsTrueWhenClosedBeforeConnected() { BufferedContentChannel content = new BufferedContentChannel(); assertFalse(content.isConnected()); content.close(null); @@ -143,7 +143,7 @@ public class BufferedContentChannelTestCase { } @Test - public void requireThatContentIsThreadSafe() throws Exception { + void requireThatContentIsThreadSafe() throws Exception { ExecutorService executor = Executors.newFixedThreadPool(101); for (int run = 0; run < 69; ++run) { List<ByteBuffer> bufs = new LinkedList<>(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java index b11afacb518..6e5ad50f447 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableRequestDispatchTestCase.java @@ -5,12 +5,12 @@ import com.yahoo.jdisc.Request; import com.yahoo.jdisc.Response; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Simon Thoresen Hult @@ -18,7 +18,7 @@ import static org.junit.Assert.assertTrue; public class CallableRequestDispatchTestCase { @Test - public void requireThatDispatchIsCalled() throws Exception { + void requireThatDispatchIsCalled() throws Exception { final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); Response response = new Response(Response.Status.OK); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java index bb17bb9bc41..ff953fe0384 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/CallableResponseDispatchTestCase.java @@ -2,11 +2,11 @@ package com.yahoo.jdisc.handler; import com.yahoo.jdisc.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; /** @@ -15,7 +15,7 @@ import static org.junit.Assert.assertSame; public class CallableResponseDispatchTestCase { @Test - public void requireThatDispatchIsCalled() throws Exception { + void requireThatDispatchIsCalled() throws Exception { final Response response = new Response(Response.Status.OK); FutureResponse handler = new FutureResponse(); new CallableResponseDispatch(handler) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java index f90251bc16e..30169699077 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ContentInputStreamTestCase.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.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.Future; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -14,13 +14,13 @@ import static org.junit.Assert.assertTrue; public class ContentInputStreamTestCase { @Test - public void requireThatContentInputStreamExtendsUnsafeContentInputStream() { + void requireThatContentInputStreamExtendsUnsafeContentInputStream() { assertTrue(UnsafeContentInputStream.class.isAssignableFrom(ContentInputStream.class)); } @Test @SuppressWarnings("FinalizeCalledExplicitly") - public void requireThatFinalizerClosesStream() throws Throwable { + void requireThatFinalizerClosesStream() throws Throwable { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); writer.write("foo"); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java index 2cdc0e1256f..3f97fe014e6 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentOutputStreamTestCase.java @@ -1,15 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.nio.ByteBuffer; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -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; /** @@ -18,15 +18,15 @@ import static org.junit.Assert.fail; public class FastContentOutputStreamTestCase { @Test - public void requireThatNullConstructorArgumentThrows() { + void requireThatNullConstructorArgumentThrows() { try { - new FastContentOutputStream((ContentChannel)null); + new FastContentOutputStream((ContentChannel) null); fail(); } catch (NullPointerException e) { assertEquals("out", e.getMessage()); } try { - new FastContentOutputStream((FastContentWriter)null); + new FastContentOutputStream((FastContentWriter) null); fail(); } catch (NullPointerException e) { assertEquals("out", e.getMessage()); @@ -34,11 +34,11 @@ public class FastContentOutputStreamTestCase { } @Test - public void requireThatAllMethodsDelegateToWriter() throws Exception { + void requireThatAllMethodsDelegateToWriter() throws Exception { FastContentWriter writer = Mockito.mock(FastContentWriter.class); FastContentOutputStream out = new FastContentOutputStream(writer); - out.write(new byte[] { 6, 9 }); + out.write(new byte[]{6, 9}); out.flush(); Mockito.verify(writer).write(Mockito.any(ByteBuffer.class)); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java index 45bc230896f..4e0b989db74 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FastContentWriterTestCase.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.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.nio.ByteBuffer; @@ -15,14 +15,14 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +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.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -30,7 +30,7 @@ import static org.junit.Assert.assertArrayEquals; public class FastContentWriterTestCase { @Test - public void requireThatContentCanBeWritten() throws ExecutionException, InterruptedException { + void requireThatContentCanBeWritten() throws ExecutionException, InterruptedException { ReadableContentChannel content = new ReadableContentChannel(); FastContentWriter out = new FastContentWriter(content); @@ -50,7 +50,7 @@ public class FastContentWriterTestCase { } @Test - public void requireThatStringsAreUtf8Encoded() { + void requireThatStringsAreUtf8Encoded() { ReadableContentChannel content = new ReadableContentChannel(); FastContentWriter out = new FastContentWriter(content); @@ -65,7 +65,7 @@ public class FastContentWriterTestCase { } @Test - public void requireThatCancelThrowsUnsupportedOperation() { + void requireThatCancelThrowsUnsupportedOperation() { try { new FastContentWriter(Mockito.mock(ContentChannel.class)).cancel(true); fail(); @@ -75,7 +75,7 @@ public class FastContentWriterTestCase { } @Test - public void requireThatCancelIsAlwaysFalse() { + void requireThatCancelIsAlwaysFalse() { FastContentWriter writer = new FastContentWriter(Mockito.mock(ContentChannel.class)); assertFalse(writer.isCancelled()); try { @@ -88,11 +88,11 @@ public class FastContentWriterTestCase { } @Test - public void requireThatGetThrowsTimeoutUntilCloseCompletionHandlerIsCalled() throws Exception { + void requireThatGetThrowsTimeoutUntilCloseCompletionHandlerIsCalled() throws Exception { ReadableContentChannel buf = new ReadableContentChannel(); FastContentWriter out = new FastContentWriter(buf); - out.write(new byte[] { 6, 9 }); + out.write(new byte[]{6, 9}); assertFalse(out.isDone()); try { out.get(100, TimeUnit.MILLISECONDS); @@ -126,11 +126,11 @@ public class FastContentWriterTestCase { } @Test - public void requireThatSyncWriteExceptionFailsFuture() throws InterruptedException { + void requireThatSyncWriteExceptionFailsFuture() throws InterruptedException { IllegalStateException expected = new IllegalStateException(); ContentChannel content = Mockito.mock(ContentChannel.class); Mockito.doThrow(expected) - .when(content).write(Mockito.any(ByteBuffer.class), Mockito.any(CompletionHandler.class)); + .when(content).write(Mockito.any(ByteBuffer.class), Mockito.any(CompletionHandler.class)); FastContentWriter out = new FastContentWriter(content); try { out.write("foo"); @@ -147,11 +147,11 @@ public class FastContentWriterTestCase { } @Test - public void requireThatSyncCloseExceptionFailsFuture() throws InterruptedException { + void requireThatSyncCloseExceptionFailsFuture() throws InterruptedException { IllegalStateException expected = new IllegalStateException(); ContentChannel content = Mockito.mock(ContentChannel.class); Mockito.doThrow(expected) - .when(content).close(Mockito.any(CompletionHandler.class)); + .when(content).close(Mockito.any(CompletionHandler.class)); FastContentWriter out = new FastContentWriter(content); try { out.close(); @@ -168,7 +168,7 @@ public class FastContentWriterTestCase { } @Test - public void requireThatAsyncExceptionFailsFuture() throws InterruptedException { + void requireThatAsyncExceptionFailsFuture() throws InterruptedException { IllegalStateException expected = new IllegalStateException(); ReadableContentChannel content = new ReadableContentChannel(); FastContentWriter out = new FastContentWriter(content); @@ -183,13 +183,13 @@ public class FastContentWriterTestCase { } @Test - public void requireThatWriterCanBeListenedTo() throws InterruptedException { + void requireThatWriterCanBeListenedTo() throws InterruptedException { ReadableContentChannel buf = new ReadableContentChannel(); FastContentWriter out = new FastContentWriter(buf); RunnableLatch listener = new RunnableLatch(); out.addListener(listener, Runnable::run); - out.write(new byte[] { 6, 9 }); + out.write(new byte[]{6, 9}); assertFalse(listener.await(100, TimeUnit.MILLISECONDS)); assertNotNull(buf.read()); assertFalse(listener.await(100, TimeUnit.MILLISECONDS)); @@ -200,7 +200,7 @@ public class FastContentWriterTestCase { } @Test - public void requireThatWriterIsThreadSafe() throws Exception { + void requireThatWriterIsThreadSafe() throws Exception { final CountDownLatch latch = new CountDownLatch(2); final ReadableContentChannel content = new ReadableContentChannel(); Future<Integer> read = Executors.newSingleThreadExecutor().submit(new Callable<Integer>() { @@ -235,6 +235,6 @@ public class FastContentWriterTestCase { } }); assertEquals(read.get(600, TimeUnit.SECONDS), - write.get(600, TimeUnit.SECONDS)); + write.get(600, TimeUnit.SECONDS)); } } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java index ef63b200b5f..fe4b329ba9d 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureCompletionTestCase.java @@ -1,16 +1,16 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -18,7 +18,7 @@ import static org.junit.Assert.assertSame; public class FutureCompletionTestCase { @Test - public void requireThatCancelIsUnsupported() { + void requireThatCancelIsUnsupported() { FutureCompletion future = new FutureCompletion(); assertFalse(future.isCancelled()); try { @@ -38,7 +38,7 @@ public class FutureCompletionTestCase { } @Test - public void requireThatCompletedReturnsTrue() throws Exception { + void requireThatCompletedReturnsTrue() throws Exception { FutureCompletion future = new FutureCompletion(); try { future.get(0, TimeUnit.MILLISECONDS); @@ -52,7 +52,7 @@ public class FutureCompletionTestCase { } @Test - public void requireThatCompletionIsDoneWhenCompleted() { + void requireThatCompletionIsDoneWhenCompleted() { FutureCompletion future = new FutureCompletion(); assertFalse(future.isDone()); future.completed(); @@ -60,7 +60,7 @@ public class FutureCompletionTestCase { } @Test - public void requireThatCompletionIsDoneWhenFailed() { + void requireThatCompletionIsDoneWhenFailed() { FutureCompletion future = new FutureCompletion(); assertFalse(future.isDone()); future.failed(new Throwable()); @@ -68,7 +68,7 @@ public class FutureCompletionTestCase { } @Test - public void requireThatFailedCauseIsRethrown() throws Exception { + void requireThatFailedCauseIsRethrown() throws Exception { FutureCompletion future = new FutureCompletion(); Throwable t = new Throwable(); future.failed(t); @@ -87,7 +87,7 @@ public class FutureCompletionTestCase { } @Test - public void requireThatCompletionCanBeListenedTo() throws InterruptedException { + void requireThatCompletionCanBeListenedTo() throws InterruptedException { FutureCompletion completion = new FutureCompletion(); RunnableLatch listener = new RunnableLatch(); completion.addListener(listener, Runnable::run); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java index 1aa78a16dfc..16c6b394426 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureConjunctionTestCase.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.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; @@ -10,10 +10,10 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -23,13 +23,17 @@ public class FutureConjunctionTestCase { private final ExecutorService executor = Executors.newCachedThreadPool(); @Test - public void requireThatAllFuturesAreWaitedFor() throws Exception { + void requireThatAllFuturesAreWaitedFor() throws Exception { final CountDownLatch latch = new CountDownLatch(1); FutureConjunction future = new FutureConjunction(); CompletableFuture<Boolean> cf = new CompletableFuture<>(); cf.completeAsync(() -> { - try { return latch.await(600, TimeUnit.SECONDS); } - catch (InterruptedException e) { return false; } + try { + return latch.await(600, TimeUnit.SECONDS); + } + catch (InterruptedException e) { + return false; + } }, executor); future.addOperand(cf); try { @@ -43,7 +47,7 @@ public class FutureConjunctionTestCase { } @Test - public void requireThatGetReturnValueIsAConjunction() throws Exception { + void requireThatGetReturnValueIsAConjunction() throws Exception { assertTrue(tryGet(true)); assertTrue(tryGet(true, true)); assertTrue(tryGet(true, true, true)); @@ -60,7 +64,7 @@ public class FutureConjunctionTestCase { } @Test - public void requireThatIsDoneReturnValueIsAConjunction() { + void requireThatIsDoneReturnValueIsAConjunction() { assertTrue(tryIsDone(true)); assertTrue(tryIsDone(true, true)); assertTrue(tryIsDone(true, true, true)); @@ -77,7 +81,7 @@ public class FutureConjunctionTestCase { } @Test - public void requireThatCancelReturnValueIsAConjuction() { + void requireThatCancelReturnValueIsAConjuction() { assertTrue(tryCancel(true)); assertTrue(tryCancel(true, true)); assertTrue(tryCancel(true, true, true)); @@ -94,7 +98,7 @@ public class FutureConjunctionTestCase { } @Test - public void requireThatIsCancelledReturnValueIsAConjuction() { + void requireThatIsCancelledReturnValueIsAConjuction() { assertTrue(tryIsCancelled(true)); assertTrue(tryIsCancelled(true, true)); assertTrue(tryIsCancelled(true, true, true)); @@ -111,7 +115,7 @@ public class FutureConjunctionTestCase { } @Test - public void requireThatConjunctionCanBeListenedTo() throws InterruptedException { + void requireThatConjunctionCanBeListenedTo() throws InterruptedException { FutureConjunction conjunction = new FutureConjunction(); RunnableLatch listener = new RunnableLatch(); conjunction.addListener(listener, Runnable::run); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java index 398f288e307..09f6db882fb 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/FutureResponseTestCase.java @@ -3,15 +3,15 @@ package com.yahoo.jdisc.handler; import com.yahoo.jdisc.Response; import com.yahoo.jdisc.test.NonWorkingContentChannel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -19,7 +19,7 @@ import static org.junit.Assert.assertSame; public class FutureResponseTestCase { @Test - public void requireThatCancelIsUnsupported() { + void requireThatCancelIsUnsupported() { FutureResponse future = new FutureResponse(); assertFalse(future.isCancelled()); try { @@ -39,7 +39,7 @@ public class FutureResponseTestCase { } @Test - public void requireThatCompletionIsDoneWhenHandlerIsCalled() { + void requireThatCompletionIsDoneWhenHandlerIsCalled() { FutureResponse future = new FutureResponse(); assertFalse(future.isDone()); future.handleResponse(new Response(69)); @@ -47,7 +47,7 @@ public class FutureResponseTestCase { } @Test - public void requireThatResponseBecomesAvailable() throws Exception { + void requireThatResponseBecomesAvailable() throws Exception { FutureResponse future = new FutureResponse(); try { future.get(0, TimeUnit.MILLISECONDS); @@ -61,7 +61,7 @@ public class FutureResponseTestCase { } @Test - public void requireThatResponseContentIsReturnedToCaller() throws Exception { + void requireThatResponseContentIsReturnedToCaller() throws Exception { ContentChannel content = new NonWorkingContentChannel(); FutureResponse future = new FutureResponse(content); Response response = new Response(Response.Status.OK); @@ -69,7 +69,7 @@ public class FutureResponseTestCase { } @Test - public void requireThatResponseCanBeListenedTo() throws InterruptedException { + void requireThatResponseCanBeListenedTo() throws InterruptedException { FutureResponse response = new FutureResponse(); RunnableLatch listener = new RunnableLatch(); response.addListener(listener, Runnable::run); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java index 598d21b94ea..8e18ab01ae3 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/NullContentTestCase.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.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import java.nio.ByteBuffer; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -14,7 +14,7 @@ import static org.junit.Assert.fail; public class NullContentTestCase { @Test - public void requireThatWriteThrowsException() { + void requireThatWriteThrowsException() { CompletionHandler completion = Mockito.mock(CompletionHandler.class); try { NullContent.INSTANCE.write(ByteBuffer.allocate(69), completion); @@ -26,7 +26,7 @@ public class NullContentTestCase { } @Test - public void requireThatWriteEmptyDoesNotThrowException() { + void requireThatWriteEmptyDoesNotThrowException() { CompletionHandler completion = Mockito.mock(CompletionHandler.class); NullContent.INSTANCE.write(ByteBuffer.allocate(0), completion); Mockito.verify(completion).completed(); @@ -34,7 +34,7 @@ public class NullContentTestCase { } @Test - public void requireThatCloseCallsCompletion() { + void requireThatCloseCallsCompletion() { CompletionHandler completion = Mockito.mock(CompletionHandler.class); NullContent.INSTANCE.close(completion); Mockito.verify(completion).completed(); @@ -42,7 +42,7 @@ public class NullContentTestCase { } @Test - public void requireThatCloseWithoutCompletionDoesNotThrow() { + void requireThatCloseWithoutCompletionDoesNotThrow() { NullContent.INSTANCE.close(null); } } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java index 385cd4015b9..77da00bfa89 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ReadableContentChannelTestCase.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.jdisc.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; import java.util.Iterator; @@ -10,12 +10,12 @@ import java.util.List; import java.util.NoSuchElementException; import java.util.concurrent.*; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * @author Simon Thoresen Hult @@ -23,7 +23,7 @@ import static org.junit.Assert.assertSame; public class ReadableContentChannelTestCase { @Test - public void requireThatWriteNullThrowsException() { + void requireThatWriteNullThrowsException() { ReadableContentChannel content = new ReadableContentChannel(); try { content.write(null, new MyCompletion()); @@ -34,7 +34,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatWriteAfterCloseThrowsException() { + void requireThatWriteAfterCloseThrowsException() { ReadableContentChannel content = new ReadableContentChannel(); content.close(null); try { @@ -46,7 +46,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatWriteAfterFailedThrowsException() { + void requireThatWriteAfterFailedThrowsException() { ReadableContentChannel content = new ReadableContentChannel(); content.failed(new RuntimeException()); try { @@ -58,7 +58,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatCloseAfterCloseThrowsException() { + void requireThatCloseAfterCloseThrowsException() { ReadableContentChannel content = new ReadableContentChannel(); content.close(null); try { @@ -70,7 +70,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatCloseAfterFailedThrowsException() { + void requireThatCloseAfterFailedThrowsException() { ReadableContentChannel content = new ReadableContentChannel(); content.failed(new RuntimeException()); try { @@ -82,7 +82,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatFailedAfterFailedThrowsException() { + void requireThatFailedAfterFailedThrowsException() { ReadableContentChannel content = new ReadableContentChannel(); content.failed(new RuntimeException()); try { @@ -94,7 +94,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatIteratorDoesNotSupportRemove() { + void requireThatIteratorDoesNotSupportRemove() { try { new ReadableContentChannel().iterator().remove(); fail(); @@ -104,7 +104,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatWrittenBufferCanBeRead() { + void requireThatWrittenBufferCanBeRead() { ReadableContentChannel content = new ReadableContentChannel(); ByteBuffer buf = ByteBuffer.allocate(69); content.write(buf, null); @@ -112,7 +112,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatWrittenBuffersAreReadInOrder() { + void requireThatWrittenBuffersAreReadInOrder() { ReadableContentChannel content = new ReadableContentChannel(); ByteBuffer foo = ByteBuffer.allocate(69); content.write(foo, null); @@ -124,7 +124,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatReadAfterCloseIsNull() { + void requireThatReadAfterCloseIsNull() { ReadableContentChannel content = new ReadableContentChannel(); content.close(null); assertNull(content.read()); @@ -132,7 +132,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatWrittenBufferCanBeReadByIterator() { + void requireThatWrittenBufferCanBeReadByIterator() { ReadableContentChannel content = new ReadableContentChannel(); ByteBuffer foo = ByteBuffer.allocate(69); content.write(foo, null); @@ -155,7 +155,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatReadAfterFailedIsNull() { + void requireThatReadAfterFailedIsNull() { ReadableContentChannel content = new ReadableContentChannel(); content.failed(new RuntimeException()); assertNull(content.read()); @@ -163,7 +163,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatReadCallsCompletion() { + void requireThatReadCallsCompletion() { ReadableContentChannel content = new ReadableContentChannel(); ByteBuffer buf = ByteBuffer.allocate(69); MyCompletion completion = new MyCompletion(); @@ -180,7 +180,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatReadWaitsForWrite() throws Exception { + void requireThatReadWaitsForWrite() throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(); ReadableContentChannel content = new ReadableContentChannel(); Future<ByteBuffer> readBuf = executor.submit(new ReadTask(content)); @@ -196,7 +196,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatCloseNotifiesRead() throws Exception { + void requireThatCloseNotifiesRead() throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(); ReadableContentChannel content = new ReadableContentChannel(); Future<ByteBuffer> buf = executor.submit(new ReadTask(content)); @@ -211,7 +211,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatFailedNotifiesRead() throws Exception { + void requireThatFailedNotifiesRead() throws Exception { ExecutorService executor = Executors.newSingleThreadExecutor(); ReadableContentChannel content = new ReadableContentChannel(); Future<ByteBuffer> buf = executor.submit(new ReadTask(content)); @@ -226,7 +226,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatFailedCallsPendingCompletions() { + void requireThatFailedCallsPendingCompletions() { MyCompletion foo = new MyCompletion(); MyCompletion bar = new MyCompletion(); ReadableContentChannel content = new ReadableContentChannel(); @@ -239,10 +239,10 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatAvailableIsNotBlocking() { + void requireThatAvailableIsNotBlocking() { ReadableContentChannel content = new ReadableContentChannel(); assertEquals(0, content.available()); - ByteBuffer buf = ByteBuffer.wrap(new byte[] { 6, 9 }); + ByteBuffer buf = ByteBuffer.wrap(new byte[]{6, 9}); content.write(buf, null); assertTrue(content.available() > 0); assertSame(buf, content.read()); @@ -253,7 +253,7 @@ public class ReadableContentChannelTestCase { } @Test - public void requireThatContentIsThreadSafe() { + void requireThatContentIsThreadSafe() { ExecutorService executor = Executors.newFixedThreadPool(100); for (int run = 0; run < 69; ++run) { List<ByteBuffer> bufs = new LinkedList<>(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java index 01634498bf3..724125e9c5e 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDeniedTestCase.java @@ -6,12 +6,12 @@ import com.yahoo.jdisc.Request; import com.yahoo.jdisc.Response; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -19,7 +19,7 @@ import static org.junit.Assert.assertSame; public class RequestDeniedTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); driver.activateContainer(driver.newContainerBuilder()); Request request = new Request(driver, URI.create("http://host/path")); @@ -30,7 +30,7 @@ public class RequestDeniedTestCase { } @Test - public void requireThatRequestDeniedIsThrown() { + void requireThatRequestDeniedIsThrown() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); RequestHandler requestHandler = new MyRequestHandler(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java index 6ec78f01733..fdae7e8e701 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/RequestDispatchTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.jdisc.Request; import com.yahoo.jdisc.Response; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStream; @@ -16,12 +16,12 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -29,7 +29,7 @@ import static org.junit.Assert.fail; public class RequestDispatchTestCase { @Test - public void requireThatRequestCanBeDispatched() throws Exception { + void requireThatRequestCanBeDispatched() throws Exception { final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); final List<ByteBuffer> writtenContent = Arrays.asList(ByteBuffer.allocate(6), ByteBuffer.allocate(9)); ReadableContentChannel receivedContent = new ReadableContentChannel(); @@ -62,7 +62,7 @@ public class RequestDispatchTestCase { } @Test - public void requireThatStreamCanBeConnected() throws IOException { + void requireThatStreamCanBeConnected() throws IOException { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); ReadableContentChannel content = new ReadableContentChannel(); @@ -84,7 +84,7 @@ public class RequestDispatchTestCase { } @Test - public void requireThatCancelIsUnsupported() { + void requireThatCancelIsUnsupported() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); RequestDispatch dispatch = driver.newRequestDispatch("http://localhost/", new FutureResponse()); assertFalse(dispatch.isCancelled()); @@ -106,7 +106,7 @@ public class RequestDispatchTestCase { } @Test - public void requireThatDispatchHandlesConnectException() { + void requireThatDispatchHandlesConnectException() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.serverBindings().bind("http://localhost/", new AbstractRequestHandler() { @@ -127,7 +127,7 @@ public class RequestDispatchTestCase { } @Test - public void requireThatDispatchHandlesWriteException() { + void requireThatDispatchHandlesWriteException() { final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); Response response = new Response(Response.Status.OK); @@ -165,7 +165,7 @@ public class RequestDispatchTestCase { } @Test - public void requireThatDispatchHandlesCloseException() { + void requireThatDispatchHandlesCloseException() { final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); Response response = new Response(Response.Status.OK); @@ -203,7 +203,7 @@ public class RequestDispatchTestCase { } @Test - public void requireThatDispatchCanBeListenedTo() throws InterruptedException { + void requireThatDispatchCanBeListenedTo() throws InterruptedException { final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); ReadableContentChannel requestContent = new ReadableContentChannel(); @@ -220,7 +220,7 @@ public class RequestDispatchTestCase { }.dispatch().whenComplete((__, ___) -> listener.run()); assertFalse(listener.await(100, TimeUnit.MILLISECONDS)); ContentChannel responseContent = ResponseDispatch.newInstance(Response.Status.OK) - .connect(requestHandler.responseHandler); + .connect(requestHandler.responseHandler); assertFalse(listener.await(100, TimeUnit.MILLISECONDS)); assertNull(requestContent.read()); assertTrue(listener.await(600, TimeUnit.SECONDS)); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java index 4006ab072cb..2c00689c3f4 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ResponseDispatchTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.jdisc.handler; import com.yahoo.jdisc.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.io.InputStream; @@ -13,13 +13,13 @@ import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -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.assertSame; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -27,7 +27,7 @@ import static org.junit.Assert.fail; public class ResponseDispatchTestCase { @Test - public void requireThatFactoryMethodsWork() throws Exception { + void requireThatFactoryMethodsWork() throws Exception { { FutureResponse handler = new FutureResponse(); ResponseDispatch.newInstance(69).dispatch(handler); @@ -78,7 +78,7 @@ public class ResponseDispatchTestCase { } @Test - public void requireThatResponseCanBeDispatched() throws Exception { + void requireThatResponseCanBeDispatched() throws Exception { final Response response = new Response(Response.Status.OK); final List<ByteBuffer> writtenContent = Arrays.asList(ByteBuffer.allocate(6), ByteBuffer.allocate(9)); ResponseDispatch dispatch = new ResponseDispatch() { @@ -109,7 +109,7 @@ public class ResponseDispatchTestCase { } @Test - public void requireThatStreamCanBeConnected() throws IOException { + void requireThatStreamCanBeConnected() throws IOException { ReadableContentChannel responseContent = new ReadableContentChannel(); OutputStream out = new FastContentOutputStream(new ResponseDispatch() { @@ -129,7 +129,7 @@ public class ResponseDispatchTestCase { } @Test - public void requireThatCancelIsUnsupported() { + void requireThatCancelIsUnsupported() { ResponseDispatch dispatch = ResponseDispatch.newInstance(69); assertFalse(dispatch.isCancelled()); try { @@ -149,7 +149,7 @@ public class ResponseDispatchTestCase { } @Test - public void requireThatDispatchClosesContentIfWriteThrowsException() { + void requireThatDispatchClosesContentIfWriteThrowsException() { final AtomicBoolean closed = new AtomicBoolean(false); try { ResponseDispatch.newInstance(6, ByteBuffer.allocate(9)).dispatch( @@ -173,12 +173,12 @@ public class ResponseDispatchTestCase { } @Test - public void requireThatDispatchCanBeListenedTo() throws InterruptedException { + void requireThatDispatchCanBeListenedTo() throws InterruptedException { RunnableLatch listener = new RunnableLatch(); ReadableContentChannel responseContent = new ReadableContentChannel(); ResponseDispatch.newInstance(6, ByteBuffer.allocate(9)) - .dispatch(new MyResponseHandler(responseContent)) - .whenComplete((__, ___) -> listener.run()); + .dispatch(new MyResponseHandler(responseContent)) + .whenComplete((__, ___) -> listener.run()); assertFalse(listener.await(100, TimeUnit.MILLISECONDS)); assertNotNull(responseContent.read()); assertFalse(listener.await(100, TimeUnit.MILLISECONDS)); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java index f639877b87b..63a6d310208 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/ThreadedRequestHandlerTestCase.java @@ -6,7 +6,7 @@ import com.yahoo.jdisc.Response; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; @@ -18,12 +18,12 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -31,7 +31,7 @@ import static org.junit.Assert.fail; public class ThreadedRequestHandlerTestCase { @Test - public void requireThatNullExecutorThrowsException() { + void requireThatNullExecutorThrowsException() { try { new ThreadedRequestHandler(null) { @@ -47,7 +47,7 @@ public class ThreadedRequestHandlerTestCase { } @Test - public void requireThatAccessorWork() { + void requireThatAccessorWork() { MyRequestHandler requestHandler = new MyRequestHandler(newExecutor()); requestHandler.setTimeout(1000, TimeUnit.MILLISECONDS); assertEquals(1000, requestHandler.getTimeout(TimeUnit.MILLISECONDS)); @@ -55,7 +55,7 @@ public class ThreadedRequestHandlerTestCase { } @Test - public void requireThatHandlerSetsRequestTimeout() throws InterruptedException { + void requireThatHandlerSetsRequestTimeout() throws InterruptedException { MyRequestHandler requestHandler = new MyRequestHandler(newExecutor()); requestHandler.setTimeout(600, TimeUnit.SECONDS); TestDriver driver = newTestDriver("http://localhost/", requestHandler); @@ -74,7 +74,7 @@ public class ThreadedRequestHandlerTestCase { } @Test - public void requireThatRequestAndResponseReachHandlers() throws InterruptedException { + void requireThatRequestAndResponseReachHandlers() throws InterruptedException { MyRequestHandler requestHandler = new MyRequestHandler(newExecutor()); TestDriver driver = newTestDriver("http://localhost/", requestHandler); @@ -99,18 +99,18 @@ public class ThreadedRequestHandlerTestCase { } @Test - public void requireThatNotImplementedHandlerDoesNotPreventShutdown() throws Exception { + void requireThatNotImplementedHandlerDoesNotPreventShutdown() throws Exception { TestDriver driver = newTestDriver("http://localhost/", new ThreadedRequestHandler(newExecutor()) { }); assertEquals(Response.Status.NOT_IMPLEMENTED, - dispatchRequest(driver, "http://localhost/", ByteBuffer.wrap(new byte[] { 69 })) - .get(600, TimeUnit.SECONDS).getStatus()); + dispatchRequest(driver, "http://localhost/", ByteBuffer.wrap(new byte[]{69})) + .get(600, TimeUnit.SECONDS).getStatus()); assertTrue(driver.close()); } @Test - public void requireThatThreadedRequestHandlerRetainsTheRequestUntilHandlerIsRun() throws Exception { + void requireThatThreadedRequestHandlerRetainsTheRequestUntilHandlerIsRun() throws Exception { final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); final AtomicInteger baseRetainCount = new AtomicInteger(); @@ -130,7 +130,7 @@ public class ThreadedRequestHandlerTestCase { @Override public void handleRequest(Request request, ReadableContentChannel requestContent, - ResponseHandler responseHandler) { + ResponseHandler responseHandler) { try { entryLatch.await(600, TimeUnit.SECONDS); } catch (InterruptedException e) { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java index 0c3670dd56e..50d695dbb27 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/handler/UnsafeContentInputStreamTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.jdisc.handler; import com.yahoo.text.Utf8; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.BufferedReader; import java.io.IOException; @@ -10,11 +10,11 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.ByteBuffer; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -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.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Simon Thoresen Hult @@ -22,7 +22,7 @@ import static org.junit.Assert.fail; public class UnsafeContentInputStreamTestCase { @Test - public void requireThatBytesCanBeRead() throws IOException { + void requireThatBytesCanBeRead() throws IOException { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); writer.write("Hello "); @@ -35,7 +35,7 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void testMark() throws IOException { + void testMark() throws IOException { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); writer.write("Hello "); @@ -71,13 +71,13 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatReadAfterResetIncludesDataAfterMark() throws IOException { + void requireThatReadAfterResetIncludesDataAfterMark() throws IOException { ReadableContentChannel content = new ReadableContentChannel(); UnsafeContentInputStream in = new UnsafeContentInputStream(content); - byte[] outBuf = new byte[] {1, 2, 3}; + byte[] outBuf = new byte[]{1, 2, 3}; content.write(ByteBuffer.wrap(outBuf), null); in.mark(4); - assertEquals(3, in.read(new byte[] {101, 102, 103, 104})); + assertEquals(3, in.read(new byte[]{101, 102, 103, 104})); in.reset(); byte[] inBuf = new byte[4]; int read = in.read(inBuf); @@ -86,7 +86,7 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatCompletionsAreCalledWithDeprecatedContentWriter() throws IOException { + void requireThatCompletionsAreCalledWithDeprecatedContentWriter() throws IOException { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); writer.write("foo"); @@ -101,7 +101,7 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatCompletionsAreCalled() throws IOException { + void requireThatCompletionsAreCalled() throws IOException { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); writer.write("foo"); @@ -116,7 +116,7 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatCloseDrainsStreamWithDeprecatedContentWriter() { + void requireThatCloseDrainsStreamWithDeprecatedContentWriter() { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); writer.write("foo"); @@ -127,7 +127,7 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatCloseDrainsStream() { + void requireThatCloseDrainsStream() { BufferedContentChannel channel = new BufferedContentChannel(); FastContentWriter writer = new FastContentWriter(channel); writer.write("foo"); @@ -138,11 +138,11 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatAvailableIsNotBlocking() throws IOException { + void requireThatAvailableIsNotBlocking() throws IOException { BufferedContentChannel channel = new BufferedContentChannel(); InputStream stream = asInputStream(channel); assertEquals(0, stream.available()); - channel.write(ByteBuffer.wrap(new byte[] { 6, 9 }), null); + channel.write(ByteBuffer.wrap(new byte[]{6, 9}), null); assertTrue(stream.available() > 0); assertEquals(6, stream.read()); assertTrue(stream.available() > 0); @@ -154,11 +154,11 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatReadLargeArrayIsNotBlocking() throws IOException { + void requireThatReadLargeArrayIsNotBlocking() throws IOException { BufferedContentChannel channel = new BufferedContentChannel(); InputStream stream = asInputStream(channel); assertEquals(0, stream.available()); - channel.write(ByteBuffer.wrap(new byte[] { 6, 9 }), null); + channel.write(ByteBuffer.wrap(new byte[]{6, 9}), null); assertTrue(stream.available() > 0); byte[] buf = new byte[69]; assertEquals(2, stream.read(buf)); @@ -171,12 +171,12 @@ public class UnsafeContentInputStreamTestCase { } @Test - public void requireThatAllByteValuesCanBeRead() throws IOException { + void requireThatAllByteValuesCanBeRead() throws IOException { ReadableContentChannel content = new ReadableContentChannel(); InputStream in = new UnsafeContentInputStream(content); for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; ++i) { - content.write(ByteBuffer.wrap(new byte[] { (byte)i }), null); - assertEquals(i, (byte)in.read()); + content.write(ByteBuffer.wrap(new byte[]{(byte) i}), null); + assertEquals(i, (byte) in.read()); } } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractClientProviderTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractClientProviderTestCase.java index bd205fd777e..9fe0b91cb39 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractClientProviderTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractClientProviderTestCase.java @@ -4,9 +4,9 @@ package com.yahoo.jdisc.service; import com.yahoo.jdisc.Request; import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.ResponseHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -15,12 +15,12 @@ import static org.junit.Assert.assertTrue; public class AbstractClientProviderTestCase { @Test - public void requireThatAbstractClassIsAClientProvider() { + void requireThatAbstractClassIsAClientProvider() { assertTrue(ClientProvider.class.isInstance(new MyClientProvider())); } @Test - public void requireThatStartDoesNotThrowAnException() { + void requireThatStartDoesNotThrowAnException() { new MyClientProvider().start(); } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractServerProviderTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractServerProviderTestCase.java index 7f4d9f72980..d46c5067dd9 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractServerProviderTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/service/AbstractServerProviderTestCase.java @@ -4,10 +4,10 @@ package com.yahoo.jdisc.service; import com.google.inject.Inject; import com.yahoo.jdisc.application.ContainerBuilder; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -16,14 +16,14 @@ import static org.junit.Assert.assertTrue; public class AbstractServerProviderTestCase { @Test - public void requireThatAbstractClassIsAServerProvider() { + void requireThatAbstractClassIsAServerProvider() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); assertTrue(ServerProvider.class.isInstance(new MyServerProvider(driver))); assertTrue(driver.close()); } @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); MyServerProvider server = builder.getInstance(MyServerProvider.class); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/service/BindingSetNotFoundTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/service/BindingSetNotFoundTestCase.java index 880641fe0f0..ad09c9d745e 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/service/BindingSetNotFoundTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/service/BindingSetNotFoundTestCase.java @@ -4,12 +4,12 @@ package com.yahoo.jdisc.service; import com.google.inject.AbstractModule; import com.yahoo.jdisc.application.BindingSetSelector; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -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; /** @@ -18,13 +18,13 @@ import static org.junit.Assert.fail; public class BindingSetNotFoundTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { BindingSetNotFoundException e = new BindingSetNotFoundException("foo"); assertEquals("foo", e.bindingSet()); } @Test - public void requireThatBindingSetNotFoundIsThrown() { + void requireThatBindingSetNotFoundIsThrown() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { @Override diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/service/ConnectToHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/service/ConnectToHandlerTestCase.java index 7182379dc85..3de43874129 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/service/ConnectToHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/service/ConnectToHandlerTestCase.java @@ -9,14 +9,14 @@ import com.yahoo.jdisc.handler.CompletionHandler; import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -25,7 +25,7 @@ import static org.junit.Assert.fail; public class ConnectToHandlerTestCase { @Test - public void requireThatNullResponseHandlerThrowsException() { + void requireThatNullResponseHandlerThrowsException() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); driver.activateContainer(driver.newContainerBuilder()); Request request = new Request(driver, URI.create("http://host/path")); @@ -40,7 +40,7 @@ public class ConnectToHandlerTestCase { } @Test - public void requireThatConnectToHandlerWorks() { + void requireThatConnectToHandlerWorks() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = new MyRequestHandler(new MyContent()); ContainerBuilder builder = driver.newContainerBuilder(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/service/ContainerNotReadyTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/service/ContainerNotReadyTestCase.java index 6fcc7601339..70a0b55f75a 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/service/ContainerNotReadyTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/service/ContainerNotReadyTestCase.java @@ -2,11 +2,11 @@ package com.yahoo.jdisc.service; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -15,7 +15,7 @@ import static org.junit.Assert.fail; public class ContainerNotReadyTestCase { @Test - public void requireThatExceptionIsThrown() throws BindingSetNotFoundException { + void requireThatExceptionIsThrown() throws BindingSetNotFoundException { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); try { driver.newReference(URI.create("http://host")); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/service/CurrentContainerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/service/CurrentContainerTestCase.java index 6aa8b891480..99622f2f3d2 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/service/CurrentContainerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/service/CurrentContainerTestCase.java @@ -3,11 +3,11 @@ package com.yahoo.jdisc.service; import com.yahoo.jdisc.Request; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** @@ -16,7 +16,7 @@ import static org.junit.Assert.assertNotNull; public class CurrentContainerTestCase { @Test - public void requireThatNewRequestsCreateSnapshot() throws Exception { + void requireThatNewRequestsCreateSnapshot() throws Exception { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); driver.activateContainer(driver.newContainerBuilder()); Request request = new Request(driver, URI.create("http://host/path")); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/service/NoBindingSetSelectedTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/service/NoBindingSetSelectedTestCase.java index cd59f676d62..68733b35adb 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/service/NoBindingSetSelectedTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/service/NoBindingSetSelectedTestCase.java @@ -4,12 +4,12 @@ package com.yahoo.jdisc.service; import com.google.inject.AbstractModule; import com.yahoo.jdisc.application.BindingSetSelector; import com.yahoo.jdisc.test.TestDriver; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.net.URI; -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; /** @@ -18,14 +18,14 @@ import static org.junit.Assert.fail; public class NoBindingSetSelectedTestCase { @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { URI uri = URI.create("http://host/path"); NoBindingSetSelectedException e = new NoBindingSetSelectedException(uri); assertEquals(uri, e.uri()); } @Test - public void requireThatNoBindingSetSelectedIsThrown() { + void requireThatNoBindingSetSelectedIsThrown() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() { @Override diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingClientTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingClientTestCase.java index 82cf4953010..862acfa1ce4 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingClientTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingClientTestCase.java @@ -2,9 +2,9 @@ package com.yahoo.jdisc.test; import com.yahoo.jdisc.service.ClientProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -13,7 +13,7 @@ import static org.junit.Assert.fail; public class NonWorkingClientTestCase { @Test - public void requireThatHandleRequestThrowsException() { + void requireThatHandleRequestThrowsException() { ClientProvider client = new NonWorkingClientProvider(); try { client.handleRequest(null, null); @@ -24,7 +24,7 @@ public class NonWorkingClientTestCase { } @Test - public void requireThatHandleTimeoutThrowsException() { + void requireThatHandleTimeoutThrowsException() { ClientProvider client = new NonWorkingClientProvider(); try { client.handleTimeout(null, null); @@ -35,19 +35,19 @@ public class NonWorkingClientTestCase { } @Test - public void requireThatStartDoesNotThrow() { + void requireThatStartDoesNotThrow() { ClientProvider client = new NonWorkingClientProvider(); client.start(); } @Test - public void requireThatRetainDoesNotThrow() { + void requireThatRetainDoesNotThrow() { ClientProvider client = new NonWorkingClientProvider(); client.release(); } @Test - public void requireThatReleaseDoesNotThrow() { + void requireThatReleaseDoesNotThrow() { ClientProvider client = new NonWorkingClientProvider(); client.release(); } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingCompletionHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingCompletionHandlerTestCase.java index 7aff45e195f..edd4447cbe6 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingCompletionHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingCompletionHandlerTestCase.java @@ -2,9 +2,9 @@ package com.yahoo.jdisc.test; import com.yahoo.jdisc.handler.CompletionHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -13,7 +13,7 @@ import static org.junit.Assert.fail; public class NonWorkingCompletionHandlerTestCase { @Test - public void requireThatCompletedThrowsException() { + void requireThatCompletedThrowsException() { CompletionHandler completion = new NonWorkingCompletionHandler(); try { completion.completed(); @@ -24,7 +24,7 @@ public class NonWorkingCompletionHandlerTestCase { } @Test - public void requireThatFailedThrowsException() { + void requireThatFailedThrowsException() { CompletionHandler completion = new NonWorkingCompletionHandler(); try { completion.failed(null); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingContentChannelTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingContentChannelTestCase.java index 4b26a53442d..46bbbad95ca 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingContentChannelTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingContentChannelTestCase.java @@ -3,11 +3,11 @@ package com.yahoo.jdisc.test; import com.yahoo.jdisc.handler.CompletionHandler; import com.yahoo.jdisc.handler.ContentChannel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -16,7 +16,7 @@ import static org.junit.Assert.fail; public class NonWorkingContentChannelTestCase { @Test - public void requireThatWriteThrowsException() { + void requireThatWriteThrowsException() { ContentChannel content = new NonWorkingContentChannel(); try { content.write(null, null); @@ -48,7 +48,7 @@ public class NonWorkingContentChannelTestCase { } @Test - public void requireThatCloseThrowsException() { + void requireThatCloseThrowsException() { ContentChannel content = new NonWorkingContentChannel(); try { content.close(null); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingOsgiFrameworkTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingOsgiFrameworkTestCase.java index 64d670b3efe..96c4e66987d 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingOsgiFrameworkTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingOsgiFrameworkTestCase.java @@ -2,15 +2,15 @@ package com.yahoo.jdisc.test; import com.yahoo.jdisc.application.OsgiFramework; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; import java.util.Collections; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -19,26 +19,26 @@ import static org.junit.Assert.fail; public class NonWorkingOsgiFrameworkTestCase { @Test - public void requireThatFrameworkCanStartAndStop() throws BundleException { + void requireThatFrameworkCanStartAndStop() throws BundleException { OsgiFramework osgi = new NonWorkingOsgiFramework(); osgi.start(); osgi.stop(); } @Test - public void requireThatFrameworkHasNoBundles() throws BundleException { + void requireThatFrameworkHasNoBundles() throws BundleException { OsgiFramework osgi = new NonWorkingOsgiFramework(); assertTrue(osgi.bundles().isEmpty()); } @Test - public void requireThatFrameworkHasNoBundleContext() { + void requireThatFrameworkHasNoBundleContext() { OsgiFramework osgi = new NonWorkingOsgiFramework(); assertNull(osgi.bundleContext()); } @Test - public void requireThatFrameworkThrowsOnInstallBundle() throws BundleException { + void requireThatFrameworkThrowsOnInstallBundle() throws BundleException { OsgiFramework osgi = new NonWorkingOsgiFramework(); try { osgi.installBundle("file:bundle.jar"); @@ -49,7 +49,7 @@ public class NonWorkingOsgiFrameworkTestCase { } @Test - public void requireThatFrameworkThrowsOnStartBundles() throws BundleException { + void requireThatFrameworkThrowsOnStartBundles() throws BundleException { OsgiFramework osgi = new NonWorkingOsgiFramework(); try { osgi.startBundles(Collections.<Bundle>emptyList(), false); @@ -60,7 +60,7 @@ public class NonWorkingOsgiFrameworkTestCase { } @Test - public void requireThatFrameworkThrowsOnRefreshPackages() throws BundleException, InterruptedException { + void requireThatFrameworkThrowsOnRefreshPackages() throws BundleException, InterruptedException { OsgiFramework osgi = new NonWorkingOsgiFramework(); try { osgi.refreshPackages(); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestHandlerTestCase.java index 4d7e911907f..26713d78ca2 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestHandlerTestCase.java @@ -2,9 +2,9 @@ package com.yahoo.jdisc.test; import com.yahoo.jdisc.handler.RequestHandler; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -13,7 +13,7 @@ import static org.junit.Assert.fail; public class NonWorkingRequestHandlerTestCase { @Test - public void requireThatHandleRequestThrowsException() { + void requireThatHandleRequestThrowsException() { RequestHandler requestHandler = new NonWorkingRequestHandler(); try { requestHandler.handleRequest(null, null); @@ -24,7 +24,7 @@ public class NonWorkingRequestHandlerTestCase { } @Test - public void requireThatHandleTimeoutThrowsException() { + void requireThatHandleTimeoutThrowsException() { RequestHandler requestHandler = new NonWorkingRequestHandler(); try { requestHandler.handleTimeout(null, null); @@ -35,7 +35,7 @@ public class NonWorkingRequestHandlerTestCase { } @Test - public void requireThatDestroyDoesNotThrow() { + void requireThatDestroyDoesNotThrow() { RequestHandler requestHandler = new NonWorkingRequestHandler(); requestHandler.release(); } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestTestCase.java index b0d67102a12..31c08057c87 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingRequestTestCase.java @@ -3,10 +3,10 @@ package com.yahoo.jdisc.test; import com.google.inject.AbstractModule; import com.yahoo.jdisc.Request; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** @@ -15,12 +15,12 @@ import static org.junit.Assert.assertSame; public class NonWorkingRequestTestCase { @Test - public void requireThatFactoryMethodWorks() { + void requireThatFactoryMethodWorks() { assertNotNull(NonWorkingRequest.newInstance("scheme://host/path")); } @Test - public void requireThatGuiceModulesAreInjected() { + void requireThatGuiceModulesAreInjected() { Object obj = new Object(); Request request = NonWorkingRequest.newInstance("scheme://host/path", new AbstractModule() { diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingResponseHandlerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingResponseHandlerTestCase.java index 6b7af12c763..08b0a58b75c 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingResponseHandlerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingResponseHandlerTestCase.java @@ -2,9 +2,9 @@ package com.yahoo.jdisc.test; import com.yahoo.jdisc.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -13,7 +13,7 @@ import static org.junit.Assert.fail; public class NonWorkingResponseHandlerTestCase { @Test - public void requireThatHandleResponseThrowsException() { + void requireThatHandleResponseThrowsException() { NonWorkingResponseHandler handler = new NonWorkingResponseHandler(); try { handler.handleResponse(new Response(Response.Status.OK)); diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingServerTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingServerTestCase.java index 1666f737459..54fbb29afec 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingServerTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/NonWorkingServerTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.jdisc.test; import com.yahoo.jdisc.service.ServerProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Simon Thoresen Hult @@ -10,25 +10,25 @@ import org.junit.Test; public class NonWorkingServerTestCase { @Test - public void requireThatStartDoesNotThrow() { + void requireThatStartDoesNotThrow() { ServerProvider server = new NonWorkingServerProvider(); server.start(); } @Test - public void requireThatCloseDoesNotThrow() { + void requireThatCloseDoesNotThrow() { ServerProvider server = new NonWorkingServerProvider(); server.close(); } @Test - public void requireThatReferDoesNotThrow() { + void requireThatReferDoesNotThrow() { ServerProvider server = new NonWorkingServerProvider(); server.refer(); } @Test - public void requireThatReleaseDoesNotThrow() { + void requireThatReleaseDoesNotThrow() { ServerProvider server = new NonWorkingServerProvider(); server.release(); } diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/ServerProviderConformanceTestTest.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/ServerProviderConformanceTestTest.java index c9c7ec1db48..89befa40367 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/ServerProviderConformanceTestTest.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/ServerProviderConformanceTestTest.java @@ -12,7 +12,7 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.CurrentContainer; import com.yahoo.jdisc.service.ServerProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.net.URI; diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/test/TestDriverTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/test/TestDriverTestCase.java index 70ee85861e6..961e2998d8f 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/test/TestDriverTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/test/TestDriverTestCase.java @@ -11,13 +11,13 @@ import com.yahoo.jdisc.handler.ContentChannel; import com.yahoo.jdisc.handler.RequestDeniedException; import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.ContainerNotReadyException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.nio.ByteBuffer; -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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** @@ -26,7 +26,7 @@ import static org.junit.Assert.fail; public class TestDriverTestCase { @Test - public void requireThatFactoryMethodsWork() { + void requireThatFactoryMethodsWork() { TestDriver.newInjectedApplicationInstance(MyApplication.class).close(); TestDriver.newInjectedApplicationInstanceWithoutOsgi(MyApplication.class).close(); TestDriver.newInjectedApplicationInstance(new MyApplication()).close(); @@ -36,14 +36,14 @@ public class TestDriverTestCase { } @Test - public void requireThatAccessorsWork() { + void requireThatAccessorsWork() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); assertNotNull(driver.bootstrapLoader()); assertTrue(driver.close()); } @Test - public void requireThatConnectRequestWorks() { + void requireThatConnectRequestWorks() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = new MyRequestHandler(new MyContentChannel()); ContainerBuilder builder = driver.newContainerBuilder(); @@ -58,7 +58,7 @@ public class TestDriverTestCase { } @Test - public void requireThatDispatchRequestWorks() { + void requireThatDispatchRequestWorks() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); MyRequestHandler requestHandler = new MyRequestHandler(new MyContentChannel()); ContainerBuilder builder = driver.newContainerBuilder(); @@ -72,7 +72,7 @@ public class TestDriverTestCase { } @Test - public void requireThatFailedRequestCreateDoesNotBlockClose() { + void requireThatFailedRequestCreateDoesNotBlockClose() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); try { driver.connectRequest("scheme://host/path", new MyResponseHandler()); @@ -84,7 +84,7 @@ public class TestDriverTestCase { } @Test - public void requireThatFailedRequestConnectDoesNotBlockClose() { + void requireThatFailedRequestConnectDoesNotBlockClose() { TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); ContainerBuilder builder = driver.newContainerBuilder(); builder.serverBindings().bind("scheme://host/path", new MyRequestHandler(null)); |