# HG changeset patch # User Jiri Vanek # Date 1453814439 -3600 # Node ID 24ae6bdef1fbf4b2534f66dc233cb7ed65aed8b5 # Parent 530bb97e9f08c47b897b9c039985b0a8e1ddbb18 Revisited some jnlp_href tests. diff -r 530bb97e9f08 -r 24ae6bdef1fb ChangeLog --- a/ChangeLog Wed Jan 27 17:03:41 2016 +0100 +++ b/ChangeLog Tue Jan 26 14:20:39 2016 +0100 @@ -1,3 +1,20 @@ +2016-01-26 Jiri Vanek + + Revisited some jnlp_href tests. + * tests/reproducers/signed/ClasspathManifestTest/testcases/ClasspathManifestTest.java: + explained why localtests on "." are passing (removed KnownToFail) and added + (correctly failing) tests in various dirs + * tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java: + used diamond + * tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedNotMatching.java: + same + * tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedMatching.java: + same + * tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedNotMatching.java: + same + * tests/reproducers/simple/SingleInstanceServiceTest/testcases/SingleInstanceTest.java: + fixed midori incompatible tests + 2016-01-25 Jiri Vanek Fixed various cosmetic NPEs when codebase is null (+tests) diff -r 530bb97e9f08 -r 24ae6bdef1fb tests/reproducers/signed/ClasspathManifestTest/testcases/ClasspathManifestTest.java --- a/tests/reproducers/signed/ClasspathManifestTest/testcases/ClasspathManifestTest.java Wed Jan 27 17:03:41 2016 +0100 +++ b/tests/reproducers/signed/ClasspathManifestTest/testcases/ClasspathManifestTest.java Tue Jan 26 14:20:39 2016 +0100 @@ -1,59 +1,74 @@ /* ClasspathManifestTest.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. */ +import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import net.sourceforge.jnlp.ProcessResult; import net.sourceforge.jnlp.ServerAccess; -import net.sourceforge.jnlp.annotations.KnownToFail; import net.sourceforge.jnlp.annotations.NeedsDisplay; import net.sourceforge.jnlp.annotations.TestInBrowsers; import net.sourceforge.jnlp.browsertesting.BrowserTest; import net.sourceforge.jnlp.browsertesting.Browsers; +import net.sourceforge.jnlp.browsertesting.browsers.firefox.FirefoxProfilesOperator; +import net.sourceforge.jnlp.util.FileUtils; +import org.junit.AfterClass; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; public class ClasspathManifestTest extends BrowserTest { - private static String s1 = "Searching for CheckForClasspath."; - private static String s2 = "CheckForClasspath found on classpath."; - private static String ss = "xception"; + private static final String s1 = "Searching for CheckForClasspath."; + private static final String s2 = "CheckForClasspath found on classpath."; + private static final String ss = "xception"; + + private static final String n1 = "ClasspathManifestJNLPHrefTest.html"; + private static final String n4 = "ClasspathManifestApplicationTest.jnlp"; + private static final String n2 = "ClasspathManifestAppletTest.jnlp"; + private static final String n3 = "ClasspathManifestAppletTest.html"; + private static final String[] ns = new String[]{n1, n2, n3, n4}; + private static final String n0 = "ClasspathManifestTest.jar"; + + private static File newRoot; + private static File newRoot1; public void checkAppFails(ProcessResult pr, String testName) { Assert.assertTrue("ClasspathManifest." + testName + " stdout should contain " + s1 + " but didn't", pr.stdout.contains(s1)); @@ -61,69 +76,148 @@ Assert.assertTrue("ClasspathManifest." + testName + " stderr should contain " + ss + " but didn't", pr.stderr.contains(ss)); } - @NeedsDisplay - @Test - public void ApplicationJNLPRemoteTest() throws Exception { - ProcessResult pr = server.executeJavawsHeadless(null, "/ClasspathManifestApplicationTest.jnlp"); - checkAppFails(pr, "ApplicationJNLPRemoteTest"); + public void checkAppPass(ProcessResult pr, String testName) { + Assert.assertTrue("ClasspathManifest." + testName + " stdout should contain " + s1 + " but didn't", pr.stdout.contains(s1)); + Assert.assertTrue("ClasspathManifest." + testName + " stdout should not contain " + s2 + " but did", pr.stdout.contains(s2)); + Assert.assertFalse("ClasspathManifest." + testName + " stderr should contain " + ss + " but didn't", pr.stderr.contains(ss)); + } + + @AfterClass + public static void removeAlternativeLocalDirs() throws IOException { + FirefoxProfilesOperator.deleteRecursively(newRoot); + } + + @BeforeClass + public static void createAlternativeLocalDirs() throws IOException { + newRoot = File.createTempFile("itw", "ClasspathManifestTest"); + newRoot.delete(); + newRoot.mkdirs(); + newRoot.deleteOnExit(); + newRoot1 = new File(newRoot, "r1"); + newRoot1.mkdir(); + FirefoxProfilesOperator.copyRecursively(new File(server.getDir(), "Classpath"), newRoot); + + for (String n : ns) { + copyTextFile(new File(server.getDir(), n), new File(newRoot, n)); + } + FirefoxProfilesOperator.copyFile(new File(server.getDir(), n0), new File(newRoot1, n0)); + } + + public static void copyTextFile(File from, File to) throws IOException { + String s = FileUtils.loadFileAsString(from); +// for (String n : ns) { +// s = s.replaceAll(n, newRoot1.getName()+"/" + n); +// } + s = s.replaceAll(n0, newRoot1.getName() + "/" + n0); + FileUtils.saveFile(s, to); } @NeedsDisplay - @KnownToFail + @Test + public void ApplicationJNLPRemoteTest() throws Exception { + ProcessResult pr = server.executeJavawsHeadless(null, "/" + n4); + checkAppFails(pr, "ApplicationJNLPRemoteTest"); + } + + /** + * See the difference between *LocalTest() and *LocalTest_differentDir(). + * + * Itw always have "." on classpath. So + * + * ./jnlp or ./html (calling to jar.jar) + ./jar.jar + + * ./Codebase/../second.jar are all on classapth but ./jnlp or ./html + * (calling to someDir/jar.jar)+ ./someDir/jar.jar + + * ./Codebase/../second.jar Is making the jar.jar laodable for startup, but + * diapearing after encauntering Class-Path: in Manifest.mf + * + * @throws Exception + */ + @NeedsDisplay @Test public void ApplicationJNLPLocalTest() throws Exception { - List commands=new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); - commands.add("ClasspathManifestApplicationTest.jnlp"); + commands.add(n4); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir()); - checkAppFails(pr, "ApplicationJNLPLocalTest"); + checkAppPass(pr, "ApplicationJNLPLocalTest"); + } + + @NeedsDisplay + @Test + public void ApplicationJNLPLocalTest_differentDir() throws Exception { + List commands = new ArrayList<>(3); + commands.add(server.getJavawsLocation()); + commands.add(ServerAccess.HEADLES_OPTION); + commands.add(n4); + ProcessResult pr = ServerAccess.executeProcess(commands, newRoot); + checkAppFails(pr, "ApplicationJNLPLocalTest_differentDir"); } @NeedsDisplay @Test public void AppletJNLPRemoteTest() throws Exception { - ProcessResult pr = server.executeJavawsHeadless(null, "/ClasspathManifestAppletTest.jnlp"); + ProcessResult pr = server.executeJavawsHeadless(null, "/" + n2); checkAppFails(pr, "AppletJNLPRemoteTest"); } @NeedsDisplay - @KnownToFail @Test public void AppletJNLPRLocalTest() throws Exception { - List commands=new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); - commands.add("ClasspathManifestAppletTest.jnlp"); + commands.add(n2); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir()); - checkAppFails(pr, "AppletJNLPRLocalTest"); + checkAppPass(pr, "AppletJNLPRLocalTest"); + } + + @NeedsDisplay + @Test + public void AppletJNLPRLocalTest_differentDir() throws Exception { + List commands = new ArrayList<>(3); + commands.add(server.getJavawsLocation()); + commands.add(ServerAccess.HEADLES_OPTION); + commands.add(n2); + ProcessResult pr = ServerAccess.executeProcess(commands, newRoot); + checkAppFails(pr, "AppletJNLPRLocalTest_differentDir"); } @NeedsDisplay @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserJNLPHrefRemoteTest() throws Exception { - ProcessResult pr = server.executeBrowser("/ClasspathManifestJNLPHrefTest.html"); + ProcessResult pr = server.executeBrowser("/" + n1); checkAppFails(pr, "BrowserJNLPHrefRemoteTest"); } @NeedsDisplay @TestInBrowsers(testIn = {Browsers.one}) - @KnownToFail @Test public void BrowserJNLPHrefLocalTest() throws Exception { - List commands=new ArrayList(2); + List commands = new ArrayList<>(2); commands.add(server.getBrowserLocation()); - commands.add("ClasspathManifestJNLPHrefTest.html"); + commands.add(n1); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir()); - checkAppFails(pr, "BrowserJNLPHrefLocalTest"); + checkAppPass(pr, "BrowserJNLPHrefLocalTest"); + } + + @NeedsDisplay + @TestInBrowsers(testIn = {Browsers.one}) + @Test + public void BrowserJNLPHrefLocalTest_differentDir() throws Exception { + List commands = new ArrayList<>(2); + commands.add(server.getBrowserLocation()); + commands.add(n1); + ProcessResult pr = ServerAccess.executeProcess(commands, newRoot); + checkAppFails(pr, "BrowserJNLPHrefLocalTest_differentDir"); } @NeedsDisplay @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserAppletRemoteTest() throws Exception { - ProcessResult pr = server.executeBrowser("/ClasspathManifestAppletTest.html"); + ProcessResult pr = server.executeBrowser("/" + n3); Assert.assertTrue("ClasspathManifest.BrowserAppletRemoteTest stdout should contain " + s1 + " but didn't", pr.stdout.contains(s1)); // Should be the only one to search manifest for classpath. Assert.assertTrue("ClasspathManifest.BrowserAppletRemoteTest stdout should contain " + s2 + " but didn't", pr.stdout.contains(s2)); diff -r 530bb97e9f08 -r 24ae6bdef1fb tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java --- a/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java Wed Jan 27 17:03:41 2016 +0100 +++ b/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedMatching.java Tue Jan 26 14:20:39 2016 +0100 @@ -37,10 +37,8 @@ import java.io.File; import java.io.IOException; -import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; -import java.util.PropertyResourceBundle; import net.sourceforge.jnlp.ProcessResult; import net.sourceforge.jnlp.ServerAccess; import net.sourceforge.jnlp.annotations.NeedsDisplay; diff -r 530bb97e9f08 -r 24ae6bdef1fb tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedNotMatching.java --- a/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedNotMatching.java Wed Jan 27 17:03:41 2016 +0100 +++ b/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntrySignedNotMatching.java Tue Jan 26 14:20:39 2016 +0100 @@ -74,7 +74,7 @@ @NeedsDisplay @Test public void ApplicationJNLPLocalTest() throws Exception { - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + ".jnlp"); @@ -90,7 +90,7 @@ @Test public void ApplicationJNLPLocalTestWithRemoteCodebase() throws Exception { prepareCopyFile(); - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + "_copy.jnlp"); @@ -109,7 +109,7 @@ @NeedsDisplay @Test public void AppletJNLPRLocalTest() throws Exception { - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + "Applet.jnlp"); @@ -132,7 +132,7 @@ @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserJNLPHrefLocalTest() throws Exception { - List commands = new ArrayList(2); + List commands = new ArrayList<>(2); commands.add(server.getBrowserLocation()); commands.add(GENERAL_NAME + SIGNATURE + "Jnlp.html"); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir(), new AutoOkClosingListener(), null); @@ -144,7 +144,7 @@ @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserAppletLocalTest() throws Exception { - List commands = new ArrayList(2); + List commands = new ArrayList<>(2); commands.add(server.getBrowserLocation()); commands.add(GENERAL_NAME + SIGNATURE + ".html"); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir(), new AutoOkClosingListener(), null); diff -r 530bb97e9f08 -r 24ae6bdef1fb tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedMatching.java --- a/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedMatching.java Wed Jan 27 17:03:41 2016 +0100 +++ b/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedMatching.java Tue Jan 26 14:20:39 2016 +0100 @@ -71,7 +71,7 @@ @Test public void ApplicationJNLPLocalTest() throws Exception { - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + ".jnlp"); @@ -86,7 +86,7 @@ @Test public void ApplicationJNLPLocalTestWithRemoteCodebase() throws Exception { prepareCopyFile(); - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + "_copy.jnlp"); @@ -106,7 +106,7 @@ @NeedsDisplay @Test public void AppletJNLPRLocalTest() throws Exception { - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + "Applet.jnlp"); @@ -128,7 +128,7 @@ @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserJNLPHrefLocalTest() throws Exception { - List commands = new ArrayList(2); + List commands = new ArrayList<>(2); commands.add(server.getBrowserLocation()); commands.add(GENERAL_NAME + SIGNATURE + "Jnlp.html"); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir(), new AutoOkClosingListener(), null); @@ -140,7 +140,7 @@ @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserAppletLocalTest() throws Exception { - List commands = new ArrayList(2); + List commands = new ArrayList<>(2); commands.add(server.getBrowserLocation()); commands.add(GENERAL_NAME + SIGNATURE + ".html"); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir(), new AutoOkClosingListener(), null); diff -r 530bb97e9f08 -r 24ae6bdef1fb tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedNotMatching.java --- a/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedNotMatching.java Wed Jan 27 17:03:41 2016 +0100 +++ b/tests/reproducers/signed/CodeBaseManifestEntrySignedMatching/testcases/CodeBaseManifestEntryUnsignedNotMatching.java Tue Jan 26 14:20:39 2016 +0100 @@ -73,7 +73,7 @@ @Test public void ApplicationJNLPLocalTest() throws Exception { - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + ".jnlp"); @@ -88,7 +88,7 @@ @Test public void ApplicationJNLPLocalTestWithRemoteCodebase() throws Exception { prepareCopyFile(); - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + "_copy.jnlp"); @@ -108,7 +108,7 @@ @NeedsDisplay @Test public void AppletJNLPRLocalTest() throws Exception { - List commands = new ArrayList(3); + List commands = new ArrayList<>(3); commands.add(server.getJavawsLocation()); commands.add(ServerAccess.HEADLES_OPTION); commands.add(GENERAL_NAME + SIGNATURE + "Applet.jnlp"); @@ -130,7 +130,7 @@ @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserJNLPHrefLocalTest() throws Exception { - List commands = new ArrayList(2); + List commands = new ArrayList<>(2); commands.add(server.getBrowserLocation()); commands.add(GENERAL_NAME + SIGNATURE + "Jnlp.html"); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir(), new AutoOkClosingListener(), null); @@ -142,7 +142,7 @@ @TestInBrowsers(testIn = {Browsers.one}) @Test public void BrowserAppletLocalTest() throws Exception { - List commands = new ArrayList(2); + List commands = new ArrayList<>(2); commands.add(server.getBrowserLocation()); commands.add(GENERAL_NAME + SIGNATURE + ".html"); ProcessResult pr = ServerAccess.executeProcess(commands, server.getDir(), new AutoOkClosingListener(), null); diff -r 530bb97e9f08 -r 24ae6bdef1fb tests/reproducers/simple/SingleInstanceServiceTest/testcases/SingleInstanceTest.java --- a/tests/reproducers/simple/SingleInstanceServiceTest/testcases/SingleInstanceTest.java Wed Jan 27 17:03:41 2016 +0100 +++ b/tests/reproducers/simple/SingleInstanceServiceTest/testcases/SingleInstanceTest.java Tue Jan 26 14:20:39 2016 +0100 @@ -168,6 +168,13 @@ @NeedsDisplay @TestInBrowsers(testIn = Browsers.one) public void htmlpAppletXhtmlpApplet() throws Exception { + //others really do + if ((server.getBrowserLocation().endsWith("midori") || server.getBrowserLocation().endsWith("epiphany"))) { + return; + } + if (server.getBrowserLocation().endsWith(ServerAccess.UNSET_BROWSER)) { + return; + } ProcessResult[] results = executeSingleInstanceCheck(htmlpApplet, htmlpApplet); String id = "htmlpAppletXhtmlpApplet"; evaluateFirstInstance(results[0], id); @@ -180,6 +187,13 @@ @NeedsDisplay @TestInBrowsers(testIn = Browsers.one) public void htmlJnlpHrefAppletXhtmlJnlpHrefApplet() throws Exception { + //others really do + if ((server.getBrowserLocation().endsWith("midori") || server.getBrowserLocation().endsWith("epiphany"))) { + return; + } + if (server.getBrowserLocation().endsWith(ServerAccess.UNSET_BROWSER)) { + return; + } ProcessResult[] results = executeSingleInstanceCheck(htmlJnlpHrefApplet, htmlJnlpHrefApplet); String id = "htmlJnlpHrefAppletXhtmlJnlpHrefApplet"; evaluateFirstInstance(results[0], id);