# HG changeset patch # User Omair Majid # Date 1378927182 14400 # Node ID a875c8f789f2785f2c320c457705c6f6dc61d839 # Parent a0ca905f9ee7c55933f788258a8319c7fdeef493 PR1533: Inherit jnlp.packEnabled and jnlp.versionEnabled like other properties Treat jnlp.packEnabled and jnlp.versionEnabled just like other properties that can be set in one resource element and inherited/filtered in others. 2013-09-09 Omair Majid * netx/net/sourceforge/jnlp/JNLPFile.java (getDownloadOptionsForJar): Rename to ... (getDownloadOptions): New method. Look up jnlp.packEnabled and jnlp.versionEnabled in any resources element. * netx/net/sourceforge/jnlp/PluginBridge.java (getDownloadOptionsForJar): Rename to ... (getDownloadOptions): New method. * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java (initializeResources): Invoke file.getDownloadResources. (getDownloadOptionsForJar): Remove. * tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java (testDownloadOptionsAppliedEverywhere): New method. (testDownloadOptionsFilteredOut): New method. diff -r a0ca905f9ee7 -r a875c8f789f2 ChangeLog --- a/ChangeLog Tue Jul 30 09:41:12 2013 -0400 +++ b/ChangeLog Wed Sep 11 15:19:42 2013 -0400 @@ -1,3 +1,19 @@ +2013-09-09 Omair Majid + + * netx/net/sourceforge/jnlp/JNLPFile.java + (getDownloadOptionsForJar): Rename to ... + (getDownloadOptions): New method. Look up jnlp.packEnabled and + jnlp.versionEnabled in any resources element. + * netx/net/sourceforge/jnlp/PluginBridge.java + (getDownloadOptionsForJar): Rename to ... + (getDownloadOptions): New method. + * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java + (initializeResources): Invoke file.getDownloadResources. + (getDownloadOptionsForJar): Remove. + * tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java + (testDownloadOptionsAppliedEverywhere): New method. + (testDownloadOptionsFilteredOut): New method. + 2013-07-30 Andrew Azores * netx/net/sourceforge/jnlp/runtime/RhinoBasedPacEvaluator.java: (getProxiesWithoutCaching) added java.vm.name read permission to fix diff -r a0ca905f9ee7 -r a875c8f789f2 netx/net/sourceforge/jnlp/JNLPFile.java --- a/netx/net/sourceforge/jnlp/JNLPFile.java Tue Jul 30 09:41:12 2013 -0400 +++ b/netx/net/sourceforge/jnlp/JNLPFile.java Wed Sep 11 15:19:42 2013 -0400 @@ -789,29 +789,17 @@ } /** - * XXX: this method does a "==" comparison between the input JARDesc and - * jars it finds through getResourcesDescs(). If ever the implementation - * of that function should change to return copies of JARDescs objects, - * then the "jar == aJar" comparison below should change accordingly. - * @param jar the jar whose download options to get. - * @return the download options. + * @return the download options to use for downloading jars listed in this jnlp file. */ - public DownloadOptions getDownloadOptionsForJar(JARDesc jar) { + public DownloadOptions getDownloadOptions() { boolean usePack = false; boolean useVersion = false; - ResourcesDesc[] descs = getResourcesDescs(); - for (ResourcesDesc desc: descs) { - JARDesc[] jars = desc.getJARs(); - for (JARDesc aJar: jars) { - if (jar == aJar) { - if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.packEnabled"))) { - usePack = true; - } - if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.versionEnabled"))) { - useVersion = true; - } - } - } + ResourcesDesc desc = getResources(); + if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.packEnabled"))) { + usePack = true; + } + if (Boolean.valueOf(desc.getPropertiesMap().get("jnlp.versionEnabled"))) { + useVersion = true; } return new DownloadOptions(usePack, useVersion); } diff -r a0ca905f9ee7 -r a875c8f789f2 netx/net/sourceforge/jnlp/PluginBridge.java --- a/netx/net/sourceforge/jnlp/PluginBridge.java Tue Jul 30 09:41:12 2013 -0400 +++ b/netx/net/sourceforge/jnlp/PluginBridge.java Wed Sep 11 15:19:42 2013 -0400 @@ -222,7 +222,7 @@ * {@inheritDoc } */ @Override - public DownloadOptions getDownloadOptionsForJar(JARDesc jar) { + public DownloadOptions getDownloadOptions() { return new DownloadOptions(usePack, useVersion); } diff -r a0ca905f9ee7 -r a875c8f789f2 netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Jul 30 09:41:12 2013 -0400 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Wed Sep 11 15:19:42 2013 -0400 @@ -639,7 +639,7 @@ tracker.addResource(jars[i].getLocation(), jars[i].getVersion(), - getDownloadOptionsForJar(jars[i]), + file.getDownloadOptions(), jars[i].isCacheable() ? JNLPRuntime.getDefaultUpdatePolicy() : UpdatePolicy.FORCE ); } @@ -2078,10 +2078,6 @@ } } - private DownloadOptions getDownloadOptionsForJar(JARDesc jar) { - return file.getDownloadOptionsForJar(jar); - } - /** * Returns a set of paths that indicate the Class-Path entries in the * manifest file. The paths are rooted in the same directory as the diff -r a0ca905f9ee7 -r a875c8f789f2 tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java --- a/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java Tue Jul 30 09:41:12 2013 -0400 +++ b/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java Wed Sep 11 15:19:42 2013 -0400 @@ -44,6 +44,7 @@ import java.util.Locale; import net.sourceforge.jnlp.JNLPFile.Match; +import net.sourceforge.jnlp.annotations.Bug; import net.sourceforge.jnlp.mock.MockJNLPFile; import org.junit.Assert; @@ -148,4 +149,71 @@ Assert.assertEquals("Sample Test", jnlpFile.getTitle()); Assert.assertEquals(2, jnlpFile.getResources().getJARs().length); } + + @Bug(id={"PR1533"}) + @Test + public void testDownloadOptionsAppliedEverywhere() throws MalformedURLException, ParseException { + String os = System.getProperty("os.name"); + String arch = System.getProperty("os.arch"); + + String jnlpContents = "\n" + + "\n" + + " \n" + + " Parsing Test\n" + + " IcedTea\n" + + " \n" + + " \n" + + " \n" + + " " + + " " + + " \n" + + " " + + " " + + " \n" + + " " + + " " + + " \n" + + " \n" + + ""; + + URL codeBase = new URL("http://icedtea.classpath.org"); + InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); + JNLPFile jnlpFile = new JNLPFile(is, codeBase, false); + DownloadOptions downloadOptions = jnlpFile.getDownloadOptions(); + + Assert.assertTrue(downloadOptions.useExplicitPack()); + Assert.assertTrue(downloadOptions.useExplicitVersion()); + } + + @Bug(id={"PR1533"}) + @Test + public void testDownloadOptionsFilteredOut() throws MalformedURLException, ParseException { + String jnlpContents = "\n" + + "\n" + + " \n" + + " Parsing Test\n" + + " IcedTea\n" + + " \n" + + " \n" + + " \n" + + " " + + " " + + " \n" + + " " + + " " + + " \n" + + " " + + " " + + " \n" + + " \n" + + ""; + + URL codeBase = new URL("http://icedtea.classpath.org"); + InputStream is = new ByteArrayInputStream(jnlpContents.getBytes()); + JNLPFile jnlpFile = new JNLPFile(is, codeBase, false); + DownloadOptions downloadOptions = jnlpFile.getDownloadOptions(); + + Assert.assertFalse(downloadOptions.useExplicitPack()); + Assert.assertFalse(downloadOptions.useExplicitVersion()); + } }