/hg/icedtea-web: Move inner test class MockedOneJarJNLPFile to t...

adomurad at icedtea.classpath.org adomurad at icedtea.classpath.org
Wed May 29 12:41:42 PDT 2013


changeset 2566a700bd86 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=2566a700bd86
author: Adam Domurad <adomurad at redhat.com>
date: Wed May 29 15:43:21 2013 -0400

	Move inner test class MockedOneJarJNLPFile to top-level DummyJNLPFileWithJar


diffstat:

 ChangeLog                                                                 |   8 +
 tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java     |  58 +--------
 tests/test-extensions/net/sourceforge/jnlp/mock/DummyJNLPFileWithJar.java |  54 +++++++++
 3 files changed, 69 insertions(+), 51 deletions(-)

diffs (200 lines):

diff -r acc70a489a2d -r 2566a700bd86 ChangeLog
--- a/ChangeLog	Wed May 29 10:54:44 2013 -0400
+++ b/ChangeLog	Wed May 29 15:43:21 2013 -0400
@@ -1,3 +1,11 @@
+2013-05-29  Adam Domurad  <adomurad at redhat.com>
+
+	* tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java:
+	Moved & renamed inner MockedOneJarJNLPFile to top-level 
+	DummyJNLPFileWithJar class.
+	* tests/test-extensions/net/sourceforge/jnlp/mock/DummyJNLPFileWithJar.java:
+	Moved & renamed from JNLPClassLoaderTest.MockedOneJarJNLPFile. 
+
 2013-05-29  Adam Domurad  <adomurad at redhat.com>
 
 	* netx/net/sourceforge/jnlp/resources/Messages.properties:
diff -r acc70a489a2d -r 2566a700bd86 tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java	Wed May 29 10:54:44 2013 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java	Wed May 29 15:43:21 2013 -0400
@@ -42,25 +42,20 @@
 
 import java.io.File;
 import java.lang.management.ManagementFactory;
-import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Locale;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import net.sourceforge.jnlp.InformationDesc;
 import net.sourceforge.jnlp.JARDesc;
-import net.sourceforge.jnlp.JNLPFile;
 import net.sourceforge.jnlp.LaunchException;
-import net.sourceforge.jnlp.ResourcesDesc;
-import net.sourceforge.jnlp.SecurityDesc;
 import net.sourceforge.jnlp.ServerAccess;
 import net.sourceforge.jnlp.Version;
 import net.sourceforge.jnlp.cache.UpdatePolicy;
+import net.sourceforge.jnlp.mock.DummyJNLPFileWithJar;
 import net.sourceforge.jnlp.util.StreamUtils;
 
 import org.junit.Test;
@@ -123,49 +118,10 @@
         return createTempJar(jarName, "");
     }
 
-    /* Create a JARDesc for the given URL location */
-    static private JARDesc makeJarDesc(URL jarLocation) {
-        return new JARDesc(jarLocation, new Version("1"), null, false,false, false,false);
-    }
-
-    /* A mocked dummy JNLP file with a single JAR. */
-    private class MockedOneJarJNLPFile extends JNLPFile {
-        URL codeBase, jarLocation;
-        JARDesc jarDesc;
-
-        MockedOneJarJNLPFile(File jarFile) throws MalformedURLException {
-            codeBase = jarFile.getParentFile().toURI().toURL();
-            jarLocation = jarFile.toURI().toURL();
-            jarDesc = makeJarDesc(jarLocation); 
-            info = new ArrayList<InformationDesc>();
-        }
-
-        @Override
-        public ResourcesDesc getResources() {
-            ResourcesDesc resources = new ResourcesDesc(null, new Locale[0], new String[0], new String[0]);
-            resources.addResource(jarDesc);
-            return resources;
-        }
-        @Override
-        public ResourcesDesc[] getResourcesDescs(final Locale locale, final String os, final String arch) {
-            return new ResourcesDesc[] { getResources() };
-        }
-
-        @Override
-        public URL getCodeBase() {
-            return codeBase;
-        }
-
-        @Override
-        public SecurityDesc getSecurity() {
-            return new SecurityDesc(this, SecurityDesc.SANDBOX_PERMISSIONS, null);
-        }
-    };
-
     /* Note: Only does file leak testing for now. */
     @Test
     public void constructorFileLeakTest() throws Exception {
-        final MockedOneJarJNLPFile jnlpFile = new MockedOneJarJNLPFile(createTempJar("test.jar"));
+        final DummyJNLPFileWithJar jnlpFile = new DummyJNLPFileWithJar(createTempJar("test.jar"));
 
         assertNoFileLeak( new Runnable () {
             @Override
@@ -183,7 +139,7 @@
      * However, it is tricky without it erroring-out. */
     @Test
     public void isInvalidJarTest() throws Exception {
-        final MockedOneJarJNLPFile jnlpFile = new MockedOneJarJNLPFile(createTempJar("test.jar"));
+        final DummyJNLPFileWithJar jnlpFile = new DummyJNLPFileWithJar(createTempJar("test.jar"));
         final JNLPClassLoader classLoader = new JNLPClassLoader(jnlpFile, UpdatePolicy.ALWAYS);
 
         assertNoFileLeak( new Runnable () {
@@ -198,7 +154,7 @@
     /* Note: Only does file leak testing for now, but more testing could be added. */
     @Test
     public void activateNativeFileLeakTest() throws Exception {
-        final MockedOneJarJNLPFile jnlpFile = new MockedOneJarJNLPFile(createTempJar("test.jar"));
+        final DummyJNLPFileWithJar jnlpFile = new DummyJNLPFileWithJar(createTempJar("test.jar"));
         final JNLPClassLoader classLoader = new JNLPClassLoader(jnlpFile, UpdatePolicy.ALWAYS);
 
         assertNoFileLeak( new Runnable () {
@@ -212,7 +168,7 @@
     @Test
     public void getMainClassNameTest() throws Exception {
         /* Test with main-class */{
-            final MockedOneJarJNLPFile jnlpFile = new MockedOneJarJNLPFile(createTempJar("test.jar", "Main-Class: DummyClass\n"));
+            final DummyJNLPFileWithJar jnlpFile = new DummyJNLPFileWithJar(createTempJar("test.jar", "Main-Class: DummyClass\n"));
             final JNLPClassLoader classLoader = new JNLPClassLoader(jnlpFile, UpdatePolicy.ALWAYS);
 
             assertNoFileLeak(new Runnable() {
@@ -223,7 +179,7 @@
             });
         }
         /* Test with-out main-class */{
-            final MockedOneJarJNLPFile jnlpFile = new MockedOneJarJNLPFile(createTempJar("test.jar", ""));
+            final DummyJNLPFileWithJar jnlpFile = new DummyJNLPFileWithJar(createTempJar("test.jar", ""));
             final JNLPClassLoader classLoader = new JNLPClassLoader(jnlpFile, UpdatePolicy.ALWAYS);
 
             assertNoFileLeak(new Runnable() {
@@ -246,7 +202,7 @@
     /* Note: Although it does a basic check, this mainly checks for file-descriptor leak */
     @Test
     public void checkForMainFileLeakTest() throws Exception {
-        final MockedOneJarJNLPFile jnlpFile = new MockedOneJarJNLPFile(createTempJar("test.jar", ""));
+        final DummyJNLPFileWithJar jnlpFile = new DummyJNLPFileWithJar(createTempJar("test.jar", ""));
         final JNLPClassLoader classLoader = new JNLPClassLoader(jnlpFile, UpdatePolicy.ALWAYS);
         assertNoFileLeak(new Runnable() {
             @Override
diff -r acc70a489a2d -r 2566a700bd86 tests/test-extensions/net/sourceforge/jnlp/mock/DummyJNLPFileWithJar.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-extensions/net/sourceforge/jnlp/mock/DummyJNLPFileWithJar.java	Wed May 29 15:43:21 2013 -0400
@@ -0,0 +1,54 @@
+package net.sourceforge.jnlp.mock;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Locale;
+
+import net.sourceforge.jnlp.InformationDesc;
+import net.sourceforge.jnlp.JARDesc;
+import net.sourceforge.jnlp.JNLPFile;
+import net.sourceforge.jnlp.ResourcesDesc;
+import net.sourceforge.jnlp.SecurityDesc;
+import net.sourceforge.jnlp.Version;
+
+/* A mocked dummy JNLP file with a single JAR. */
+public class DummyJNLPFileWithJar extends JNLPFile {
+
+    /* Create a JARDesc for the given URL location */
+    static JARDesc makeJarDesc(URL jarLocation) {
+        return new JARDesc(jarLocation, new Version("1"), null, false,false, false,false);
+    }
+
+    public URL codeBase, jarLocation;
+    public JARDesc jarDesc;
+
+    public DummyJNLPFileWithJar(File jarFile) throws MalformedURLException {
+        codeBase = jarFile.getParentFile().toURI().toURL();
+        jarLocation = jarFile.toURI().toURL();
+        jarDesc = makeJarDesc(jarLocation); 
+        info = new ArrayList<InformationDesc>();
+    }
+
+    @Override
+    public ResourcesDesc getResources() {
+        ResourcesDesc resources = new ResourcesDesc(null, new Locale[0], new String[0], new String[0]);
+        resources.addResource(jarDesc);
+        return resources;
+    }
+    @Override
+    public ResourcesDesc[] getResourcesDescs(final Locale locale, final String os, final String arch) {
+        return new ResourcesDesc[] { getResources() };
+    }
+
+    @Override
+    public URL getCodeBase() {
+        return codeBase;
+    }
+
+    @Override
+    public SecurityDesc getSecurity() {
+        return new SecurityDesc(this, SecurityDesc.SANDBOX_PERMISSIONS, null);
+    }
+}
\ No newline at end of file



More information about the distro-pkg-dev mailing list