Mercurial > hg > release > icedtea-web-1.5
changeset 739:2566a700bd86
Move inner test class MockedOneJarJNLPFile to top-level DummyJNLPFileWithJar
author | Adam Domurad <adomurad@redhat.com> |
---|---|
date | Wed, 29 May 2013 15:43:21 -0400 |
parents | acc70a489a2d |
children | 8e6aa48abeba |
files | ChangeLog tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java tests/test-extensions/net/sourceforge/jnlp/mock/DummyJNLPFileWithJar.java |
diffstat | 3 files changed, 69 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- 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@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@redhat.com> * netx/net/sourceforge/jnlp/resources/Messages.properties:
--- 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
--- /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