From 926b611a6b8908854a58561fc0690bbd77019d14 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 16 Sep 2013 12:35:20 -0400 Subject: Use Arrays.asList instead of custom implementation 2013-09-16 Omair Majid * tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java (toList): Remove. (checkForMainFileLeakTest): Use Arrays.asList. * tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java (toList): Remove. (testToRelativePaths): Use Arrays.asList. --- .../jnlp/runtime/JNLPClassLoaderTest.java | 11 ++------- .../UnsignedAppletTrustConfirmationTest.java | 27 ++++++++-------------- 2 files changed, 12 insertions(+), 26 deletions(-) (limited to 'tests') diff --git a/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java b/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java index 169af7b..c3ff3a7 100644 --- a/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java +++ b/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java @@ -43,6 +43,7 @@ import static org.junit.Assert.fail; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.jar.Attributes; import java.util.jar.Manifest; @@ -131,14 +132,6 @@ public class JNLPClassLoaderTest { } } - static private List toList(T ... parts) { - List list = new ArrayList(); - for (T part : parts) { - list.add(part); - } - return list; - } - /* Note: Although it does a basic check, this mainly checks for file-descriptor leak */ @Test public void checkForMainFileLeakTest() throws Exception { @@ -152,7 +145,7 @@ public class JNLPClassLoaderTest { @Override public void run() { try { - classLoader.checkForMain(toList(jnlpFile.jarDesc)); + classLoader.checkForMain(Arrays.asList(jnlpFile.jarDesc)); } catch (LaunchException e) { fail(e.toString()); } diff --git a/tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java b/tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java index 31da5d3..0ec85de 100644 --- a/tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java +++ b/tests/netx/unit/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmationTest.java @@ -4,36 +4,29 @@ import static org.junit.Assert.assertEquals; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.junit.Test; public class UnsignedAppletTrustConfirmationTest { - private List toList(String ... parts) { - List list = new ArrayList(); - for (String part : parts) { - list.add(part); - } - return list; - } - @Test public void testToRelativePaths() throws Exception { /* Absolute -> Relative */ - assertEquals(toList("test.jar"), - UnsignedAppletTrustConfirmation.toRelativePaths(toList("http://example.com/test.jar"), "http://example.com/")); + assertEquals(Arrays.asList("test.jar"), + UnsignedAppletTrustConfirmation.toRelativePaths(Arrays.asList("http://example.com/test.jar"), "http://example.com/")); /* Relative is unchanged */ - assertEquals(toList("test.jar"), - UnsignedAppletTrustConfirmation.toRelativePaths(toList("test.jar"), "http://example.com/")); + assertEquals(Arrays.asList("test.jar"), + UnsignedAppletTrustConfirmation.toRelativePaths(Arrays.asList("test.jar"), "http://example.com/")); /* Different root URL is unchanged */ - assertEquals(toList("http://example2.com/test.jar"), - UnsignedAppletTrustConfirmation.toRelativePaths(toList("http://example2.com/test.jar"), "http://example.com/")); + assertEquals(Arrays.asList("http://example2.com/test.jar"), + UnsignedAppletTrustConfirmation.toRelativePaths(Arrays.asList("http://example2.com/test.jar"), "http://example.com/")); /* Path with invalid URL characters is handled */ - assertEquals(toList("test .jar"), - UnsignedAppletTrustConfirmation.toRelativePaths(toList("http://example.com/test .jar"), "http://example.com/")); + assertEquals(Arrays.asList("test .jar"), + UnsignedAppletTrustConfirmation.toRelativePaths(Arrays.asList("http://example.com/test .jar"), "http://example.com/")); } -} \ No newline at end of file +} -- cgit v1.2.3