diff options
author | Adam Domurad <[email protected]> | 2013-01-30 12:01:11 -0500 |
---|---|---|
committer | Adam Domurad <[email protected]> | 2013-01-30 12:01:11 -0500 |
commit | 8dd0f50c259ff8119cc9a801d87ed2fce44fbb09 (patch) | |
tree | 0997666dc73d835b7a91d727504e60b94e215dad /tests | |
parent | e2959ae96078602cf8b964a62bf454b364129c08 (diff) |
Fix for PR1292: Javaws does not resolve versioned jar names with periods properly
Diffstat (limited to 'tests')
5 files changed, 257 insertions, 0 deletions
diff --git a/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceUrlCreatorTest.java b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceUrlCreatorTest.java new file mode 100644 index 0000000..208180d --- /dev/null +++ b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceUrlCreatorTest.java @@ -0,0 +1,43 @@ +package net.sourceforge.jnlp.cache; + +import static org.junit.Assert.assertEquals; + +import java.net.MalformedURLException; +import java.net.URL; + +import net.sourceforge.jnlp.Version; + +import org.junit.Test; + +public class ResourceUrlCreatorTest { + + @Test + public void testVersionEncode() throws MalformedURLException { + Resource resource = Resource.getResource(new URL("http://test.jar"), new Version("1.1"), null); + URL result = ResourceUrlCreator.getUrl(resource, false /*don't use pack suffix*/, true /*use version suffix*/); + assertEquals("http://test__V1.1.jar", result.toString()); + } + + @Test + public void testVersionWithPeriods() throws MalformedURLException { + Resource resource = Resource.getResource(new URL("http://test.with.periods.jar"), new Version("1.1"), null); + URL result = ResourceUrlCreator.getUrl(resource, false /*don't use pack suffix*/, true /*use version suffix*/); + + // A previous bug had this as "test__V1.1.with.periods.jar" + assertEquals("http://test.with.periods__V1.1.jar", result.toString()); + } + + @Test + public void testPackEncode() throws MalformedURLException { + Resource resource = Resource.getResource(new URL("http://test.jar"), new Version("1.1"), null); + URL result = ResourceUrlCreator.getUrl(resource, true /*use pack suffix*/, false /*don't use version suffix*/); + assertEquals("http://test.jar.pack.gz", result.toString()); + } + + @Test + public void testVersionAndPackEncode() throws MalformedURLException { + Resource resource = Resource.getResource(new URL("http://test.jar"), new Version("1.1"), null); + URL result = ResourceUrlCreator.getUrl(resource, true /*use pack suffix*/, true/*use version suffix*/); + assertEquals("http://test__V1.1.jar.pack.gz", result.toString()); + } +} diff --git a/tests/reproducers/simple/VersionedJar__V1/resources/VersionedJarDisabled.jnlp b/tests/reproducers/simple/VersionedJar__V1/resources/VersionedJarDisabled.jnlp new file mode 100644 index 0000000..6e1e7ec --- /dev/null +++ b/tests/reproducers/simple/VersionedJar__V1/resources/VersionedJarDisabled.jnlp @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + --> + +<jnlp spec="1.0" + codebase="./" + href="VersionedJarDisabled.jnlp"> + <information> + <title>Test versioned jars</title> + <vendor>IcedTea</vendor> + </information> + <resources> + <jar href="VersionedJar.jar" main="true" version="1"/> + <property name="jnlp.versionEnabled" value="false"/> + </resources> + <application-desc main-class="VersionedJar"/> +</jnlp> diff --git a/tests/reproducers/simple/VersionedJar__V1/resources/VersionedJarEnabled.jnlp b/tests/reproducers/simple/VersionedJar__V1/resources/VersionedJarEnabled.jnlp new file mode 100644 index 0000000..9c6399f --- /dev/null +++ b/tests/reproducers/simple/VersionedJar__V1/resources/VersionedJarEnabled.jnlp @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +IcedTea is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + --> + +<jnlp spec="1.0" + codebase="./" + href="VersionedJarEnabled.jnlp"> + <information> + <title>Test replacing security manager</title> + <vendor>IcedTea</vendor> + </information> + <resources> + <jar href="VersionedJar.jar" main="true" version="1"/> + <property name="jnlp.versionEnabled" value="true"/> + </resources> + <application-desc main-class="VersionedJar"/> +</jnlp> diff --git a/tests/reproducers/simple/VersionedJar__V1/srcs/VersionedJar.java b/tests/reproducers/simple/VersionedJar__V1/srcs/VersionedJar.java new file mode 100644 index 0000000..f043072 --- /dev/null +++ b/tests/reproducers/simple/VersionedJar__V1/srcs/VersionedJar.java @@ -0,0 +1,46 @@ +/* Copyright (C) 2012 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + +import java.applet.*; +import java.awt.*; +import java.lang.reflect.Array; +import java.lang.reflect.Field; + +public class VersionedJar { + static public void main(String[] args) { + System.out.println("Versioned jar was accessed."); + } +}
\ No newline at end of file diff --git a/tests/reproducers/simple/VersionedJar__V1/testcases/VersionedJarTest.java b/tests/reproducers/simple/VersionedJar__V1/testcases/VersionedJarTest.java new file mode 100644 index 0000000..e035c97 --- /dev/null +++ b/tests/reproducers/simple/VersionedJar__V1/testcases/VersionedJarTest.java @@ -0,0 +1,64 @@ +/* Copyright (C) 2012 Red Hat, Inc. + +This file is part of IcedTea. + +IcedTea is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License as published by +the Free Software Foundation, version 2. + +IcedTea is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IcedTea; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. + */ + + +import junit.framework.Assert; + +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ServerAccess; + +import org.junit.Test; + +public class VersionedJarTest { + + private static final ServerAccess server = new ServerAccess(); + private static final String VERSIONED = "Versioned jar was accessed."; + private static final String FAILURE = "net.sourceforge.jnlp.LaunchException"; + + @Test + public void testDisabledVersionParameter() throws Exception { + ProcessResult pr = server.executeJavawsHeadless("/VersionedJarDisabled.jnlp"); + Assert.assertFalse("Stdout should NOT contain '" + VERSIONED + "', but did.", pr.stdout.contains(VERSIONED)); + Assert.assertTrue("Stderr should contain '" +FAILURE + "', but did not.", pr.stderr.contains(FAILURE)); + } + + @Test + public void testEnabledVersionParameter() throws Exception { + ProcessResult pr = server.executeJavawsHeadless("/VersionedJarEnabled.jnlp"); + Assert.assertTrue("Stdout should contain '" + VERSIONED + "', but did not.", pr.stdout.contains(VERSIONED)); + Assert.assertFalse("Stderr should NOT contain '" +FAILURE + "', but did.", pr.stderr.contains(FAILURE)); + } +}
\ No newline at end of file |