/hg/icedtea-web: PR1533: Inherit jnlp.packEnabled and jnlp.versi...

omajid at icedtea.classpath.org omajid at icedtea.classpath.org
Mon Sep 9 08:33:22 PDT 2013


changeset f59d6eba666c in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=f59d6eba666c
author: Omair Majid <omajid at redhat.com>
date: Mon Sep 09 11:32:36 2013 -0400

	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  <omajid at redhat.com>

	    * 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.


diffstat:

 ChangeLog                                              |  16 ++++
 netx/net/sourceforge/jnlp/JNLPFile.java                |  29 ++-----
 netx/net/sourceforge/jnlp/PluginBridge.java            |   2 +-
 netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java |   6 +-
 tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java |  68 ++++++++++++++++++
 5 files changed, 94 insertions(+), 27 deletions(-)

diffs (190 lines):

diff -r bb8132ebc241 -r f59d6eba666c ChangeLog
--- a/ChangeLog	Wed Sep 04 13:48:42 2013 -0400
+++ b/ChangeLog	Mon Sep 09 11:32:36 2013 -0400
@@ -1,3 +1,19 @@
+2013-09-09  Omair Majid  <omajid at redhat.com>
+
+	* 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-09-04  Andrew Azores  <aazores at redhat.com>
 
 	* netx/net/sourceforge/jnlp/config/Defaults.java: (USER_CACHE_HOME) made
diff -r bb8132ebc241 -r f59d6eba666c netx/net/sourceforge/jnlp/JNLPFile.java
--- a/netx/net/sourceforge/jnlp/JNLPFile.java	Wed Sep 04 13:48:42 2013 -0400
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java	Mon Sep 09 11:32:36 2013 -0400
@@ -20,7 +20,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.Reader;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -791,29 +790,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 bb8132ebc241 -r f59d6eba666c netx/net/sourceforge/jnlp/PluginBridge.java
--- a/netx/net/sourceforge/jnlp/PluginBridge.java	Wed Sep 04 13:48:42 2013 -0400
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java	Mon Sep 09 11:32:36 2013 -0400
@@ -228,7 +228,7 @@
      * {@inheritDoc }
      */
     @Override
-    public DownloadOptions getDownloadOptionsForJar(JARDesc jar) {
+    public DownloadOptions getDownloadOptions() {
         return new DownloadOptions(usePack, useVersion);
     }
 
diff -r bb8132ebc241 -r f59d6eba666c netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Wed Sep 04 13:48:42 2013 -0400
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java	Mon Sep 09 11:32:36 2013 -0400
@@ -626,7 +626,7 @@
 
             tracker.addResource(jars[i].getLocation(),
                                 jars[i].getVersion(),
-                                getDownloadOptionsForJar(jars[i]),
+                                file.getDownloadOptions(),
                                 jars[i].isCacheable() ? JNLPRuntime.getDefaultUpdatePolicy() : UpdatePolicy.FORCE
                                );
         }
@@ -1966,10 +1966,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 bb8132ebc241 -r f59d6eba666c tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java	Wed Sep 04 13:48:42 2013 -0400
+++ b/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java	Mon Sep 09 11:32:36 2013 -0400
@@ -45,6 +45,7 @@
 import java.util.Map;
 
 import net.sourceforge.jnlp.JNLPFile.Match;
+import net.sourceforge.jnlp.annotations.Bug;
 import net.sourceforge.jnlp.mock.MockJNLPFile;
 
 import org.junit.Assert;
@@ -208,4 +209,71 @@
         Assert.assertEquals("os2", properties.get("os"));
         Assert.assertEquals("arch2", properties.get("arch"));
     }
+
+    @Bug(id={"PR1533"})
+    @Test
+    public void testDownloadOptionsAppliedEverywhere() throws MalformedURLException, ParseException {
+        String os = System.getProperty("os.name");
+        String arch = System.getProperty("os.arch");
+
+        String jnlpContents = "<?xml version='1.0'?>\n" +
+                "<jnlp spec='1.5' href='foo' codebase='bar'>\n" +
+                "  <information>\n" +
+                "    <title>Parsing Test</title>\n" +
+                "    <vendor>IcedTea</vendor>\n" +
+                "    <offline-allowed/>\n" +
+                "  </information>\n" +
+                "  <resources>\n" +
+                "    <property name='jnlp.packEnabled' value='false'/>" +
+                "    <property name='jnlp.versionEnabled' value='false'/>" +
+                "  </resources>\n" +
+                "  <resources os='" + os + "'>" +
+                "    <property name='jnlp.packEnabled' value='true'/>" +
+                "  </resources>\n" +
+                "  <resources arch='" + arch + "'>" +
+                "    <property name='jnlp.versionEnabled' value='true'/>" +
+                "  </resources>\n" +
+                "  <installer-desc/>\n" +
+                "</jnlp>";
+
+        URL codeBase = new URL("http://icedtea.classpath.org");
+        InputStream is = new ByteArrayInputStream(jnlpContents.getBytes());
+        JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false,false,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 = "<?xml version='1.0'?>\n" +
+                "<jnlp spec='1.5' href='foo' codebase='bar'>\n" +
+                "  <information>\n" +
+                "    <title>Parsing Test</title>\n" +
+                "    <vendor>IcedTea</vendor>\n" +
+                "    <offline-allowed/>\n" +
+                "  </information>\n" +
+                "  <resources>\n" +
+                "    <property name='jnlp.packEnabled' value='false'/>" +
+                "    <property name='jnlp.versionEnabled' value='false'/>" +
+                "  </resources>\n" +
+                "  <resources os='someOtherOs'>" +
+                "    <property name='jnlp.packEnabled' value='true'/>" +
+                "  </resources>\n" +
+                "  <resources arch='someOtherArch'>" +
+                "    <property name='jnlp.versionEnabled' value='true'/>" +
+                "  </resources>\n" +
+                "  <installer-desc/>\n" +
+                "</jnlp>";
+
+        URL codeBase = new URL("http://icedtea.classpath.org");
+        InputStream is = new ByteArrayInputStream(jnlpContents.getBytes());
+        JNLPFile jnlpFile = new JNLPFile(is, codeBase, new ParserSettings(false,false,false));
+        DownloadOptions downloadOptions = jnlpFile.getDownloadOptions();
+
+        Assert.assertFalse(downloadOptions.useExplicitPack());
+        Assert.assertFalse(downloadOptions.useExplicitVersion());
+    }
 }



More information about the distro-pkg-dev mailing list