# HG changeset patch # Parent d8b3e37483e6c12201052f23bb31a9296136ea9e diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java --- a/netx/net/sourceforge/jnlp/PluginBridge.java +++ b/netx/net/sourceforge/jnlp/PluginBridge.java @@ -54,8 +54,8 @@ private List codeBaseFolders = new ArrayList(); private String[] cacheJars = new String[0]; private String[] cacheExJars = new String[0]; - private boolean usePack; - private boolean useVersion; + private boolean usePack = false; + private boolean useVersion = false; private boolean useJNLPHref; /** @@ -130,6 +130,9 @@ this.jars.add(fileName); } + usePack = jnlpFile.getDownloadOptions().useExplicitPack(); + useVersion = jnlpFile.getDownloadOptions().useExplicitVersion(); + // Store any extensions listed in the JNLP file to be returned later on, namely in getResources() extensionJars = Arrays.asList(jnlpFile.getResources().getExtensions()); } catch (MalformedURLException e) { @@ -198,8 +201,6 @@ security = null; this.uniqueKey = params.getUniqueKey(codebase); - usePack = false; - useVersion = false; String jargs = params.getJavaArguments(); if (!jargs.isEmpty()) { for (String s : jargs.split(" ")) { diff --git a/tests/reproducers/custom/PackGZip/resources/PackGZip.jnlp b/tests/reproducers/custom/PackGZip/resources/PackGZip.jnlp new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/PackGZip/resources/PackGZip.jnlp @@ -0,0 +1,52 @@ + + + + simple application + IcedTea + + + + + + + + + + + + diff --git a/tests/reproducers/custom/PackGZip/resources/PackGZipApplet.html b/tests/reproducers/custom/PackGZip/resources/PackGZipApplet.html new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/PackGZip/resources/PackGZipApplet.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/tests/reproducers/custom/PackGZip/resources/PackGZipJNLP.html b/tests/reproducers/custom/PackGZip/resources/PackGZipJNLP.html new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/PackGZip/resources/PackGZipJNLP.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/tests/reproducers/custom/PackGZip/srcs/Makefile b/tests/reproducers/custom/PackGZip/srcs/Makefile new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/PackGZip/srcs/Makefile @@ -0,0 +1,28 @@ +TESTNAME=PackGZip + +JAVAC_CLASSPATH=$(TEST_EXTENSIONS_DIR):$(NETX_DIR)/lib/classes.jar +JAVAC=$(BOOT_DIR)/bin/javac +JAR=$(BOOT_DIR)/bin/jar +JARSIGNER=$(BOOT_DIR)/bin/jarsigner +PACKER=pack200 + +TMPDIR:=$(shell mktemp -d) + +prepare-reproducer: + echo PREPARING REPRODUCER $(TESTNAME) + + $(JAVAC) -d $(TMPDIR) -classpath $(JAVAC_CLASSPATH) $(TESTNAME).java; \ + + cp ../resources/* $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \ + + cd $(TMPDIR); \ + $(JAR) cf $(TESTNAME).jar $(TESTNAME).class; \ + cd $(TMPDIR); \ + $(PACKER) $(TESTNAME).jar.pack.gz $(TESTNAME).jar; \ + cp $(TMPDIR)/$(TESTNAME).jar.pack.gz $(REPRODUCERS_TESTS_SERVER_DEPLOYDIR); \ + + echo PREPARED REPRODUCER $(TESTNAME), removing $(TMPDIR); \ + rm -rf $(TMPDIR); \ + +clean-reproducer: + echo NOTHING TO CLEAN FOR $(TESTNAME) diff --git a/tests/reproducers/custom/PackGZip/srcs/PackGZip.java b/tests/reproducers/custom/PackGZip/srcs/PackGZip.java new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/PackGZip/srcs/PackGZip.java @@ -0,0 +1,47 @@ +/* +Copyright (C) 2014 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.Applet; +import java.lang.System; + +public class PackGZip extends Applet { + private static final String initStr = "init"; + @Override + public void init() { + System.out.println(initStr); + } +} diff --git a/tests/reproducers/custom/PackGZip/testcases/PackGZipTest.java b/tests/reproducers/custom/PackGZip/testcases/PackGZipTest.java new file mode 100644 --- /dev/null +++ b/tests/reproducers/custom/PackGZip/testcases/PackGZipTest.java @@ -0,0 +1,110 @@ +/* +Copyright (C) 2014 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 org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.annotations.KnownToFail; +import net.sourceforge.jnlp.annotations.NeedsDisplay; +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import net.sourceforge.jnlp.browsertesting.BrowserTest; +import net.sourceforge.jnlp.browsertesting.Browsers; +import net.sourceforge.jnlp.cache.CacheUtil; +import net.sourceforge.jnlp.closinglisteners.CountingClosingListener; + +public class PackGZipTest extends BrowserTest { + private static final boolean doNotRunInOpera = true; + + + private static final String initStr = "init"; + + private class CountingClosingListenerImpl extends CountingClosingListener { + @Override + protected boolean isAlowedToFinish(String s) { + return s.contains(initStr); + } + } + + @Before + public void setup() { + CacheUtil.clearCache(); + } + + @Test + @TestInBrowsers(testIn = { Browsers.all }) + @NeedsDisplay + public void testBrowserJNLP() throws Exception { + String url = "/PackGZipJNLP.html"; + if (doNotRunInOpera) { + if (server.getCurrentBrowser().getID() == Browsers.opera) { + return; + } + ProcessResult pr = server.executeBrowser(url, new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); + Assert.assertTrue("stdout should contain " + initStr + ", but it didnt.", pr.stdout.contains(initStr)); + } + } + + @Test + @TestInBrowsers(testIn = { Browsers.all }) + @NeedsDisplay + public void testBrowserApplet() throws Exception { + String url = "/PackGZipApplet.html"; + if (doNotRunInOpera) { + if (server.getCurrentBrowser().getID() == Browsers.opera) { + return; + } + ProcessResult pr = server.executeBrowser(url, new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); + Assert.assertTrue("stdout should contain " + initStr + ", but it didnt.", pr.stdout.contains(initStr)); + } + } + + @Test + @TestInBrowsers(testIn = { Browsers.all }) + @NeedsDisplay + public void testJavawsJNLP() throws Exception { + String url = "/PackGZip.jnlp"; + if (doNotRunInOpera) { + if (server.getCurrentBrowser().getID() == Browsers.opera) { + return; + } + ProcessResult pr = server.executeJavaws(url, new CountingClosingListenerImpl(), new CountingClosingListenerImpl()); + Assert.assertTrue("stdout should contain " + initStr + ", but it didnt.", pr.stdout.contains(initStr)); + } + } +} diff --git a/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java b/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java --- a/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java +++ b/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java @@ -71,6 +71,8 @@ private boolean canRun = true; private boolean supportingHeadRequest = true; + private boolean acceptEncoding = false; + public TinyHttpdImpl(Socket socket, File dir) { this(socket, dir, true); } @@ -116,63 +118,77 @@ boolean isHeadRequest = request.equals(ResourceTracker.RequestMethods.HEAD.toString()); boolean isGetRequest = request.equals(ResourceTracker.RequestMethods.GET.toString()); + boolean isAcceptEncodingRequest = request.contains("Accept-Encoding"); + if (isAcceptEncodingRequest) { + ServerAccess.logOutputReprint("Recieved Accept-Encoding request: " + request); + acceptEncoding = true; + } if (isHeadRequest && !isSupportingHeadRequest()) { ServerAccess.logOutputReprint("Received HEAD request but not supported"); writer.writeBytes(HTTP_NOT_IMPLEMENTED); - continue; - } + } else if (!isHeadRequest && !isGetRequest) { + ServerAccess.logOutputReprint("Received unknown request type " + request); + } else { + String filePath = t.nextToken(); + boolean slowSend = filePath.startsWith(XSX); - if (!isHeadRequest && !isGetRequest) { - ServerAccess.logOutputReprint("Received unknown request type " + request); - continue; - } + if (slowSend) { + filePath = filePath.replace(XSX, "/"); + } - String filePath = t.nextToken(); - boolean slowSend = filePath.startsWith(XSX); + ServerAccess.logOutputReprint("Getting- " + request + ": " + filePath); + filePath = urlToFilePath(filePath); + File resource; + if (filePath.endsWith(".jar")) { + resource = getJarFile(filePath); + } else { + resource = new File(this.testDir, filePath); + } - if (slowSend) { - filePath = filePath.replace(XSX, "/"); - } + if (!(resource != null && resource.isFile() && resource.canRead())) { + ServerAccess.logOutputReprint("Could not open file " + filePath); + writer.writeBytes(HTTP_NOT_FOUND); + } else { + ServerAccess.logOutputReprint("Serving- " + request + ": " + filePath); - ServerAccess.logOutputReprint("Getting- " + request + ": " + filePath); - filePath = urlToFilePath(filePath); + int resourceLength = (int) resource.length(); + byte[] buff = new byte[resourceLength]; + FileInputStream fis = new FileInputStream(resource); + fis.read(buff); + fis.close(); - File resource = new File(this.testDir, filePath); - if (!(resource.isFile() && resource.canRead())) { - ServerAccess.logOutputReprint("Could not open file " + filePath); - writer.writeBytes(HTTP_NOT_FOUND); - continue; - } - ServerAccess.logOutputReprint("Serving- " + request + ": " + filePath); + String message = HTTP_OK + "Content-Length:" + resourceLength + CRLF; - int resourceLength = (int) resource.length(); - byte[] buff = new byte[resourceLength]; - FileInputStream fis = new FileInputStream(resource); - fis.read(buff); - fis.close(); + String contentType = "Content-Type: "; + if (filePath.toLowerCase().endsWith(".jnlp")) { + contentType += "application/x-java-jnlp-file"; + } else if (filePath.toLowerCase().endsWith(".jar")) { + contentType += "application/x-jar"; + } else { + contentType += "text/html"; + } + message = message + contentType + CRLF; - String contentType = "Content-Type: "; - if (filePath.toLowerCase().endsWith(".jnlp")) { - contentType += "application/x-java-jnlp-file"; - } else if (filePath.toLowerCase().endsWith(".jar")) { - contentType += "application/x-jar"; - } else { - contentType += "text/html"; - } - writer.writeBytes(HTTP_OK + "Content-Length:" + resourceLength + CRLF + contentType + CRLF + CRLF); + if (acceptEncoding && resource.getName().endsWith(".gz")) { + message = message + "Content-Encoding: gzip" + CRLF; + } - if (isGetRequest) { - if (slowSend) { - byte[][] bb = splitArray(buff, 10); - for (int j = 0; j < bb.length; j++) { - Thread.sleep(2000); - byte[] bs = bb[j]; - writer.write(bs, 0, bs.length); + writer.writeBytes(message + CRLF); + + if (isGetRequest) { + if (slowSend) { + byte[][] bb = splitArray(buff, 10); + for (int j = 0; j < bb.length; j++) { + Thread.sleep(2000); + byte[] bs = bb[j]; + writer.write(bs, 0, bs.length); + } + } else { + writer.write(buff, 0, resourceLength); + } } - } else { - writer.write(buff, 0, resourceLength); } } } @@ -190,6 +206,27 @@ } } + private File getJarFile(String filePath) { + File resource = new File(this.testDir, filePath); + if (exists(resource)) { + return resource; + } + resource = new File(this.testDir, filePath + ".pack.gz"); + if (exists(resource)) { + return resource; + } + resource = new File(this.testDir, filePath + ".gz"); + if (exists(resource)) { + return resource; + } + + return null; + } + + private boolean exists(File resource) { + return resource.isFile() && resource.canRead(); + } + /** * This function splits input array to severasl pieces * from byte[length] splitt to n pieces s is retrunrd byte[n][length/n], except