From eae8bd5edfb2300861eb1e646595b27b68293829 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Mon, 9 Sep 2013 11:32:36 -0400 Subject: 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. --- .../unit/net/sourceforge/jnlp/JNLPFileTest.java | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'tests') diff --git a/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java b/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java index 1f517be..8285df2 100644 --- a/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java +++ b/tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java @@ -45,6 +45,7 @@ import java.util.Locale; 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 @@ public class JNLPFileTest { 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 = "\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, 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 = "\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, new ParserSettings(false,false,false)); + DownloadOptions downloadOptions = jnlpFile.getDownloadOptions(); + + Assert.assertFalse(downloadOptions.useExplicitPack()); + Assert.assertFalse(downloadOptions.useExplicitVersion()); + } } -- cgit v1.2.3