diff options
Diffstat (limited to 'jdisc_core')
21 files changed, 139 insertions, 154 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/AbstractApplication.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/AbstractApplication.java index 71956691623..3485c07c74e 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/AbstractApplication.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/AbstractApplication.java @@ -6,7 +6,6 @@ import com.yahoo.jdisc.service.CurrentContainer; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; -import java.util.Arrays; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -67,7 +66,7 @@ public abstract class AbstractApplication implements Application { } public final List<Bundle> installAndStartBundle(String... locations) throws BundleException { - return installAndStartBundle(Arrays.asList(locations)); + return installAndStartBundle(List.of(locations)); } public final List<Bundle> installAndStartBundle(Iterable<String> locations) throws BundleException { @@ -75,7 +74,7 @@ public abstract class AbstractApplication implements Application { } public final void stopAndUninstallBundle(Bundle... bundles) throws BundleException { - stopAndUninstallBundle(Arrays.asList(bundles)); + stopAndUninstallBundle(List.of(bundles)); } public final void stopAndUninstallBundle(Iterable<Bundle> bundles) throws BundleException { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/GuiceRepository.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/GuiceRepository.java index fb3965108d8..5fc3b42055f 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/GuiceRepository.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/GuiceRepository.java @@ -13,7 +13,6 @@ import com.google.inject.spi.Elements; import com.yahoo.jdisc.Container; import org.osgi.framework.Bundle; -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; @@ -38,7 +37,7 @@ public class GuiceRepository implements Iterable<Module> { private Injector injector; public GuiceRepository(Module... modules) { - installAll(Arrays.asList(modules)); + installAll(List.of(modules)); } public Injector activate() { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/client/ClientDriver.java b/jdisc_core/src/main/java/com/yahoo/jdisc/client/ClientDriver.java index 8a5c8de92b9..beba03d7d84 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/client/ClientDriver.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/client/ClientDriver.java @@ -10,7 +10,6 @@ import com.yahoo.jdisc.core.FelixFramework; import com.yahoo.jdisc.core.FelixParams; import com.yahoo.jdisc.test.NonWorkingOsgiFramework; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -94,7 +93,7 @@ public abstract class ClientDriver { } private static List<Module> newModuleList(final ClientApplication appInstance, Module... guiceModules) { - List<Module> lst = new LinkedList<>(Arrays.asList(guiceModules)); + List<Module> lst = new LinkedList<>(List.of(guiceModules)); lst.add(new AbstractModule() { @Override @@ -108,7 +107,7 @@ public abstract class ClientDriver { private static List<Module> newModuleList(final Class<? extends ClientApplication> appClass, Module... guiceModules) { - List<Module> lst = new LinkedList<>(Arrays.asList(guiceModules)); + List<Module> lst = new LinkedList<>(List.of(guiceModules)); lst.add(new AbstractModule() { @Override diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java index 80e531c90af..2bf3e05baed 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixFramework.java @@ -14,7 +14,6 @@ import org.osgi.framework.FrameworkEvent; import org.osgi.framework.wiring.FrameworkWiring; import java.io.File; -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; @@ -150,14 +149,14 @@ public class FelixFramework implements OsgiFramework { @Override public List<Bundle> bundles() { - return Arrays.asList(felix.getBundleContext().getBundles()); + return List.of(felix.getBundleContext().getBundles()); } @Override public List<Bundle> getBundles(Bundle requestingBundle) { log.fine(() -> "All bundles: " + bundles()); log.fine(() -> "Getting visible bundles for bundle " + requestingBundle); - List<Bundle> visibleBundles = Arrays.asList(requestingBundle.getBundleContext().getBundles()); + List<Bundle> visibleBundles = List.of(requestingBundle.getBundleContext().getBundles()); log.fine(() -> "Visible bundles: " + visibleBundles); return visibleBundles; } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/test/TestDriver.java b/jdisc_core/src/main/java/com/yahoo/jdisc/test/TestDriver.java index 18449f207ee..64c690e89d4 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/test/TestDriver.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/test/TestDriver.java @@ -26,7 +26,6 @@ import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.jdisc.service.CurrentContainer; import java.net.URI; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.concurrent.Callable; @@ -311,7 +310,7 @@ public class TestDriver implements ContainerActivator, CurrentContainer { */ public static TestDriver newApplicationBundleInstance(String bundleLocation, boolean privileged, Module... guiceModules) { - return newInstance(newOsgiFramework(), bundleLocation, privileged, Arrays.asList(guiceModules)); + return newInstance(newOsgiFramework(), bundleLocation, privileged, List.of(guiceModules)); } /** @@ -326,7 +325,7 @@ public class TestDriver implements ContainerActivator, CurrentContainer { */ public static TestDriver newInstance(OsgiFramework osgiFramework, String bundleLocation, boolean privileged, Module... guiceModules) { - return newInstance(osgiFramework, bundleLocation, privileged, Arrays.asList(guiceModules)); + return newInstance(osgiFramework, bundleLocation, privileged, List.of(guiceModules)); } /** @@ -381,7 +380,7 @@ public class TestDriver implements ContainerActivator, CurrentContainer { private static List<Module> newModuleList(final Application app, final Class<? extends Application> appClass, Module... guiceModules) { List<Module> lst = new LinkedList<>(); - lst.addAll(Arrays.asList(guiceModules)); + lst.addAll(List.of(guiceModules)); lst.add(new AbstractModule() { @Override 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 7fe3c052566..acaed01a946 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/HeaderFieldsTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/HeaderFieldsTestCase.java @@ -3,7 +3,6 @@ package com.yahoo.jdisc; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -64,9 +63,9 @@ public class HeaderFieldsTestCase { @Test void requireThatContainsValueWorksAsExpected() { HeaderFields headers = new HeaderFields(); - assertFalse(headers.containsValue(Arrays.asList("bar"))); + assertFalse(headers.containsValue(List.of("bar"))); headers.add("foo", "bar"); - assertTrue(headers.containsValue(Arrays.asList("bar"))); + assertTrue(headers.containsValue(List.of("bar"))); } @Test @@ -102,19 +101,19 @@ public class HeaderFieldsTestCase { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.add("foo", "bar"); - assertEquals(Arrays.asList("bar"), headers.get("foo")); + assertEquals(List.of("bar"), headers.get("foo")); headers.add("foo", "baz"); - assertEquals(Arrays.asList("bar", "baz"), headers.get("foo")); + assertEquals(List.of("bar", "baz"), headers.get("foo")); } @Test void requireThatAddListWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); - headers.add("foo", Arrays.asList("bar")); - assertEquals(Arrays.asList("bar"), headers.get("foo")); - headers.add("foo", Arrays.asList("baz", "cox")); - assertEquals(Arrays.asList("bar", "baz", "cox"), headers.get("foo")); + headers.add("foo", List.of("bar")); + assertEquals(List.of("bar"), headers.get("foo")); + headers.add("foo", List.of("baz", "cox")); + assertEquals(List.of("bar", "baz", "cox"), headers.get("foo")); } @Test @@ -122,16 +121,16 @@ public class HeaderFieldsTestCase { HeaderFields headers = new HeaderFields(); headers.add("foo", "bar"); headers.add("bar", "baz"); - assertEquals(Arrays.asList("bar"), headers.get("foo")); - assertEquals(Arrays.asList("baz"), headers.get("bar")); + assertEquals(List.of("bar"), headers.get("foo")); + assertEquals(List.of("baz"), headers.get("bar")); Map<String, List<String>> map = new HashMap<>(); - map.put("foo", Arrays.asList("baz", "cox")); - map.put("bar", Arrays.asList("cox")); + map.put("foo", List.of("baz", "cox")); + map.put("bar", List.of("cox")); headers.addAll(map); - assertEquals(Arrays.asList("bar", "baz", "cox"), headers.get("foo")); - assertEquals(Arrays.asList("baz", "cox"), headers.get("bar")); + assertEquals(List.of("bar", "baz", "cox"), headers.get("foo")); + assertEquals(List.of("baz", "cox"), headers.get("bar")); } @Test @@ -139,19 +138,19 @@ public class HeaderFieldsTestCase { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.put("foo", "bar"); - assertEquals(Arrays.asList("bar"), headers.get("foo")); + assertEquals(List.of("bar"), headers.get("foo")); headers.put("foo", "baz"); - assertEquals(Arrays.asList("baz"), headers.get("foo")); + assertEquals(List.of("baz"), headers.get("foo")); } @Test void requireThatPutListWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); - headers.put("foo", Arrays.asList("bar")); - assertEquals(Arrays.asList("bar"), headers.get("foo")); - headers.put("foo", Arrays.asList("baz", "cox")); - assertEquals(Arrays.asList("baz", "cox"), headers.get("foo")); + headers.put("foo", List.of("bar")); + assertEquals(List.of("bar"), headers.get("foo")); + headers.put("foo", List.of("baz", "cox")); + assertEquals(List.of("baz", "cox"), headers.get("foo")); } @Test @@ -159,24 +158,24 @@ public class HeaderFieldsTestCase { HeaderFields headers = new HeaderFields(); headers.add("foo", "bar"); headers.add("bar", "baz"); - assertEquals(Arrays.asList("bar"), headers.get("foo")); - assertEquals(Arrays.asList("baz"), headers.get("bar")); + assertEquals(List.of("bar"), headers.get("foo")); + assertEquals(List.of("baz"), headers.get("bar")); Map<String, List<String>> map = new HashMap<>(); - map.put("foo", Arrays.asList("baz", "cox")); - map.put("bar", Arrays.asList("cox")); + map.put("foo", List.of("baz", "cox")); + map.put("bar", List.of("cox")); headers.putAll(map); - assertEquals(Arrays.asList("baz", "cox"), headers.get("foo")); - assertEquals(Arrays.asList("cox"), headers.get("bar")); + assertEquals(List.of("baz", "cox"), headers.get("foo")); + assertEquals(List.of("cox"), headers.get("bar")); } @Test void requireThatRemoveWorksAsExpected() { HeaderFields headers = new HeaderFields(); - headers.put("foo", Arrays.asList("bar", "baz")); - assertEquals(Arrays.asList("bar", "baz"), headers.get("foo")); - assertEquals(Arrays.asList("bar", "baz"), headers.remove("foo")); + headers.put("foo", List.of("bar", "baz")); + assertEquals(List.of("bar", "baz"), headers.get("foo")); + assertEquals(List.of("bar", "baz"), headers.remove("foo")); assertNull(headers.get("foo")); assertNull(headers.remove("foo")); } @@ -184,11 +183,11 @@ public class HeaderFieldsTestCase { @Test void requireThatRemoveStringWorksAsExpected() { HeaderFields headers = new HeaderFields(); - headers.put("foo", Arrays.asList("bar", "baz")); - assertEquals(Arrays.asList("bar", "baz"), headers.get("foo")); + headers.put("foo", List.of("bar", "baz")); + assertEquals(List.of("bar", "baz"), headers.get("foo")); assertTrue(headers.remove("foo", "bar")); assertFalse(headers.remove("foo", "cox")); - assertEquals(Arrays.asList("baz"), headers.get("foo")); + assertEquals(List.of("baz"), headers.get("foo")); assertTrue(headers.remove("foo", "baz")); assertFalse(headers.remove("foo", "cox")); assertNull(headers.get("foo")); @@ -199,8 +198,8 @@ public class HeaderFieldsTestCase { HeaderFields headers = new HeaderFields(); headers.add("foo", "bar"); headers.add("bar", "baz"); - assertEquals(Arrays.asList("bar"), headers.get("foo")); - assertEquals(Arrays.asList("baz"), headers.get("bar")); + assertEquals(List.of("bar"), headers.get("foo")); + assertEquals(List.of("baz"), headers.get("bar")); headers.clear(); assertNull(headers.get("foo")); assertNull(headers.get("bar")); @@ -211,14 +210,14 @@ public class HeaderFieldsTestCase { HeaderFields headers = new HeaderFields(); assertNull(headers.get("foo")); headers.add("foo", "bar"); - assertEquals(Arrays.asList("bar"), headers.get("foo")); + assertEquals(List.of("bar"), headers.get("foo")); } @Test void requireThatGetFirstWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertNull(headers.getFirst("foo")); - headers.add("foo", Arrays.asList("bar", "baz")); + headers.add("foo", List.of("bar", "baz")); assertEquals("bar", headers.getFirst("foo")); } @@ -226,17 +225,17 @@ public class HeaderFieldsTestCase { void requireThatIsTrueWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertFalse(headers.isTrue("foo")); - headers.put("foo", Arrays.asList("true")); + headers.put("foo", List.of("true")); assertTrue(headers.isTrue("foo")); - headers.put("foo", Arrays.asList("true", "true")); + headers.put("foo", List.of("true", "true")); assertTrue(headers.isTrue("foo")); - headers.put("foo", Arrays.asList("true", "false")); + headers.put("foo", List.of("true", "false")); assertFalse(headers.isTrue("foo")); - headers.put("foo", Arrays.asList("false", "true")); + headers.put("foo", List.of("false", "true")); assertFalse(headers.isTrue("foo")); - headers.put("foo", Arrays.asList("false", "false")); + headers.put("foo", List.of("false", "false")); assertFalse(headers.isTrue("foo")); - headers.put("foo", Arrays.asList("false")); + headers.put("foo", List.of("false")); assertFalse(headers.isTrue("foo")); } @@ -245,9 +244,9 @@ public class HeaderFieldsTestCase { HeaderFields headers = new HeaderFields(); assertTrue(headers.keySet().isEmpty()); headers.add("foo", "bar"); - assertEquals(new HashSet<>(Arrays.asList("foo")), headers.keySet()); + assertEquals(new HashSet<>(List.of("foo")), headers.keySet()); headers.add("bar", "baz"); - assertEquals(new HashSet<>(Arrays.asList("foo", "bar")), headers.keySet()); + assertEquals(new HashSet<>(List.of("foo", "bar")), headers.keySet()); } @Test @@ -257,34 +256,34 @@ public class HeaderFieldsTestCase { headers.add("foo", "bar"); Collection<List<String>> values = headers.values(); assertEquals(1, values.size()); - assertTrue(values.contains(Arrays.asList("bar"))); + assertTrue(values.contains(List.of("bar"))); headers.add("bar", "baz"); values = headers.values(); assertEquals(2, values.size()); - assertTrue(values.contains(Arrays.asList("bar"))); - assertTrue(values.contains(Arrays.asList("baz"))); + assertTrue(values.contains(List.of("bar"))); + assertTrue(values.contains(List.of("baz"))); } @Test void requireThatEntrySetWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertTrue(headers.entrySet().isEmpty()); - headers.put("foo", Arrays.asList("bar", "baz")); + headers.put("foo", List.of("bar", "baz")); Set<Map.Entry<String, List<String>>> entries = headers.entrySet(); assertEquals(1, entries.size()); Map.Entry<String, List<String>> entry = entries.iterator().next(); assertNotNull(entry); assertEquals("foo", entry.getKey()); - assertEquals(Arrays.asList("bar", "baz"), entry.getValue()); + assertEquals(List.of("bar", "baz"), entry.getValue()); } @Test void requireThatEntriesWorksAsExpected() { HeaderFields headers = new HeaderFields(); assertTrue(headers.entries().isEmpty()); - headers.put("foo", Arrays.asList("bar", "baz")); + headers.put("foo", List.of("bar", "baz")); List<Map.Entry<String, String>> entries = headers.entries(); assertEquals(2, entries.size()); 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 e35f1c69073..133472f5678 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 @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -480,13 +479,13 @@ public class BindingSetTestCase { for (int i = 0; i < expected.length; ++i) { actual.add(expected[(off + i) % expected.length]); } - assertOrder(Arrays.asList(expected), actual); + assertOrder(List.of(expected), actual); actual = new ArrayList<>(); for (int i = expected.length; --i >= 0; ) { actual.add(expected[(off + i) % expected.length]); } - assertOrder(Arrays.asList(expected), actual); + assertOrder(List.of(expected), actual); } } 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 6a704b1aacc..34ac6603e62 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 @@ -5,9 +5,9 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.osgi.framework.Bundle; -import java.util.Arrays; import java.util.Collection; import java.util.LinkedList; +import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; @@ -41,7 +41,7 @@ public class BundleInstallationExceptionTestCase { @Test void requireThatBundlesCollectionIsUnmodifiable() { - BundleInstallationException e = new BundleInstallationException(Arrays.asList(Mockito.mock(Bundle.class)), + BundleInstallationException e = new BundleInstallationException(List.of(Mockito.mock(Bundle.class)), new Throwable()); try { e.installedBundles().add(Mockito.mock(Bundle.class)); 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 9b3d61d7c89..3737647679d 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 @@ -8,7 +8,7 @@ import com.yahoo.jdisc.test.TestDriver; import org.junit.jupiter.api.Test; import java.net.URISyntaxException; -import java.util.Arrays; +import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; @@ -106,11 +106,11 @@ public class ContainerBuilderTestCase { assertTrue(ContainerBuilder.safeStringSplit(new Object(), ",").isEmpty()); assertTrue(ContainerBuilder.safeStringSplit("", ",").isEmpty()); assertTrue(ContainerBuilder.safeStringSplit(" \f\n\r\t", ",").isEmpty()); - assertEquals(Arrays.asList("foo"), ContainerBuilder.safeStringSplit("foo", ",")); - assertEquals(Arrays.asList("foo"), ContainerBuilder.safeStringSplit(" foo", ",")); - assertEquals(Arrays.asList("foo"), ContainerBuilder.safeStringSplit("foo ", ",")); - assertEquals(Arrays.asList("foo"), ContainerBuilder.safeStringSplit("foo, ", ",")); - assertEquals(Arrays.asList("foo"), ContainerBuilder.safeStringSplit("foo ,", ",")); - assertEquals(Arrays.asList("foo", "bar"), ContainerBuilder.safeStringSplit("foo, bar", ",")); + assertEquals(List.of("foo"), ContainerBuilder.safeStringSplit("foo", ",")); + assertEquals(List.of("foo"), ContainerBuilder.safeStringSplit(" foo", ",")); + assertEquals(List.of("foo"), ContainerBuilder.safeStringSplit("foo ", ",")); + assertEquals(List.of("foo"), ContainerBuilder.safeStringSplit("foo, ", ",")); + assertEquals(List.of("foo"), ContainerBuilder.safeStringSplit("foo ,", ",")); + assertEquals(List.of("foo", "bar"), ContainerBuilder.safeStringSplit("foo, bar", ",")); } } 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 ef09c854f72..0e5df5656c4 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 @@ -4,7 +4,6 @@ package com.yahoo.jdisc.application; import org.junit.jupiter.api.Test; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -42,14 +41,14 @@ public class GlobPatternTestCase { assertMatch("foo", "foo", Collections.<String>emptyList()); assertNotMatch("foo", "bar"); - assertMatch("*", "foo", Arrays.asList("foo")); - assertMatch("*", "bar", Arrays.asList("bar")); + assertMatch("*", "foo", List.of("foo")); + assertMatch("*", "bar", List.of("bar")); - assertMatch("*foo", "foo", Arrays.asList("")); - assertMatch("*oo", "foo", Arrays.asList("f")); - assertMatch("f*o", "foo", Arrays.asList("o")); - assertMatch("fo*", "foo", Arrays.asList("o")); - assertMatch("foo*", "foo", Arrays.asList("")); + assertMatch("*foo", "foo", List.of("")); + assertMatch("*oo", "foo", List.of("f")); + assertMatch("f*o", "foo", List.of("o")); + assertMatch("fo*", "foo", List.of("o")); + assertMatch("foo*", "foo", List.of("")); assertNotMatch("*foo", "bar"); assertNotMatch("*oo", "bar"); @@ -57,11 +56,11 @@ public class GlobPatternTestCase { assertNotMatch("fo*", "bar"); assertNotMatch("foo*", "bar"); - assertMatch("**foo", "foo", Arrays.asList("", "")); - assertMatch("**oo", "foo", Arrays.asList("", "f")); - assertMatch("f**o", "foo", Arrays.asList("", "o")); - assertMatch("fo**", "foo", Arrays.asList("", "o")); - assertMatch("foo**", "foo", Arrays.asList("", "")); + assertMatch("**foo", "foo", List.of("", "")); + assertMatch("**oo", "foo", List.of("", "f")); + assertMatch("f**o", "foo", List.of("", "o")); + assertMatch("fo**", "foo", List.of("", "o")); + assertMatch("foo**", "foo", List.of("", "")); assertNotMatch("**foo", "bar"); assertNotMatch("**oo", "bar"); @@ -70,9 +69,9 @@ public class GlobPatternTestCase { assertNotMatch("foo**", "bar"); assertMatch("foo bar", "foo bar", Collections.<String>emptyList()); - assertMatch("*foo *bar", "foo bar", Arrays.asList("", "")); - assertMatch("foo* bar*", "foo bar", Arrays.asList("", "")); - assertMatch("f* *r", "foo bar", Arrays.asList("oo", "ba")); + assertMatch("*foo *bar", "foo bar", List.of("", "")); + assertMatch("foo* bar*", "foo bar", List.of("", "")); + assertMatch("f* *r", "foo bar", List.of("oo", "ba")); assertNotMatch("foo bar", "baz cox"); assertNotMatch("*foo *bar", "baz cox"); 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 7aa8a16d856..30c917f9150 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 @@ -12,7 +12,6 @@ import com.google.inject.name.Named; import com.google.inject.name.Names; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -47,7 +46,7 @@ public class GuiceRepositoryTestCase { GuiceRepository guice = new GuiceRepository(); StringBinding foo = new StringBinding("fooKey", "fooVal"); StringBinding bar = new StringBinding("barKey", "barVal"); - guice.installAll(Arrays.asList(foo, bar)); + guice.installAll(List.of(foo, bar)); assertBinding(guice, "fooKey", "fooVal"); assertBinding(guice, "barKey", "barVal"); @@ -77,12 +76,12 @@ public class GuiceRepositoryTestCase { StringBinding foo = new StringBinding("fooKey", "fooVal"); StringBinding bar = new StringBinding("barKey", "barVal"); StringBinding baz = new StringBinding("bazKey", "bazVal"); - guice.installAll(Arrays.asList(foo, bar, baz)); + guice.installAll(List.of(foo, bar, baz)); assertBinding(guice, "fooKey", "fooVal"); assertBinding(guice, "barKey", "barVal"); assertBinding(guice, "bazKey", "bazVal"); - guice.uninstallAll(Arrays.asList(foo, baz)); + guice.uninstallAll(List.of(foo, baz)); assertNoBinding(guice, "fooKey"); assertBinding(guice, "barKey", "barVal"); assertNoBinding(guice, "bazKey"); @@ -122,7 +121,7 @@ public class GuiceRepositoryTestCase { void requireThatPrivateModulesWorks() { GuiceRepository guice = new GuiceRepository(); - List<Named> names = Arrays.asList(Names.named("A"), Names.named("B")); + List<Named> names = List.of(Names.named("A"), Names.named("B")); for (Named name : names) { guice.install(createPrivateInjectNameModule(name)); 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 3a2db7d1e75..a54a42228e4 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 @@ -5,8 +5,8 @@ import com.yahoo.jdisc.NoopSharedResource; import com.yahoo.jdisc.service.ServerProvider; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Iterator; +import java.util.List; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -35,7 +35,7 @@ public class ServerRepositoryTestCase { ServerRepository servers = newServerRepository(); ServerProvider foo = new MyServer(); ServerProvider bar = new MyServer(); - servers.installAll(Arrays.asList(foo, bar)); + servers.installAll(List.of(foo, bar)); Iterator<ServerProvider> it = servers.iterator(); assertTrue(it.hasNext()); @@ -60,8 +60,8 @@ public class ServerRepositoryTestCase { ServerProvider foo = new MyServer(); ServerProvider bar = new MyServer(); ServerProvider baz = new MyServer(); - servers.installAll(Arrays.asList(foo, bar, baz)); - servers.uninstallAll(Arrays.asList(foo, bar)); + servers.installAll(List.of(foo, bar, baz)); + servers.uninstallAll(List.of(foo, bar)); Iterator<ServerProvider> it = servers.iterator(); assertNotNull(it); assertTrue(it.hasNext()); 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 063ddc81f45..0f8016eba10 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 @@ -5,7 +5,6 @@ import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -49,19 +48,19 @@ public class UriPatternTestCase { assertNotMatch(pattern, "barbaz://host:69/path"); pattern = new UriPattern("*://host:69/path"); - assertMatch(pattern, "foobar://host:69/path", Arrays.asList("foobar")); - assertMatch(pattern, "bar://host:69/path", Arrays.asList("bar")); - assertMatch(pattern, "barbaz://host:69/path", Arrays.asList("barbaz")); + assertMatch(pattern, "foobar://host:69/path", List.of("foobar")); + assertMatch(pattern, "bar://host:69/path", List.of("bar")); + assertMatch(pattern, "barbaz://host:69/path", List.of("barbaz")); pattern = new UriPattern("*bar://host:69/path"); - assertMatch(pattern, "foobar://host:69/path", Arrays.asList("foo")); - assertMatch(pattern, "bar://host:69/path", Arrays.asList("")); + assertMatch(pattern, "foobar://host:69/path", List.of("foo")); + assertMatch(pattern, "bar://host:69/path", List.of("")); assertNotMatch(pattern, "barbaz://host:69/path"); pattern = new UriPattern("bar*://host:69/path"); assertNotMatch(pattern, "foobar://host:69/path"); - assertMatch(pattern, "bar://host:69/path", Arrays.asList("")); - assertMatch(pattern, "barbaz://host:69/path", Arrays.asList("baz")); + assertMatch(pattern, "bar://host:69/path", List.of("")); + assertMatch(pattern, "barbaz://host:69/path", List.of("baz")); // host matching pattern = new UriPattern("scheme://bar:69/path"); @@ -70,19 +69,19 @@ public class UriPatternTestCase { assertNotMatch(pattern, "scheme://barbaz:69/path"); pattern = new UriPattern("scheme://*:69/path"); - assertMatch(pattern, "scheme://foobar:69/path", Arrays.asList("foobar")); - assertMatch(pattern, "scheme://bar:69/path", Arrays.asList("bar")); - assertMatch(pattern, "scheme://barbaz:69/path", Arrays.asList("barbaz")); + assertMatch(pattern, "scheme://foobar:69/path", List.of("foobar")); + assertMatch(pattern, "scheme://bar:69/path", List.of("bar")); + assertMatch(pattern, "scheme://barbaz:69/path", List.of("barbaz")); pattern = new UriPattern("scheme://*bar:69/path"); - assertMatch(pattern, "scheme://foobar:69/path", Arrays.asList("foo")); - assertMatch(pattern, "scheme://bar:69/path", Arrays.asList("")); + assertMatch(pattern, "scheme://foobar:69/path", List.of("foo")); + assertMatch(pattern, "scheme://bar:69/path", List.of("")); assertNotMatch(pattern, "scheme://barbaz:69/path"); pattern = new UriPattern("scheme://bar*:69/path"); assertNotMatch(pattern, "scheme://foobar:69/path"); - assertMatch(pattern, "scheme://bar:69/path", Arrays.asList("")); - assertMatch(pattern, "scheme://barbaz:69/path", Arrays.asList("baz")); + assertMatch(pattern, "scheme://bar:69/path", List.of("")); + assertMatch(pattern, "scheme://barbaz:69/path", List.of("baz")); // port matching pattern = new UriPattern("scheme://host:69/path"); @@ -91,9 +90,9 @@ public class UriPatternTestCase { assertNotMatch(pattern, "scheme://host:699/path"); pattern = new UriPattern("scheme://host:*/path"); - assertMatch(pattern, "scheme://host:669/path", Arrays.asList("669")); - assertMatch(pattern, "scheme://host:69/path", Arrays.asList("69")); - assertMatch(pattern, "scheme://host:699/path", Arrays.asList("699")); + assertMatch(pattern, "scheme://host:669/path", List.of("669")); + assertMatch(pattern, "scheme://host:69/path", List.of("69")); + assertMatch(pattern, "scheme://host:699/path", List.of("699")); // path matching pattern = new UriPattern("scheme://host:69/"); @@ -106,20 +105,20 @@ public class UriPatternTestCase { assertNotMatch(pattern, "scheme://host:69/barbaz"); pattern = new UriPattern("scheme://host:69/*"); - assertMatch(pattern, "scheme://host:69/", Arrays.asList("")); - assertMatch(pattern, "scheme://host:69/foobar", Arrays.asList("foobar")); - assertMatch(pattern, "scheme://host:69/bar", Arrays.asList("bar")); - assertMatch(pattern, "scheme://host:69/barbaz", Arrays.asList("barbaz")); + assertMatch(pattern, "scheme://host:69/", List.of("")); + assertMatch(pattern, "scheme://host:69/foobar", List.of("foobar")); + assertMatch(pattern, "scheme://host:69/bar", List.of("bar")); + assertMatch(pattern, "scheme://host:69/barbaz", List.of("barbaz")); pattern = new UriPattern("scheme://host:69/*bar"); - assertMatch(pattern, "scheme://host:69/foobar", Arrays.asList("foo")); - assertMatch(pattern, "scheme://host:69/bar", Arrays.asList("")); + assertMatch(pattern, "scheme://host:69/foobar", List.of("foo")); + assertMatch(pattern, "scheme://host:69/bar", List.of("")); assertNotMatch(pattern, "scheme://host:69/barbaz"); pattern = new UriPattern("scheme://host:69/bar*"); assertNotMatch(pattern, "scheme://host:69/foobar"); - assertMatch(pattern, "scheme://host:69/bar", Arrays.asList("")); - assertMatch(pattern, "scheme://host:69/barbaz", Arrays.asList("baz")); + assertMatch(pattern, "scheme://host:69/bar", List.of("")); + assertMatch(pattern, "scheme://host:69/barbaz", List.of("baz")); } @Test @@ -128,7 +127,7 @@ public class UriPatternTestCase { assertNotMatch(pattern, "scheme://host"); pattern = new UriPattern("scheme://host/*"); - assertMatch(pattern, "scheme://host", Arrays.asList("")); + assertMatch(pattern, "scheme://host", List.of("")); } @Test @@ -141,8 +140,8 @@ public class UriPatternTestCase { @Test 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")); + assertMatch(pattern, "scheme://a.host/path", List.of("a")); + assertMatch(pattern, "scheme://a.b.host/path", List.of("a.b")); } @Test 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 478f15f721d..53a29cf22c1 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 @@ -8,7 +8,6 @@ import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -36,7 +35,7 @@ public class BindingMatchingTestCase { 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)) { + for (int numBindings : List.of(1, 10, 25, 50, 100, 250)) { BindingRepository<Object> repo = new BindingRepository<>(); for (int binding = 0; binding < numBindings; ++binding) { repo.bind("http://*/v" + binding + "/*/data/", new Object()); 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 5301eb297b4..cb9114f2981 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 @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; @@ -20,7 +19,7 @@ public class UriMatchingTestCase { @Test void requireThatUriPatternMatchingIsFast() { - List<String> inputs = Arrays.asList( + List<String> inputs = List.of( "other://host/", "scheme://other/", "scheme://host/", 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 d8aa553b628..95511b3ed1c 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 @@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; -import java.util.Arrays; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -54,7 +54,7 @@ public class ApplicationRestartTestCase { private static ApplicationLoader newApplicationLoader() { return new ApplicationLoader(new NonWorkingOsgiFramework(), - Arrays.asList(new AbstractModule() { + List.of(new AbstractModule() { @Override public void configure() { bind(Application.class).to(SimpleApplication.class); 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 252b7074a2c..25399433e2e 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 @@ -4,7 +4,6 @@ package com.yahoo.jdisc.core; import org.junit.jupiter.api.Test; import org.osgi.framework.Constants; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -60,8 +59,8 @@ public class FelixParamsTestCase { assertEquals(prev.length + 2, next.length); List<String> diff = new LinkedList<>(); - diff.addAll(Arrays.asList(next)); - diff.removeAll(Arrays.asList(prev)); + diff.addAll(List.of(next)); + diff.removeAll(List.of(prev)); assertEquals(2, diff.size()); assertTrue(diff.contains("foo")); assertTrue(diff.contains("bar")); 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 a9ac904c36c..c37b6ffe915 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 @@ -3,8 +3,8 @@ package com.yahoo.jdisc.core; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.LinkedList; +import java.util.List; import java.util.Queue; import static com.yahoo.jdisc.core.ScheduledQueue.MILLIS_PER_SLOT; @@ -123,6 +123,6 @@ public class ScheduledQueueTestCase { Queue<Object> expired = new LinkedList<>(); queue.drainTo(currentTimeMillis, expired); assertEquals(expected.length, expired.size()); - assertEquals(Arrays.asList(expected), expired); + assertEquals(List.of(expected), expired); } } 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 c672b33ff2b..acfe8d32e61 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 @@ -12,7 +12,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URI; import java.nio.ByteBuffer; -import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; @@ -31,7 +30,7 @@ public class RequestDispatchTestCase { @Test void requireThatRequestCanBeDispatched() throws Exception { final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(); - final List<ByteBuffer> writtenContent = Arrays.asList(ByteBuffer.allocate(6), ByteBuffer.allocate(9)); + final List<ByteBuffer> writtenContent = List.of(ByteBuffer.allocate(6), ByteBuffer.allocate(9)); ReadableContentChannel receivedContent = new ReadableContentChannel(); ContainerBuilder builder = driver.newContainerBuilder(); Response response = new Response(Response.Status.OK); @@ -154,7 +153,7 @@ public class RequestDispatchTestCase { @Override protected Iterable<ByteBuffer> requestContent() { - return Arrays.asList(ByteBuffer.allocate(69)); + return List.of(ByteBuffer.allocate(69)); } }.dispatch(); fail(); @@ -192,7 +191,7 @@ public class RequestDispatchTestCase { @Override protected Iterable<ByteBuffer> requestContent() { - return Arrays.asList(ByteBuffer.allocate(69)); + return List.of(ByteBuffer.allocate(69)); } }.dispatch(); fail(); 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 84bdc07dd33..32481b4607e 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 @@ -8,7 +8,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; -import java.util.Arrays; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; @@ -46,7 +45,7 @@ public class ResponseDispatchTestCase { ReadableContentChannel content = new ReadableContentChannel(); FutureResponse handler = new FutureResponse(content); ByteBuffer buf = ByteBuffer.allocate(69); - ResponseDispatch.newInstance(69, Arrays.asList(buf)).dispatch(handler); + ResponseDispatch.newInstance(69, List.of(buf)).dispatch(handler); Response response = handler.get(600, TimeUnit.SECONDS); assertNotNull(response); assertEquals(69, response.getStatus()); @@ -57,7 +56,7 @@ public class ResponseDispatchTestCase { ReadableContentChannel content = new ReadableContentChannel(); FutureResponse handler = new FutureResponse(content); ByteBuffer buf = ByteBuffer.allocate(69); - ResponseDispatch.newInstance(69, Arrays.asList(buf)).dispatch(handler); + ResponseDispatch.newInstance(69, List.of(buf)).dispatch(handler); Response response = handler.get(600, TimeUnit.SECONDS); assertNotNull(response); assertEquals(69, response.getStatus()); @@ -69,7 +68,7 @@ public class ResponseDispatchTestCase { FutureResponse handler = new FutureResponse(content); ByteBuffer buf = ByteBuffer.allocate(69); Response sentResponse = new Response(69); - ResponseDispatch.newInstance(sentResponse, Arrays.asList(buf)).dispatch(handler); + ResponseDispatch.newInstance(sentResponse, List.of(buf)).dispatch(handler); Response receivedResponse = handler.get(600, TimeUnit.SECONDS); assertSame(sentResponse, receivedResponse); assertSame(buf, content.read()); @@ -80,7 +79,7 @@ public class ResponseDispatchTestCase { @Test void requireThatResponseCanBeDispatched() throws Exception { final Response response = new Response(Response.Status.OK); - final List<ByteBuffer> writtenContent = Arrays.asList(ByteBuffer.allocate(6), ByteBuffer.allocate(9)); + final List<ByteBuffer> writtenContent = List.of(ByteBuffer.allocate(6), ByteBuffer.allocate(9)); ResponseDispatch dispatch = new ResponseDispatch() { @Override 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 84da19c221a..56d7d2959e8 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 @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; import java.net.URI; import java.nio.ByteBuffer; -import java.util.Arrays; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; @@ -170,7 +170,7 @@ public class ThreadedRequestHandlerTestCase { @Override protected Iterable<ByteBuffer> requestContent() { - return Arrays.asList(content); + return List.of(content); } }.dispatch(); } |