# HG changeset patch # User Jiri Vanek # Date 1453910621 -3600 # Node ID 530bb97e9f08c47b897b9c039985b0a8e1ddbb18 # Parent 978b3c7070b7f908445e7c62325cee6b3681b89d Fixed various cosmetic NPEs when codebase is null (+tests) diff -r 978b3c7070b7 -r 530bb97e9f08 ChangeLog --- a/ChangeLog Tue Jan 19 21:14:09 2016 +0100 +++ b/ChangeLog Wed Jan 27 17:03:41 2016 +0100 @@ -1,3 +1,65 @@ +2016-01-25 Jiri Vanek + + Fixed various cosmetic NPEs when codebase is null (+tests) + * NEWS: mentioned PR2489 + * netx/net/sourceforge/jnlp/JNLPFile.java: added method getNotNullProbalbeCodeBase + workaround cases when codebase is null (for various output reasons) + * netx/net/sourceforge/jnlp/PluginBridge.java: using getNotNullProbalbeCodeBase + when fixing codebase during generation of jnlp stub. + * netx/net/sourceforge/jnlp/SecurityDesc.java: same for generating uri for policies + record + * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: (manageExternalJars) + same for ref string comparsion + * netx/net/sourceforge/jnlp/security/SecurityDialog.java: same for visible form of + codebase + * netx/net/sourceforge/jnlp/security/SecurityDialogs.java: same + * netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java: + same + * netx/net/sourceforge/jnlp/security/dialogs/TemporaryPermissionsButton.java: + same + * netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/PartiallySignedAppTrustWarningPanel.java: + same + * netx/net/sourceforge/jnlp/util/UrlUtils.java: (normalizeUrlAndStripParams) and + (removeFileName) when input is null, return null. + * tests/junit-runner/JunitLikeXmlOutputListener.java: now supports hg commits + * tests/reproducers/signed/CodebasesAttsSigned/srcs/CodebasesAttsSigned.java: + test printing "hardocded" id and paramet to know jar and calling jnlp/html source + * tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSigned.html.in: + resouirce capable of substitue id param, codebase, jar and htmlHref + * tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedApp.jnlp.in: + same + * tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedApplet.jnlp.in: + same + * tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedJnlpHref.html.in: + same + * tests/reproducers/signed/CodebasesAttsSigned/testcases/CodebasesAttsSignedDialogsTest1.java: + Test testing various dialogues of signed app. Including tests for corrupted signature + * tests/reproducers/simple/CodebasesAtts/srcs/CodebasesAtts.java: same as CodebasesAttsSigned + but not signed + * tests/reproducers/simple/CodebasesAtts/resources/CodebasesAtts.html.in: + same as signed ones + * tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsApp.jnlp.in: + same + * tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsApplet.jnlp.in: + same + * tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsJnlpHref.html.in: + same + * tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsDialogsTest1.java: + same + * tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest1.java: + * tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest2.java: + * tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest3.java: + Again tests for various substituted values + * tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java: + added stubs to create independent instance upon tmp folder and execute browser + upon url. + * tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/firefox/FirefoxProfilesOperator.java: + (copyFile) moved to autocloseable + * tests/test-extensions/net/sourceforge/jnlp/closinglisteners/AutoErrorClosingListener.java: + fixed to not to close on rhino exception + * tests/test-extensions/net/sourceforge/jnlp/closinglisteners/StringBasedClosingListener.java: + condition made protected + 2016-01-19 Jiri Vanek When tagsoup is missing, parsing errors are more informative diff -r 978b3c7070b7 -r 530bb97e9f08 NEWS --- a/NEWS Tue Jan 19 21:14:09 2016 +0100 +++ b/NEWS Wed Jan 27 17:03:41 2016 +0100 @@ -14,6 +14,7 @@ * PR2591 - IcedTea-Web request resources twice for meta informations and causes ClientAbortException on tomcat in conjunction with JnlpDownloadServlet * PR2690 - Can't run BOM into JNLP file * PR2669 - remove bash-specific syntax from top level Makefile.am +* PR2489 - various NPEs when codebase is null * NetX - main-class attribute trimmed by default - in strict mode, main-class attribute checked for invalid characters diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/JNLPFile.java --- a/netx/net/sourceforge/jnlp/JNLPFile.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/JNLPFile.java Wed Jan 27 17:03:41 2016 +0100 @@ -37,6 +37,7 @@ import net.sourceforge.jnlp.runtime.JNLPClassLoader; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.util.ClasspathMatcher; +import net.sourceforge.jnlp.util.UrlUtils; import net.sourceforge.jnlp.util.logging.OutputController; /** @@ -419,6 +420,25 @@ public URL getCodeBase() { return codeBase; } + + /** + * It is not recommended to use this method for internals of itw - use normal getCodeBase rather, as null is expected always except toString calls. + * + * If you are not sure, use getCodeBase and chek null as you need. See that this method is used mostly for xtendedAppletSecuriyty dialogs. + * + * @return the codebase URL for the JNLP file or url of location of calling file (jnlp, hreffed jnlp, or directly html) + */ + public URL getNotNullProbalbeCodeBase() { + if (getCodeBase()!=null){ + return getCodeBase(); + } + try { + return UrlUtils.removeFileName(getSourceLocation()); + } catch (Exception ex) { + OutputController.getLogger().log(ex); + } + return getSourceLocation(); + } /** * @return the information section of the JNLP file as viewed diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/PluginBridge.java --- a/netx/net/sourceforge/jnlp/PluginBridge.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/PluginBridge.java Wed Jan 27 17:03:41 2016 +0100 @@ -475,7 +475,7 @@ } else { StringBuilder s = new StringBuilder(); s.append("\n" - + "\n") + + "\n") .append(" \n" + " ").append(createJnlpTitle()).append("\n" + " ").append(createJnlpVendor()).append("\n" @@ -540,7 +540,7 @@ } private String fixCommonIsuses(boolean needSecurity, String orig) { - String codebase = getCodeBase().toString(); + String codebase = getNotNullProbalbeCodeBase().toString(); return fixCommonIsuses(needSecurity, orig, codebase, createJnlpTitle(), createJnlpVendor()); } diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/SecurityDesc.java --- a/netx/net/sourceforge/jnlp/SecurityDesc.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/SecurityDesc.java Wed Jan 27 17:03:41 2016 +0100 @@ -415,11 +415,7 @@ } } try { - URL codebaseOriginal = file.getCodeBase(); - if (codebaseOriginal == null){ - codebaseOriginal =file.fileLocation; - } - final URI codebase = codebaseOriginal.toURI().normalize(); + final URI codebase = file.getNotNullProbalbeCodeBase().toURI().normalize(); final URI host = getHost(codebase); final String codebaseHostUriString = host.toString(); final String urlPermissionUrlString = appendRecursiveSubdirToCodebaseHostString(codebaseHostUriString); diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Wed Jan 27 17:03:41 2016 +0100 @@ -2162,7 +2162,7 @@ if (foundLoader != null) approved = true; - else if (ref.toString().startsWith(file.getCodeBase().toString())) + else if (ref.toString().startsWith(file.getNotNullProbalbeCodeBase().toString())) approved = true; else if (SecurityDesc.ALL_PERMISSIONS.equals(security.getSecurityType())) approved = true; diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/runtime/ManifestAttributesChecker.java --- a/netx/net/sourceforge/jnlp/runtime/ManifestAttributesChecker.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/runtime/ManifestAttributesChecker.java Wed Jan 27 17:03:41 2016 +0100 @@ -282,7 +282,7 @@ throw new LaunchException("Your Extended applets security is at 'Very high', and this application is missing the 'permissions' attribute in manifest. This is fatal"); } if (itwSecurityLevel == AppletSecurityLevel.ASK_UNSIGNED) { - final boolean userApproved = SecurityDialogs.showMissingPermissionsAttributeDialogue(file.getTitle(), file.getCodeBase()); + final boolean userApproved = SecurityDialogs.showMissingPermissionsAttributeDialogue(file.getTitle(), file.getNotNullProbalbeCodeBase().toExternalForm()); if (!userApproved) { throw new LaunchException("Your Extended applets security is at 'high' and this application is missing the 'permissions' attribute in manifest. And you have refused to run it."); } else { @@ -407,7 +407,7 @@ att = file.getManifestsAttributes().getApplicationLibraryAllowableCodebase(); } if (att == null) { - final boolean userApproved = SecurityDialogs.showMissingALACAttributePanel(file.getTitle(), documentBase, usedUrls); + final boolean userApproved = SecurityDialogs.showMissingALACAttributePanel(file.getTitle(), file.getNotNullProbalbeCodeBase(), usedUrls); if (!userApproved) { throw new LaunchException("The application uses non-codebase resources, has no Application-Library-Allowable-Codebase Attribute, and was blocked from running by the user"); } else { diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/security/SecurityDialogs.java --- a/netx/net/sourceforge/jnlp/security/SecurityDialogs.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/security/SecurityDialogs.java Wed Jan 27 17:03:41 2016 +0100 @@ -441,7 +441,7 @@ } } - public static boolean showMissingPermissionsAttributeDialogue(String title, URL codeBase) { + public static boolean showMissingPermissionsAttributeDialogue(String title, String codeBase) { if (!shouldPromptUser()) { if (JNLPRuntime.isTrustAll()) { @@ -453,7 +453,7 @@ SecurityDialogMessage message = new SecurityDialogMessage(); message.dialogType = DialogType.UNSIGNED_EAS_NO_PERMISSIONS_WARNING; - message.extras = new Object[]{title, codeBase.toExternalForm()}; + message.extras = new Object[]{title, codeBase}; Object selectedValue = getUserResponse(message); return SecurityDialogs.getIntegerResponseAsBoolean(selectedValue); } diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java --- a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java Wed Jan 27 17:03:41 2016 +0100 @@ -110,8 +110,8 @@ private static UnsignedAppletActionEntry getMatchingItem(UnsignedAppletActionStorage actionStorage, JNLPFile file, int id) { return actionStorage.getMatchingItem( UrlUtils.normalizeUrlAndStripParams(file.getSourceLocation(), true /* encode local files */).toString(), - UrlUtils.normalizeUrlAndStripParams(file.getCodeBase(), true /* encode local files */).toString(), - toRelativePaths(getJars(file), file.getCodeBase().toString()), id); + UrlUtils.normalizeUrlAndStripParams(file.getNotNullProbalbeCodeBase(), true /* encode local files */).toString(), + toRelativePaths(getJars(file), file.getNotNullProbalbeCodeBase().toExternalForm()), id); } /* Extract the archives as relative paths */ @@ -134,7 +134,7 @@ try { UnsignedAppletActionEntry oldEntry = getMatchingItem(userActionStorage, file, id); - URL codebase = UrlUtils.normalizeUrlAndStripParams(file.getCodeBase(), true /* encode local files */); + URL codebase = UrlUtils.normalizeUrlAndStripParams(file.getNotNullProbalbeCodeBase(), true /* encode local files */); URL documentbase = UrlUtils.normalizeUrlAndStripParams(file.getSourceLocation(), true /* encode local files */); /* Else, create a new entry */ @@ -144,7 +144,7 @@ if (!rememberForCodeBase) { documentbaseRegex = UrlRegEx.quote(documentbase.toExternalForm()); // Match only this applet - archiveMatches = toRelativePaths(getJars(file), file.getCodeBase().toString()); // Match only this applet + archiveMatches = toRelativePaths(getJars(file), file.getNotNullProbalbeCodeBase().toString()); // Match only this applet } /* Update, if entry exists */ diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/security/dialogs/TemporaryPermissionsButton.java --- a/netx/net/sourceforge/jnlp/security/dialogs/TemporaryPermissionsButton.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/security/dialogs/TemporaryPermissionsButton.java Wed Jan 27 17:03:41 2016 +0100 @@ -174,7 +174,7 @@ policyEditorWindow.asWindow().repaint(); } policyEditorWindow.setModalityType(ModalityType.DOCUMENT_MODAL); - policyEditorWindow.getPolicyEditor().addNewCodebase(file.getCodeBase().toString()); + policyEditorWindow.getPolicyEditor().addNewCodebase(file.getNotNullProbalbeCodeBase().toString()); policyEditorWindow.asWindow().setVisible(true); menu.setVisible(false); } diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/PartiallySignedAppTrustWarningPanel.java --- a/netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/PartiallySignedAppTrustWarningPanel.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/PartiallySignedAppTrustWarningPanel.java Wed Jan 27 17:03:41 2016 +0100 @@ -100,7 +100,7 @@ try { if (file instanceof PluginBridge) { - from = file.getCodeBase().toExternalForm(); + from = file.getNotNullProbalbeCodeBase().toExternalForm(); } else { from = file.getInformation().getHomepage().toExternalForm(); } diff -r 978b3c7070b7 -r 530bb97e9f08 netx/net/sourceforge/jnlp/util/UrlUtils.java --- a/netx/net/sourceforge/jnlp/util/UrlUtils.java Tue Jan 19 21:14:09 2016 +0100 +++ b/netx/net/sourceforge/jnlp/util/UrlUtils.java Wed Jan 27 17:03:41 2016 +0100 @@ -52,6 +52,9 @@ private static final String UTF8 = "utf-8"; public static URL normalizeUrlAndStripParams(URL url, boolean encodeFileUrls) { + if (url == null) { + return null; + } try { String[] urlParts = url.toString().split("\\?"); URL strippedUrl = new URL(urlParts[0]); @@ -165,6 +168,9 @@ * @return src without file */ public static URL removeFileName(final URL src) { + if (src == null) { + return src; + } URL nsrc = normalizeUrlAndStripParams(src); String s = nsrc.getPath(); int i1 = s.lastIndexOf("/"); diff -r 978b3c7070b7 -r 530bb97e9f08 tests/junit-runner/JunitLikeXmlOutputListener.java --- a/tests/junit-runner/JunitLikeXmlOutputListener.java Tue Jan 19 21:14:09 2016 +0100 +++ b/tests/junit-runner/JunitLikeXmlOutputListener.java Wed Jan 27 17:03:41 2016 +0100 @@ -424,6 +424,8 @@ String distro = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/"; String openjdk = "http://mail.openjdk.java.net/pipermail/"; + String pushHead = "http://icedtea.classpath.org/hg/"; + String pushBranch = "http://icedtea.classpath.org/hg/release/"; if (string.startsWith(distro)) { r[0] = "distro-pkg"; return r; @@ -432,6 +434,14 @@ r[0] = "openjdk"; return r; } + if (string.startsWith(pushBranch)) { + r[0] = "push (branch)"; + return r; + } + if (string.startsWith(pushHead)) { + r[0] = "push (head)"; + return r; + } return r; } @@ -459,5 +469,11 @@ q = createBug("http://lists.fedoraproject.org/pipermail/chinese/2012-January/008868.html"); System.out.println(q[0] + " : " + q[1]); + + q = createBug("http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7"); + System.out.println(q[0] + " : " + q[1]); + + q = createBug("http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d"); + System.out.println(q[0] + " : " + q[1]); } } diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSigned.html.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSigned.html.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,46 @@ + + + + + + + + + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedApp.jnlp.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedApp.jnlp.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,55 @@ + + + + + + CodebasesAttsSigned + IcedTea + + PR2489 + + + + + + + + @ID@ + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedApplet.jnlp.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedApplet.jnlp.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,59 @@ + + + + + + CodebasesAttsSigned + IcedTea + + PR2489 + + + + + + + + + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedJnlpHref.html.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/signed/CodebasesAttsSigned/resources/CodebasesAttsSignedJnlpHref.html.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,47 @@ + + + + + + + + + + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/signed/CodebasesAttsSigned/srcs/CodebasesAttsSigned.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/signed/CodebasesAttsSigned/srcs/CodebasesAttsSigned.java Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,86 @@ +/* ExtensionJnlpTestApplet.java + Copyright (C) 2013 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.Graphics; + +/** + * + * Note that for html's appelt and jnlphreff's jnlp file may have different + * codebase. + * + */ +public class CodebasesAttsSigned extends Applet { + + private static final String appletCloseString = "*** APPLET FINISHED ***"; + private static final String bid = "BID0"; + + public static void main(String... args) { + System.out.println("id: "+args[0]); + System.out.println("BID: "+bid); + System.out.println(CodebasesAttsSigned.class.getName()); + System.out.println(appletCloseString); + System.out.flush(); + System.out.println("some garbage"); + } + + @Override + public void init() { + + } + + @Override + public void start() { + main(getParameter("id")); + } + + @Override + public void stop() { + + } + + @Override + public void destroy() { + + } + + @Override + public void paint(Graphics g) { + + } + +} diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/signed/CodebasesAttsSigned/testcases/CodebasesAttsSignedDialogsTest1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/signed/CodebasesAttsSigned/testcases/CodebasesAttsSignedDialogsTest1.java Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,528 @@ +/* CodebasesAttsSignedNoDialogsTest1.java + Copyright (C) 2013 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.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; +import net.sourceforge.jnlp.OptionsDefinitions; +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ProcessWrapper; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.ServerLauncher; +import net.sourceforge.jnlp.annotations.Bug; +import net.sourceforge.jnlp.annotations.NeedsDisplay; +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import net.sourceforge.jnlp.browsertesting.BrowserTest; +import static net.sourceforge.jnlp.browsertesting.BrowserTest.server; +import net.sourceforge.jnlp.browsertesting.Browsers; +import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener; +import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; +import net.sourceforge.jnlp.config.DeploymentConfiguration; +import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; +import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; +import net.sourceforge.jnlp.util.FileUtils; +import org.junit.AfterClass; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * null, empty, none, wrong, correct jnlp x html different codebases. + * + * no dialogs should be appeared. Second testsuite with ALL dialogs (head only) + * + * + */ +public class CodebasesAttsSignedDialogsTest1 extends BrowserTest { + + public static final String appletCloseString = AutoOkClosingListener.MAGICAL_OK_CLOSING_STRING; + public static final String[] JAVAWS_HTML_ARRAY = new String[]{OptionsDefinitions.OPTIONS.HTML.option}; + public static final List JAVAWS_HTML_LIST = Arrays.asList(JAVAWS_HTML_ARRAY); + //disabled - 1.6 specific. We need dialogs to pop up. Anyway, in 1.6 all such tests are disbaled for runtime anyway + private static final String[] JAVAWS_HEADLES_ARRAY = new String[]{};//{OptionsDefinitions.OPTIONS.HTML.HEADLESS.option}; + private static final List JAVAWS_HEADLES_LIST = Arrays.asList(JAVAWS_HEADLES_ARRAY); + + public static final String JNLPAPP = "CodebasesAttsSignedApp.jnlp"; + public static final String JNLPAPPLET = "CodebasesAttsSignedApplet.jnlp"; + public static final String HTML = "CodebasesAttsSigned.html"; + public static final String HTMLHREF = "CodebasesAttsSignedJnlpHref.html"; + public static final String CodebasesAttsSigned = "CodebasesAttsSigned"; + + private static ServerLauncher secondValidServer; + private static DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier ensuredDP; + + public static final String[] files = new String[]{"CodebasesAttsSignedApp.jnlp", "CodebasesAttsSigned.html", "CodebasesAttsSignedApplet.jnlp", "CodebasesAttsSignedJnlpHref.html"}; + + @BeforeClass + public static void initSecondaryServers() throws IOException { + secondValidServer = ServerAccess.getIndependentInstanceOnTmpDir(); + } + + @AfterClass + public static void stopSecondaryServers() throws IOException { + secondValidServer.stop(); + } + + @BeforeClass + public static void setProperties() throws IOException { + ensuredDP = new DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier( + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.ALL.name()), + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ASK_UNSIGNED.name()) + ); + ensuredDP.setProperties(); + } + + @AfterClass + public static void resetProperties() throws IOException { + ensuredDP.restoreProperties(); + } + + //jar from different source + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJnlp1_null_foreignJar() throws Exception { + prepareSwapResources(); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, secondValidServer.getUrl(JNLPAPP)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJnlp2_null_foreignJar() throws Exception { + prepareSwapResources(); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, secondValidServer.getUrl(JNLPAPPLET)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test// browsers dont support headless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksHtml1_null_foreignJar() throws Exception { + prepareSwapResources(); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test //browsers do not support ehadless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksHtml2_null_foreignJar() throws Exception { + prepareSwapResources(); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJavawsHtml1_null_foreignJar() throws Exception { + prepareSwapResources(); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, secondValidServer.getUrl(HTML)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJavawsHtml2_null_foreignJar() throws Exception { + prepareSwapResources(); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, secondValidServer.getUrl(HTMLHREF)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + //done cross jars + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + //the only alaca one in "normal mode" + public void codebasesAttsSignedTestWorksJnlp1_null() throws Exception { + prepare(null); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, server.getUrl(JNLPAPP)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJnlp2_null() throws Exception { + prepare(null); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, server.getUrl(JNLPAPPLET)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test // browsers dont support headless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksHtml1_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(null, HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test // browsers do not support ehadless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksHtml2_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(null, HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJavawsHtml1_null() throws Exception { + prepare(null); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, server.getUrl(HTML)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJavawsHtml2_null() throws Exception { + prepare(null); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, server.getUrl(HTMLHREF)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAttsSigned)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + public static void prepare(String codebase) throws IOException { + prepare(codebase, codebase); + } + + public static void prepare(String codebase1, String codebase2) throws IOException { + prepareSingle(codebase1, null, null, '1', ServerAccess.getInstance().getDir(), files, true); + prepareSingle(codebase2, null, null, '2', secondValidServer.getDir(), files, true); + } + + //note, that the modification of jar is breaking signature.. well worthy to add test :) + public static void prepareSingle(String codebase, String jnlphref, String jar, char id, File targetDir, String[] files, boolean corrupt) throws IOException { + File srcDir = ServerAccess.getInstance().getDir(); + for (String file : files) { + String s1 = FileUtils.loadFileAsString(new File(srcDir, file + ".in")); + if (codebase == null) { + s1 = s1.replace("@CODEBASE@", ""); + } else { + s1 = s1.replace("@CODEBASE@", "codebase=\"" + codebase + "\""); + } + if (jnlphref == null) { + s1 = s1.replace("@JNLPHREF@", "CodebasesAttsSignedApplet.jnlp"); + } else { + s1 = s1.replace("@JNLPHREF@", jnlphref + "/CodebasesAttsSignedApplet.jnlp"); + } + if (jar == null) { + s1 = s1.replace("@JAR@", "CodebasesAttsSigned"); + } else { + s1 = s1.replace("@JAR@", jar + "/CodebasesAttsSigned"); + } + s1 = s1.replace("@ID@", "" + id); + FileUtils.saveFile(s1, new File(targetDir, file)); + } + String n = "CodebasesAttsSigned.jar"; + if (!srcDir.equals(targetDir)) { + copyJarAndChange(new File(srcDir, n), new File(targetDir, n), id, corrupt); + } + } + + /** + * This copy zip jar entry by entry, and for one particular class it do BYTE + * changes + * + * @param from + * @param to + * @param id + * @throws FileNotFoundException + * @throws IOException + */ + private static void copyJarAndChange(File from, File to, char id, boolean corruptSignatures) throws FileNotFoundException, IOException { + ZipFile original = new ZipFile(from); + try (ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(to))) { + Enumeration entries = original.entries(); + byte[] buffer = new byte[512]; + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + if (entry.getName().endsWith("CodebasesAttsSigned.class") && corruptSignatures) { + ZipEntry newEntry = new ZipEntry(entry.getName()); + outputStream.putNextEntry(newEntry); + try (InputStream in = original.getInputStream(entry)) { + copyStreamAndChange(in, outputStream, id); + } + } else { + ZipEntry newEntry = new ZipEntry(entry.getName()); + outputStream.putNextEntry(newEntry); + try (InputStream in = original.getInputStream(entry)) { + while (0 < in.available()) { + int read = in.read(buffer); + outputStream.write(buffer, 0, read); + } + } + } + outputStream.closeEntry(); + } + } + } + + /** + * This changes bytes BID0 to BID'idchar'. + * + * @param din + * @param dout + * @param id + * @throws FileNotFoundException + * @throws IOException + */ + private static void copyStreamAndChange(InputStream din, OutputStream dout, char id) throws FileNotFoundException, IOException { + int c; + final boolean[] BID0 = new boolean[]{false, false, false}; + while ((c = din.read()) != -1) { + if (c == 'B') { + BID0[0] = true; + dout.write((byte) c); + } else if (c == 'I' && BID0[0]) { + BID0[1] = true; + dout.write((byte) c); + } else if (c == 'D' && BID0[1]) { + BID0[2] = true; + dout.write((byte) c); + } else if (c == '0' && BID0[2]) { + dout.write((byte) id); + reset(BID0); + } else { + reset(BID0); + dout.write((byte) c); + } + } + } + + private static void reset(final boolean[] b) { + for (int i = 0; i < b.length; i++) { + b[i] = false; + + } + } + + //reading corruptied jars + @NeedsDisplay + @Test + public void codebasesAttsSignedTestWorksJnlp1_null_corruptedJar() throws Exception { + prepare(null); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, secondValidServer.getUrl(JNLPAPP)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + ProcessResult pr = pw.execute(); + generalFailure(pr); + } + + @NeedsDisplay + @Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJnlp2_null_corruptedJar() throws Exception { + prepare(null); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, secondValidServer.getUrl(JNLPAPPLET)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + ProcessResult pr = pw.execute(); + generalFailure(pr); + } + + @NeedsDisplay + @Test // browsers dont support headless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksHtml1_null_corruptedJar() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + generalFailure(pr); + } + + @NeedsDisplay + @Test //browsers do not support ehadless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksHtml2_null_corruptedJar() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + generalFailure(pr); + } + + @NeedsDisplay + @Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJavawsHtml1_null_corruptedJar() throws Exception { + prepare(null); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, secondValidServer.getUrl(HTML)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + ProcessResult pr = pw.execute(); + generalFailure(pr); + } + + @NeedsDisplay + @Test + @Bug(id = "PR2489") + public void codebasesAttsSignedTestWorksJavawsHtml2_null_corruptedJar() throws Exception { + prepare(null); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, secondValidServer.getUrl(HTMLHREF)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + ProcessResult pr = pw.execute(); + generalFailure(pr); + } + + public void generalFailure(String s) { + Assert.assertFalse(s.contains(appletCloseString)); + Assert.assertFalse(s.contains("id:")); + Assert.assertFalse(s.contains("BID")); + } + + private void generalFailure(ProcessResult pr) { + generalFailure(pr.stdout); + } + + private void prepareSwapResources() throws IOException { + prepareSingle(null, null, secondValidServer.getUrl().toExternalForm(), '1', ServerAccess.getInstance().getDir(), files, true); + prepareSingle(null, null, server.getUrl().toExternalForm(), '2', secondValidServer.getDir(), files, true); + } + +} diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/resources/CodebasesAtts.html.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/resources/CodebasesAtts.html.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,46 @@ + + + + + + + + + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsApp.jnlp.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsApp.jnlp.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,55 @@ + + + + + + CodebasesAtts + IcedTea + + PR2489 + + + + + + + + @ID@ + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsApplet.jnlp.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsApplet.jnlp.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,59 @@ + + + + + + CodebasesAtts + IcedTea + + PR2489 + + + + + + + + + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsJnlpHref.html.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/resources/CodebasesAttsJnlpHref.html.in Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,47 @@ + + + + + + + + + + + diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/srcs/CodebasesAtts.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/srcs/CodebasesAtts.java Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,86 @@ +/* ExtensionJnlpTestApplet.java + Copyright (C) 2013 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.Graphics; + +/** + * + * Note that for html's appelt and jnlphreff's jnlp file may have different + * codebase. + * + */ +public class CodebasesAtts extends Applet { + + private static final String appletCloseString = "*** APPLET FINISHED ***"; + private static final String bid = "BID0"; + + public static void main(String... args) { + System.out.println("id: "+args[0]); + System.out.println("BID: "+bid); + System.out.println(CodebasesAtts.class.getName()); + System.out.println(appletCloseString); + System.out.flush(); + System.out.println("some garbage"); + } + + @Override + public void init() { + + } + + @Override + public void start() { + main(getParameter("id")); + } + + @Override + public void stop() { + + } + + @Override + public void destroy() { + + } + + @Override + public void paint(Graphics g) { + + } + +} diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsDialogsTest1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsDialogsTest1.java Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,239 @@ +/* CodebasesAttsNoDialogsTest1.java + Copyright (C) 2013 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.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; +import net.sourceforge.jnlp.OptionsDefinitions; +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ProcessWrapper; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.ServerLauncher; +import net.sourceforge.jnlp.annotations.Bug; +import net.sourceforge.jnlp.annotations.NeedsDisplay; +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import net.sourceforge.jnlp.browsertesting.BrowserTest; +import static net.sourceforge.jnlp.browsertesting.BrowserTest.server; +import net.sourceforge.jnlp.browsertesting.Browsers; +import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener; +import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; +import net.sourceforge.jnlp.config.DeploymentConfiguration; +import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; +import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; +import net.sourceforge.jnlp.util.FileUtils; +import org.junit.AfterClass; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * null, empty, none, wrong, correct jnlp x html different codebases. + * + * no dialogs should be appeared. Second testsuite with ALL dialogs (head only) + * + * + */ +public class CodebasesAttsDialogsTest1 extends BrowserTest { + + private static final String appletCloseString = CodebasesAttsNoDialogsTest1.appletCloseString; + private static final String[] JAVAWS_HTML_ARRAY = CodebasesAttsNoDialogsTest1.JAVAWS_HTML_ARRAY; + private static final List JAVAWS_HTML_LIST = CodebasesAttsNoDialogsTest1.JAVAWS_HTML_LIST; + //disabled - 1.6 specific. We need dialogs to pop up. Anyway, in 1.6 all such tests are disbaled for runtime anyway + private static final String[] JAVAWS_HEADLES_ARRAY = new String[]{};//{OptionsDefinitions.OPTIONS.HTML.HEADLESS.option}; + private static final List JAVAWS_HEADLES_LIST = Arrays.asList(JAVAWS_HEADLES_ARRAY); + + private static final String JNLPAPP = CodebasesAttsNoDialogsTest1.JNLPAPP; + private static final String JNLPAPPLET = CodebasesAttsNoDialogsTest1.JNLPAPPLET; + private static final String HTML = CodebasesAttsNoDialogsTest1.HTML; + private static final String HTMLHREF = CodebasesAttsNoDialogsTest1.HTMLHREF; + private static final String CodebasesAtts = CodebasesAttsNoDialogsTest1.CodebasesAtts; + + private static ServerLauncher secondValidServer; + private static DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier ensuredDP; + + public static final String[] files = new String[]{"CodebasesAttsApp.jnlp", "CodebasesAtts.html", "CodebasesAttsApplet.jnlp", "CodebasesAttsJnlpHref.html"}; + + @BeforeClass + public static void initSecondaryServers() throws IOException { + secondValidServer = ServerAccess.getIndependentInstanceOnTmpDir(); + } + + @AfterClass + public static void stopSecondaryServers() throws IOException { + secondValidServer.stop(); + } + + @BeforeClass + public static void setProperties() throws IOException { + ensuredDP = new DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier( + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.ALL.name()), + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ASK_UNSIGNED.name()) + ); + ensuredDP.setProperties(); + } + + @AfterClass + public static void resetProperties() throws IOException { + ensuredDP.restoreProperties(); + } + + @Test + public void allTestsInThisFileAreDisabled(){ + //because 1.6 do not support headless dialogues + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsTestWorksJnlp1_null() throws Exception { + prepare(null); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, server.getUrl(JNLPAPP)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsTestWorksJnlp2_null() throws Exception { + prepare(null); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), JAVAWS_HEADLES_LIST, server.getUrl(JNLPAPPLET)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test //rowsers dont support headless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsTestWorksHtml1_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(null, HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test //browsers do not support ehadless dialogues + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsTestWorksHtml2_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(null, HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsTestWorksJavawsHtml1_null() throws Exception { + prepare(null); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, server.getUrl(HTML)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + //@Test + @Bug(id = "PR2489") + public void codebasesAttsTestWorksJavawsHtml2_null() throws Exception { + prepare(null); + ArrayList HTML_HEADLESS = new ArrayList<>(); + HTML_HEADLESS.addAll(JAVAWS_HEADLES_LIST); + HTML_HEADLESS.addAll(JAVAWS_HTML_LIST); + ProcessWrapper pw = new ProcessWrapper(server.getJavawsLocation(), HTML_HEADLESS, server.getUrl(HTMLHREF)); + pw.addStdOutListener(new AutoOkClosingListener()); + pw.addStdErrListener(new AutoErrorClosingListener()); + //pw.setWriter("YES\nYES\nYES\nYES\n"); + ProcessResult pr = pw.execute(); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + public static void prepare(String codebase) throws IOException { + prepare(codebase, codebase); + } + + public static void prepare(String codebase1, String codebase2) throws IOException { + CodebasesAttsNoDialogsTest1.prepareSingle(codebase1, null, null, '1', ServerAccess.getInstance().getDir(), files); + CodebasesAttsNoDialogsTest1.prepareSingle(codebase2, null, null, '2', secondValidServer.getDir(), files); + } + +} diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest1.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest1.java Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,699 @@ +/* CodebasesAttsNoDialogsTest1.java + Copyright (C) 2013 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.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipOutputStream; +import net.sourceforge.jnlp.OptionsDefinitions; +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.ServerLauncher; +import net.sourceforge.jnlp.annotations.Bug; +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.closinglisteners.AutoErrorClosingListener; +import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; +import net.sourceforge.jnlp.config.DeploymentConfiguration; +import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; +import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; +import net.sourceforge.jnlp.util.FileUtils; +import org.junit.AfterClass; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * null, empty, none, wrong, correct jnlp x html different codebases. + * + * no dialogs should be appeared. Second testsuite with ALL dialogs (head only) + * + * + */ +public class CodebasesAttsNoDialogsTest1 extends BrowserTest { + + public static final String appletCloseString = AutoOkClosingListener.MAGICAL_OK_CLOSING_STRING; + public static final String[] JAVAWS_HTML_ARRAY = new String[]{OptionsDefinitions.OPTIONS.HTML.option}; + public static final List JAVAWS_HTML_LIST = Arrays.asList(JAVAWS_HTML_ARRAY); + + public static final String JNLPAPP = "CodebasesAttsApp.jnlp"; + public static final String JNLPAPPLET = "CodebasesAttsApplet.jnlp"; + public static final String HTML = "CodebasesAtts.html"; + public static final String HTMLHREF = "CodebasesAttsJnlpHref.html"; + public static final String CodebasesAtts = "CodebasesAtts"; + + private static ServerLauncher emptyServer; + private static ServerLauncher secondValidServer; + private static DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier ensuredDP; + + public static final String[] files = new String[]{"CodebasesAttsApp.jnlp", "CodebasesAtts.html", "CodebasesAttsApplet.jnlp", "CodebasesAttsJnlpHref.html"}; + + @BeforeClass + public static void initSecondaryServers() throws IOException { + emptyServer = ServerAccess.getIndependentInstanceOnTmpDir(); + secondValidServer = ServerAccess.getIndependentInstanceOnTmpDir(); + } + + @AfterClass + public static void stopSecondaryServers() throws IOException { + emptyServer.stop(); + secondValidServer.stop(); + } + + @BeforeClass + public static void setProperties() throws IOException { + ensuredDP = new DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier( + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.NONE.name()), + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.name()) + ); + ensuredDP.setProperties(); + } + + @AfterClass + public static void resetProperties() throws IOException { + ensuredDP.restoreProperties(); + } + + //jnlp app + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_dot() throws Exception { + prepare("\".\""); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_empty() throws Exception { + prepare("\"\""); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_space() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_spaces() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @Bug(id = "PR2489") + public void codebasesAttsTestWorksJnlp1_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_value() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + //all three are valid, but on l one bug is supported nows + @Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + public void codebasesAttsTestWorksJnlp1_value2() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeJavaws(JNLPAPP, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); //param comes from original jnlp, this will be visible on jnlp_href + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_value3() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeJavawsUponUrl(null, new URL(secondValidServer.getUrl().toString() + "/" + JNLPAPP), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + //value3 and 4 tests ar emoreover testing taht our three servers are working as expected. + @NeedsDisplay + @Test + //all three are valid, but on l one bug is supported now + @Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + public void codebasesAttsTestWorksJnlp1_value4() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeJavawsUponUrl(null, new URL(secondValidServer.getUrl().toString() + "/" + JNLPAPP), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); //param comes from original jnlp, this will be visible on jnlp_href + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + //jnlp applet + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_dot() throws Exception { + prepare("\".\""); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_empty() throws Exception { + prepare("\"\""); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_space() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_spaces() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @Bug(id = "PR2489") + public void codebasesAttsTestWorksJnlp2_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_value() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + //all three are valid, but on l one bug is supported now + @Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksJnlp2_value2() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeJavaws(JNLPAPPLET, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); //param comes from original jnlp, this will be visible on jnlp_href + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_value3() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeJavawsUponUrl(null, new URL(secondValidServer.getUrl().toString() + "/" + JNLPAPPLET), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + //value3 and 4 tests ar emoreover testing taht our three servers are working as expected. + @NeedsDisplay + @Test + //all three are valid, but on l one bug is supported now + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + @Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksJnlp2_value4() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeJavawsUponUrl(null, new URL(secondValidServer.getUrl().toString() + "/" + JNLPAPPLET), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); //param comes from original jnlp, this will be visible on jnlp_href + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_dot() throws Exception { + prepare("\".\""); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_empty() throws Exception { + prepare("\"\""); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksJHtml1_space() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_spaces() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsTestWorksHtml1_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_value() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + @Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksHtml1_value2() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeBrowser(HTML, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); //param comes from original jnlp, this will be visible on jnlp_href + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_value3() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeBrowser(null, new URL(secondValidServer.getUrl().toString() + "/" + HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + //value3 and 4 tests ar emoreover testing taht our three servers are working as expected. + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + @Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksHtml1_value4() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeBrowser(null, new URL(secondValidServer.getUrl().toString() + "/" + HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); //param comes from original jnlp, this will be visible on jnlp_href + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_dot() throws Exception { + prepare("\".\""); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_empty() throws Exception { + prepare("\"\""); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksJHtml2_space() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_spaces() throws Exception { + prepare("\" \""); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + @Bug(id = "PR2489") + public void codebasesAttsTestWorksHtml2_null() throws Exception { + prepare(null); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_value() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + @Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksHtml2_value2() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeBrowser(HTMLHREF, new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); //param comes from original jnlp, this will be visible on SECOND jnlp_href tests + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_value3() throws Exception { + prepare(secondValidServer.getUrl().toString()); + ProcessResult pr = server.executeBrowser(null, new URL(secondValidServer.getUrl().toString() + "/" + HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + //value3 and 4 tests ar emoreover testing taht our three servers are working as expected. + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + @Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksHtml2_value4() throws Exception { + prepare(server.getUrl().toString()); + ProcessResult pr = server.executeBrowser(null, new URL(secondValidServer.getUrl().toString() + "/" + HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); //param comes from original jnlp, this will be visible on jnlp_href + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + private static void prepare(String codebase) throws IOException { + prepare(codebase, codebase); + } + + private static void prepare(String codebase1, String codebase2) throws IOException { + prepareSingle(codebase1, null, null, '1', ServerAccess.getInstance().getDir(), files); + prepareSingle(codebase2, null, null, '2', secondValidServer.getDir(), files); + } + + public static void prepareSingle(URL codebase, String jnlphref, String jar, char id, File targetDir, String[] files) throws IOException { + prepareSingle(codebase.toExternalForm(), jnlphref, jar, id, targetDir, files); + } + public static void prepareSingle(String codebase, String jnlphref, String jar, char id, File targetDir, String[] files) throws IOException { + File srcDir = ServerAccess.getInstance().getDir(); + for (String file : files) { + String s1 = FileUtils.loadFileAsString(new File(srcDir, file + ".in")); + if (codebase == null) { + s1 = s1.replace("@CODEBASE@", ""); + } else { + s1 = s1.replace("@CODEBASE@", "codebase=\"" + codebase + "\""); + } + if (jnlphref == null) { + s1 = s1.replace("@JNLPHREF@", "CodebasesAttsApplet.jnlp"); + } else { + s1 = s1.replace("@JNLPHREF@", jnlphref + "/CodebasesAttsApplet.jnlp"); + } + if (jar == null) { + s1 = s1.replace("@JAR@", "CodebasesAtts"); + } else { + s1 = s1.replace("@JAR@", jar + "/CodebasesAtts"); + } + s1 = s1.replace("@ID@", "" + id); + FileUtils.saveFile(s1, new File(targetDir, file)); + } + String n = "CodebasesAtts.jar"; + if (!srcDir.equals(targetDir)) { + copyJarAndChange(new File(srcDir, n), new File(targetDir, n), id); + } + } + + /** + * This copy zip jar entry by entry, and for one particular class it do BYTE + * changes + * + * @param from + * @param to + * @param id + * @throws FileNotFoundException + * @throws IOException + */ + private static void copyJarAndChange(File from, File to, char id) throws FileNotFoundException, IOException { + ZipFile original = new ZipFile(from); + try (ZipOutputStream outputStream = new ZipOutputStream(new FileOutputStream(to))) { + Enumeration entries = original.entries(); + byte[] buffer = new byte[512]; + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + if (entry.getName().endsWith("CodebasesAtts.class")) { + ZipEntry newEntry = new ZipEntry(entry.getName()); + outputStream.putNextEntry(newEntry); + try (InputStream in = original.getInputStream(entry)) { + copyStreamAndChange(in, outputStream, id); + } + } else { + ZipEntry newEntry = new ZipEntry(entry.getName()); + outputStream.putNextEntry(newEntry); + try (InputStream in = original.getInputStream(entry)) { + while (0 < in.available()) { + int read = in.read(buffer); + outputStream.write(buffer, 0, read); + } + } + } + outputStream.closeEntry(); + } + } + } + + /** + * This changes bytes BID0 to BID'idchar'. + * + * @param din + * @param dout + * @param id + * @throws FileNotFoundException + * @throws IOException + */ + private static void copyStreamAndChange(InputStream din, OutputStream dout, char id) throws FileNotFoundException, IOException { + int c; + final boolean[] BID0 = new boolean[]{false, false, false}; + while ((c = din.read()) != -1) { + if (c == 'B') { + BID0[0] = true; + dout.write((byte) c); + } else if (c == 'I' && BID0[0]) { + BID0[1] = true; + dout.write((byte) c); + } else if (c == 'D' && BID0[1]) { + BID0[2] = true; + dout.write((byte) c); + } else if (c == '0' && BID0[2]) { + dout.write((byte) id); + reset(BID0); + } else { + reset(BID0); + dout.write((byte) c); + } + } + } + + private static void reset(final boolean[] b) { + for (int i = 0; i < b.length; i++) { + b[i] = false; + + } + } + +} diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest2.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest2.java Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,432 @@ +/* CodebasesAttsNoDialogsTest1.java + Copyright (C) 2013 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.io.IOException; +import java.net.URL; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.List; +import net.sourceforge.jnlp.OptionsDefinitions; +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.ServerLauncher; +import net.sourceforge.jnlp.annotations.Bug; +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.closinglisteners.AutoErrorClosingListener; +import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; +import net.sourceforge.jnlp.config.DeploymentConfiguration; +import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; +import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; +import org.junit.AfterClass; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * null, empty, none, wrong, correct jnlp x html different codebases. + * + * no dialogs should be appeared. Second testsuite with ALL dialogs (head only) + * + * + */ +public class CodebasesAttsNoDialogsTest2 extends BrowserTest { + + private static final String appletCloseString = CodebasesAttsNoDialogsTest1.appletCloseString; + private static final String[] HTMLA = CodebasesAttsNoDialogsTest1.JAVAWS_HTML_ARRAY; + private static final List HTMLL = CodebasesAttsNoDialogsTest1.JAVAWS_HTML_LIST; + + private static final String JNLPAPP = CodebasesAttsNoDialogsTest1.JNLPAPP; + private static final String JNLPAPPLET = CodebasesAttsNoDialogsTest1.JNLPAPPLET; + private static final String HTML = CodebasesAttsNoDialogsTest1.HTML; + private static final String HTMLHREF = CodebasesAttsNoDialogsTest1.HTMLHREF; + private static final String CodebasesAtts = CodebasesAttsNoDialogsTest1.CodebasesAtts; + + private static ServerLauncher secondValidServer; + private static DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier ensuredDP; + + @BeforeClass + public static void initSecondaryServers() throws IOException { + secondValidServer = ServerAccess.getIndependentInstanceOnTmpDir(); + } + + @AfterClass + public static void stopSecondaryServers() throws IOException { + secondValidServer.stop(); + } + + @BeforeClass + public static void setProperties() throws IOException { + ensuredDP = new DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier( + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.NONE.name()), + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.name()) + ); + ensuredDP.setProperties(); + } + + @AfterClass + public static void resetProperties() throws IOException { + ensuredDP.restoreProperties(); + } + + //jnlp app + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_NormalValid_normal() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, server.getUrl(JNLPAPP), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_NormalValid_second() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, secondValidServer.getUrl(JNLPAPP), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_ValidNormal_normal() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, server.getUrl(JNLPAPP), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp1_ValidNormal_second() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, secondValidServer.getUrl(JNLPAPP), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + //jnlp app let + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_NormalValid_normal() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, server.getUrl(JNLPAPPLET), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_NormalValid_second() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, secondValidServer.getUrl(JNLPAPPLET), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_ValidNormal_normal() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, server.getUrl(JNLPAPPLET), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + public void codebasesAttsTestWorksJnlp2_ValidNormal_second() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeJavawsUponUrl(null, secondValidServer.getUrl(JNLPAPPLET), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + //html + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_NormalValid_normal() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_NormalValid_second() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_ValidNormal_normal() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml1_ValidNormal_second() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + //htmlhref relative hrefs + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_NormalValid_normal() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_NormalValid_second() throws Exception { + prepare(server.getUrl(), secondValidServer.getUrl()); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_ValidNormal_normal() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); //codebase is relative, so launchiong server is used to locate jnlp + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_ValidNormal_second() throws Exception { + prepare(secondValidServer.getUrl(), server.getUrl()); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2"));//jnlphref is relative, so launchiong server is used to locate jnlp + } + + public void prepare(URL c1, URL c2) throws IOException { + prepare(c1.toExternalForm(), c2.toExternalForm()); + } + + public static void prepare(String codebase1, String codebase2) throws IOException { + CodebasesAttsNoDialogsTest1.prepareSingle(codebase1, null, null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(codebase2, null, null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + } + + //htmlhref absolute hrefs + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_NormalValid_normal_absoluteJnlpHrefNormal() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), server.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), server.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + @Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksHtml2_NormalValid_normal_absoluteJnlpHrefSecond() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + @Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksHtml2_NormalValid_second_absoluteJnlpHrefNormal() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), server.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), server.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_NormalValid_second_absoluteJnlpHrefSecond() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + @Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a7") + public void codebasesAttsTestWorksHtml2_ValidNormal_normal_absoluteJnlpHrefNormal() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), server.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), server.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_ValidNormal_normal_absoluteJnlpHrefSecond() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + ProcessResult pr = server.executeBrowser(null, server.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 1")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + public void codebasesAttsTestWorksHtml2_ValidNormal_second_bsoluteJnlpHrefNormal() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), server.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), server.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID2")); + } + + @NeedsDisplay + @Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + @Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a + public void codebasesAttsTestWorksHtml2_ValidNormal_second_bsoluteJnlpHrefSecond() throws Exception { + CodebasesAttsNoDialogsTest1.prepareSingle(secondValidServer.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle(server.getUrl(), secondValidServer.getUrl().toExternalForm(), null, '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + ProcessResult pr = server.executeBrowser(null, secondValidServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + Assert.assertTrue(pr.stdout.contains(appletCloseString)); + Assert.assertTrue(pr.stdout.contains(CodebasesAtts)); + Assert.assertTrue(pr.stdout.contains("id: 2")); + Assert.assertTrue(pr.stdout.contains("BID0")); + } + +} diff -r 978b3c7070b7 -r 530bb97e9f08 tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest3.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/reproducers/simple/CodebasesAtts/testcases/CodebasesAttsNoDialogsTest3.java Wed Jan 27 17:03:41 2016 +0100 @@ -0,0 +1,308 @@ +/* CodebasesAttsNoDialogsTest1.java + Copyright (C) 2013 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.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import net.sourceforge.jnlp.OptionsDefinitions; +import net.sourceforge.jnlp.ProcessResult; +import net.sourceforge.jnlp.ServerAccess; +import net.sourceforge.jnlp.ServerLauncher; +import net.sourceforge.jnlp.annotations.Bug; +import net.sourceforge.jnlp.annotations.KnownToFail; +import net.sourceforge.jnlp.annotations.NeedsDisplay; +import net.sourceforge.jnlp.annotations.TestInBrowsers; +import net.sourceforge.jnlp.browsertesting.Browser; +import net.sourceforge.jnlp.browsertesting.BrowserFactory; +import net.sourceforge.jnlp.browsertesting.BrowserTest; +import static net.sourceforge.jnlp.browsertesting.BrowserTest.server; +import net.sourceforge.jnlp.browsertesting.Browsers; +import net.sourceforge.jnlp.closinglisteners.AutoErrorClosingListener; +import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener; +import net.sourceforge.jnlp.config.DeploymentConfiguration; +import net.sourceforge.jnlp.runtime.ManifestAttributesChecker; +import net.sourceforge.jnlp.security.appletextendedsecurity.AppletSecurityLevel; +import net.sourceforge.jnlp.tools.DeploymentPropertiesModifier; +import org.junit.AfterClass; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * null, empty, none, wrong, correct jnlp x html different codebases. + * + * no dialogs should be appeared. Second testsuite with ALL dialogs (head only) + * + * + */ +public class CodebasesAttsNoDialogsTest3 extends BrowserTest { + + private static final String appletCloseString = CodebasesAttsNoDialogsTest1.appletCloseString; + private static final String[] HTMLA = CodebasesAttsNoDialogsTest1.JAVAWS_HTML_ARRAY; + private static final List HTMLL = CodebasesAttsNoDialogsTest1.JAVAWS_HTML_LIST; + + private static final String JNLPAPP = CodebasesAttsNoDialogsTest1.JNLPAPP; + private static final String JNLPAPPLET = CodebasesAttsNoDialogsTest1.JNLPAPPLET; + private static final String HTML = CodebasesAttsNoDialogsTest1.HTML; + private static final String HTMLHREF = CodebasesAttsNoDialogsTest1.HTMLHREF; + private static final String CodebasesAtts = CodebasesAttsNoDialogsTest1.CodebasesAtts; + + private static ServerLauncher secondValidServer; + private static ServerLauncher thirdValidServer; + private static DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier ensuredDP; + + private static final String ABS = "ABS"; + private static boolean WAS; + private static final boolean Force_Outputs = false;//set to true to see outputs of apps in big test + + @BeforeClass + public static void initSecondaryServers() throws IOException { + secondValidServer = ServerAccess.getIndependentInstanceOnTmpDir(); + thirdValidServer = ServerAccess.getIndependentInstanceOnTmpDir(); + } + + @AfterClass + public static void stopSecondaryServers() throws IOException { + secondValidServer.stop(); + thirdValidServer.stop(); + } + + @BeforeClass + public static void setProperties() throws IOException { + ensuredDP = new DeploymentPropertiesModifier.MultipleDeploymentPropertiesModifier( + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_ENABLE_MANIFEST_ATTRIBUTES_CHECK, ManifestAttributesChecker.MANIFEST_ATTRIBUTES_CHECK.NONE.name()), + new AbstractMap.SimpleEntry(DeploymentConfiguration.KEY_SECURITY_LEVEL, AppletSecurityLevel.ALLOW_UNSIGNED.name()) + ); + ensuredDP.setProperties(); + } + + @AfterClass + public static void resetProperties() throws IOException { + ensuredDP.restoreProperties(); + } + + @BeforeClass + public static void setOutput() throws IOException { + WAS = ServerAccess.LOGS_REPRINT; + } + + @AfterClass + public static void resetOutput() throws IOException { + ServerAccess.LOGS_REPRINT = WAS; + } + + /* + *Most fun. jnlp/applet is on page, jnlp on second and resource on third + * (those should fail) + + * As adition, jnlphref have applet on one side, jnlp on second and this one have codebase on THIRD + * (agian representation of that triple bug from CodebasesAttsNoDialogsTest1 + */ + //@Test test is disbaled. Is not testing much more then other CodebasesAttsNoDialogsTest1-3 tests and is fragile. Also its behaviour may change, if loading form non-codebase/docbase resources will be prohibited + //@TestInBrowsers(testIn = Browsers.one) hacked manually. We really do not wont to iterate this test browser-times + public void threeServers__okValues() throws IOException, Exception { + Browser localBrowser = BrowserFactory.getFactory().getRandom(); + setBrowser(localBrowser.getID()); + Browsers browserBackup = getBrowser(); + try { + int totalCounter = 0; + //we know that "" and " " behaves in same way, so let sminimalize this lopp + //abs get substituted by hardcoded path + String[] validValues = new String[]{ABS, null, "", "."}; + for (int a = 0; a < validValues.length; a++) { + String codebaseIn = validValues[a]; + for (int b = 0; b < validValues.length; b++) { + String jnlpHrefIn = validValues[b]; + for (int c = 0; c < validValues.length; c++) { + String jarIn = validValues[c]; + + if (jarIn != null) { + if (jarIn.trim().isEmpty()) { + jarIn = null; + } + } + if (jnlpHrefIn != null) { + if (jnlpHrefIn.trim().isEmpty()) { + jnlpHrefIn = null; + } + } + + //ServerLauncher[] servers = new ServerLauncher[]{ServerAccess.getIndependentInstance(), secondValidServer, thirdValidServer}; + //for (abs x abs or abs x relative or realtive x relative) x (nonm jnlp href) are enough two servers + //lets yousee tmp ones, as they have aligned id and BID + ServerLauncher[] servers = new ServerLauncher[]{secondValidServer, thirdValidServer}; + for (int i = 0; i < servers.length; i++) { + ServerLauncher usedServer = servers[i]; + String[] codebaseJnlpHrefJar = setByServer(usedServer, codebaseIn, jnlpHrefIn, jarIn); + CodebasesAttsNoDialogsTest1.prepareSingle(codebaseJnlpHrefJar[0], codebaseJnlpHrefJar[1], codebaseJnlpHrefJar[2], ("" + (i + 1)).charAt(0), usedServer.getDir(), CodebasesAttsNoDialogsTest1.files); + } + for (int i = 0; i < servers.length; i++) { + totalCounter++; + ServerLauncher usedServer = servers[i]; + //server is caller, only because it knows javaws/browser location + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(totalCounter + ") i=" + i + ", c=" + c + ", b=" + b + ", a=" + a); + ServerAccess.logOutputReprint(usedServer.getUrl().toExternalForm() + ": " + codebaseIn + ", " + jnlpHrefIn + ", " + jarIn); + ServerAccess.logOutputReprint("jnlpapp " + JNLPAPP); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr1 = server.executeJavawsUponUrl(null, usedServer.getUrl(JNLPAPP), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr1.stdout); + ServerAccess.logOutputReprint(pr1.stderr); + generalPass(pr1); + ServerAccess.logOutputReprint("jnlpapplet " + JNLPAPPLET); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr2 = server.executeJavawsUponUrl(null, usedServer.getUrl(JNLPAPPLET), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr2.stdout); + ServerAccess.logOutputReprint(pr2.stderr); + generalPass(pr2); + ServerAccess.logOutputReprint("html " + HTML); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr3 = server.executeBrowser(null, usedServer.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr3.stdout); + ServerAccess.logOutputReprint(pr3.stderr); + generalPass(pr3); + ServerAccess.logOutputReprint("javaws html " + HTML); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr33 = server.executeJavawsUponUrl(HTMLL, usedServer.getUrl(HTML), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr33.stdout); + ServerAccess.logOutputReprint(pr33.stderr); + generalPass(pr33); + ServerAccess.logOutputReprint("htmlhref " + HTMLHREF); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr4 = server.executeBrowser(null, usedServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr4.stdout); + ServerAccess.logOutputReprint(pr4.stderr); + generalPass(pr4); + ServerAccess.logOutputReprint("javaws htmlhref " + HTMLHREF); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr44 = server.executeJavawsUponUrl(HTMLL, usedServer.getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr44.stdout); + ServerAccess.logOutputReprint(pr44.stderr); + generalPass(pr44); + } + + } + } + } + } finally { + setBrowser(browserBackup); + } + } + + //@Test + @TestInBrowsers(testIn = Browsers.one) + //all three are valid, but on l one bug is supported now + @Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a + public void threeServers_resourceIsElsewhere1_html() throws IOException, Exception { + CodebasesAttsNoDialogsTest1.prepareSingle((String) null, secondValidServer.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle((String) null, null, thirdValidServer.getUrl().toExternalForm(), '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle((String) null, null, null, '3', thirdValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint("htmlhref " + HTMLHREF); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr4 = server.executeBrowser(null, ServerAccess.getInstance().getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr4.stdout); + ServerAccess.logOutputReprint(pr4.stderr); + Assert.assertTrue(pr4.stdout.contains("id: 1")); //param is from applet page + Assert.assertTrue(pr4.stdout.contains("BID3")); + ServerAccess.LOGS_REPRINT = WAS; + } + + @Test + @Bug(id = "PR2805") + @KnownToFail + //all three are valid, but on l one bug is supported now, but 2805 have priority + //@Bug(id = "http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2016-January/034446.html") + //@Bug(id = "http://icedtea.classpath.org/hg/release/icedtea-web-1.6/rev/0d9faf51357d") + //@Bug(id = "http://icedtea.classpath.org/hg/icedtea-web/rev/22b7becd48a + public void threeServers_resourceIsElsewhere1_javawshtml() throws IOException, Exception { + CodebasesAttsNoDialogsTest1.prepareSingle((String) null, secondValidServer.getUrl().toExternalForm(), null, '1', ServerAccess.getInstance().getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle((String) null, null, thirdValidServer.getUrl().toExternalForm(), '2', secondValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + CodebasesAttsNoDialogsTest1.prepareSingle((String) null, null, null, '3', thirdValidServer.getDir(), CodebasesAttsNoDialogsTest1.files); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint("javaws htmlhref " + HTMLHREF); + ServerAccess.LOGS_REPRINT = false; + ProcessResult pr44 = server.executeJavawsUponUrl(HTMLL, ServerAccess.getInstance().getUrl(HTMLHREF), new AutoOkClosingListener(), new AutoErrorClosingListener()); + ServerAccess.LOGS_REPRINT = Force_Outputs; + ServerAccess.logOutputReprint(pr44.stdout); + ServerAccess.logOutputReprint(pr44.stderr); + //Assert.assertTrue(pr44.stdout.contains("id: 2")); //param is from jnlphreffed file. This may be considered bug + Assert.assertTrue(pr44.stdout.contains("BID3")); + Assert.assertTrue(pr44.stdout.contains("id: 1")); //should be same as threeServers_resourceIsElsewhere1_html + ServerAccess.LOGS_REPRINT = WAS; + } + + private String[] setByServer(ServerLauncher instance, String codebaseIn, String jnlpHrefIn, String jarIn) throws MalformedURLException { + String[] codebaseJnlpHrefJar = new String[]{codebaseIn, jnlpHrefIn, jarIn}; + + if (ABS.equals(codebaseIn)) { + codebaseJnlpHrefJar[0] = instance.getUrl().toExternalForm(); + } + if (ABS.equals(jnlpHrefIn)) { + codebaseJnlpHrefJar[1] = instance.getUrl().toExternalForm(); + } + if (ABS.equals(jarIn)) { + codebaseJnlpHrefJar[2] = instance.getUrl().toExternalForm(); + } + return codebaseJnlpHrefJar; + } + + private void generalPass(ProcessResult pr1) { + generalPass(pr1.stdout); + } + + private void generalPass(String s) { + Assert.assertTrue(s.contains("id: ")); + Assert.assertTrue(s.contains("BID")); + } + +} diff -r 978b3c7070b7 -r 530bb97e9f08 tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java --- a/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java Tue Jan 19 21:14:09 2016 +0100 +++ b/tests/test-extensions/net/sourceforge/jnlp/ServerAccess.java Wed Jan 27 17:03:41 2016 +0100 @@ -228,7 +228,20 @@ public static ServerLauncher getIndependentInstance(String dir, int port) { return getIndependentInstance(dir, port, true); } - public static ServerLauncher getIndependentInstance(String dir, int port,boolean daemon) { + + public static ServerLauncher getIndependentInstance(String dir) throws IOException { + return getIndependentInstance(dir, findFreePort(), true); + } + + public static ServerLauncher getIndependentInstanceOnTmpDir() throws IOException { + File f = File.createTempFile("itwReproducers_", "_anotherDeployDir"); + f.delete(); + f.mkdir(); + f.deleteOnExit(); + return getIndependentInstance(f.getAbsolutePath(), findFreePort(), true); + } + + public static ServerLauncher getIndependentInstance(String dir, int port, boolean daemon) { if (dir == null || dir.trim().length() == 0 || !new File(dir).exists() || !new File(dir).isDirectory()) { @@ -647,6 +660,12 @@ rpw.setReactingProcess(getCurrentBrowser());//current browser may be null, but it does not metter return rpw.execute(); } + + public ProcessResult executeBrowser(List otherargs, URL url, ContentReaderListener stdoutl, ContentReaderListener stderrl) throws Exception { + ProcessWrapper rpw = new ProcessWrapper(getBrowserLocation(), otherargs, url, stdoutl, stderrl, null); + rpw.setReactingProcess(getCurrentBrowser());//current browser may be null, but it does not metter + return rpw.execute(); + } public ProcessResult executeBrowser(List otherargs, String resource, List stdoutl, List stderrl) throws Exception { ProcessWrapper rpw = new ProcessWrapper(getBrowserLocation(), otherargs, getUrlUponThisInstance(resource), stdoutl, stderrl, null); diff -r 978b3c7070b7 -r 530bb97e9f08 tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/firefox/FirefoxProfilesOperator.java --- a/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/firefox/FirefoxProfilesOperator.java Tue Jan 19 21:14:09 2016 +0100 +++ b/tests/test-extensions/net/sourceforge/jnlp/browsertesting/browsers/firefox/FirefoxProfilesOperator.java Wed Jan 27 17:03:41 2016 +0100 @@ -129,11 +129,9 @@ FileInputStream is = new FileInputStream(from); FileOutputStream fos = new FileOutputStream(to); FileChannel f = is.getChannel(); - FileChannel f2 = fos.getChannel(); - try { + try (FileChannel f2 = fos.getChannel()) { f.transferTo(0, f.size(), f2); } finally { - f2.close(); f.close(); } } diff -r 978b3c7070b7 -r 530bb97e9f08 tests/test-extensions/net/sourceforge/jnlp/closinglisteners/AutoErrorClosingListener.java --- a/tests/test-extensions/net/sourceforge/jnlp/closinglisteners/AutoErrorClosingListener.java Tue Jan 19 21:14:09 2016 +0100 +++ b/tests/test-extensions/net/sourceforge/jnlp/closinglisteners/AutoErrorClosingListener.java Wed Jan 27 17:03:41 2016 +0100 @@ -1,38 +1,38 @@ /* AutoErrorClosingListener.java -Copyright (C) 2012 Red Hat, Inc. + Copyright (C) 2012 Red Hat, Inc. -This file is part of IcedTea. + 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 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. + 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. + 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. + 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. + 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. */ package net.sourceforge.jnlp.closinglisteners; @@ -43,4 +43,14 @@ public AutoErrorClosingListener() { super(MAGICAL_ERROR_CLOSING_STRING); } + + @Override + public void lineReaded(String s) { + if (s.contains("FAILED ASSERTION")) { + //dont terminate if it is rhino's org.mozilla.javascript.Kit + } else { + super.lineReaded(s); + } + } + } diff -r 978b3c7070b7 -r 530bb97e9f08 tests/test-extensions/net/sourceforge/jnlp/closinglisteners/StringBasedClosingListener.java --- a/tests/test-extensions/net/sourceforge/jnlp/closinglisteners/StringBasedClosingListener.java Tue Jan 19 21:14:09 2016 +0100 +++ b/tests/test-extensions/net/sourceforge/jnlp/closinglisteners/StringBasedClosingListener.java Wed Jan 27 17:03:41 2016 +0100 @@ -40,7 +40,7 @@ public class StringBasedClosingListener extends ClosingListener { - private final String condition; + protected final String condition; public StringBasedClosingListener(String condition) { this.condition = condition;