- Timestamp:
- Sep 24, 2014, 9:34:21 PM (11 years ago)
- Location:
- trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook
- Files:
-
- 2 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook/srcs/AddShutdownHook.java
r418 r429 1 2 import java.applet.Applet; 3 1 4 /* AddShutdownHook.java 2 Copyright (C) 2011 Red Hat, Inc.5 Copyright (C) 2011 Red Hat, Inc. 3 6 4 This file is part of IcedTea.7 This file is part of IcedTea. 5 8 6 IcedTea is free software; you can redistribute it and/or7 modify it under the terms of the GNU General Public License as published by8 the Free Software Foundation, version 2.9 IcedTea is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, version 2. 9 12 10 IcedTea is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13 General Public License for more details.13 IcedTea is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 General Public License for more details. 14 17 15 You should have received a copy of the GNU General Public License16 along with IcedTea; see the file COPYING. If not, write to17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA18 02110-1301 USA.18 You should have received a copy of the GNU General Public License 19 along with IcedTea; see the file COPYING. If not, write to 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 02110-1301 USA. 19 22 20 Linking this library statically or dynamically with other modules is21 making a combined work based on this library. Thus, the terms and22 conditions of the GNU General Public License cover the whole23 combination.23 Linking this library statically or dynamically with other modules is 24 making a combined work based on this library. Thus, the terms and 25 conditions of the GNU General Public License cover the whole 26 combination. 24 27 25 As a special exception, the copyright holders of this library give you26 permission to link this library with independent modules to produce an27 executable, regardless of the license terms of these independent28 modules, and to copy and distribute the resulting executable under29 terms of your choice, provided that you also meet, for each linked30 independent module, the terms and conditions of the license of that31 module. An independent module is a module which is not derived from32 or based on this library. If you modify this library, you may extend33 this exception to your version of the library, but you are not34 obligated to do so. If you do not wish to do so, delete this35 exception statement from your version.28 As a special exception, the copyright holders of this library give you 29 permission to link this library with independent modules to produce an 30 executable, regardless of the license terms of these independent 31 modules, and to copy and distribute the resulting executable under 32 terms of your choice, provided that you also meet, for each linked 33 independent module, the terms and conditions of the license of that 34 module. An independent module is a module which is not derived from 35 or based on this library. If you modify this library, you may extend 36 this exception to your version of the library, but you are not 37 obligated to do so. If you do not wish to do so, delete this 38 exception statement from your version. 36 39 */ 40 public class AddShutdownHook extends Applet { 37 41 38 public class AddShutdownHook {39 42 public static void main(String[] args) { 40 43 41 Runtime.getRuntime().addShutdownHook(new Thread() { 42 public void run() { 43 // no op 44 } 45 }); 46 44 Runtime.getRuntime().addShutdownHook(new Thread() { 45 public void run() { 46 // no op 47 } 48 }); 49 50 } 51 52 @Override 53 public void start() { 54 main(null); 55 System.err.println("WRONG - ShutdownHook was probably added"); 47 56 } 48 57 } -
trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook/testcases/AddShutdownHookTest.java
r418 r429 1 1 /* AddShutdownHookTest.java 2 Copyright (C) 2011 Red Hat, Inc.2 Copyright (C) 2011 Red Hat, Inc. 3 3 4 This file is part of IcedTea.4 This file is part of IcedTea. 5 5 6 IcedTea is free software; you can redistribute it and/or7 modify it under the terms of the GNU General Public License as published by8 the Free Software Foundation, version 2.6 IcedTea is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, version 2. 9 9 10 IcedTea is distributed in the hope that it will be useful,11 but WITHOUT ANY WARRANTY; without even the implied warranty of12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13 General Public License for more details.10 IcedTea is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 14 15 You should have received a copy of the GNU General Public License16 along with IcedTea; see the file COPYING. If not, write to17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA18 02110-1301 USA.15 You should have received a copy of the GNU General Public License 16 along with IcedTea; see the file COPYING. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 02110-1301 USA. 19 19 20 Linking this library statically or dynamically with other modules is21 making a combined work based on this library. Thus, the terms and22 conditions of the GNU General Public License cover the whole23 combination.20 Linking this library statically or dynamically with other modules is 21 making a combined work based on this library. Thus, the terms and 22 conditions of the GNU General Public License cover the whole 23 combination. 24 24 25 As a special exception, the copyright holders of this library give you26 permission to link this library with independent modules to produce an27 executable, regardless of the license terms of these independent28 modules, and to copy and distribute the resulting executable under29 terms of your choice, provided that you also meet, for each linked30 independent module, the terms and conditions of the license of that31 module. An independent module is a module which is not derived from32 or based on this library. If you modify this library, you may extend33 this exception to your version of the library, but you are not34 obligated to do so. If you do not wish to do so, delete this35 exception statement from your version.25 As a special exception, the copyright holders of this library give you 26 permission to link this library with independent modules to produce an 27 executable, regardless of the license terms of these independent 28 modules, and to copy and distribute the resulting executable under 29 terms of your choice, provided that you also meet, for each linked 30 independent module, the terms and conditions of the license of that 31 module. An independent module is a module which is not derived from 32 or based on this library. If you modify this library, you may extend 33 this exception to your version of the library, but you are not 34 obligated to do so. If you do not wish to do so, delete this 35 exception statement from your version. 36 36 */ 37 37 38 import net.sourceforge.jnlp.ServerAccess; 38 import net.sourceforge.jnlp.ClosingListener; 39 import net.sourceforge.jnlp.ProcessResult; 40 import net.sourceforge.jnlp.annotations.TestInBrowsers; 41 import net.sourceforge.jnlp.browsertesting.BrowserTest; 42 import net.sourceforge.jnlp.browsertesting.Browsers; 43 import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener; 44 import net.sourceforge.jnlp.closinglisteners.StringMatchClosingListener; 39 45 import org.junit.Assert; 40 46 41 47 import org.junit.Test; 42 48 43 public class AddShutdownHookTest {49 public class AddShutdownHookTest extends BrowserTest { 44 50 45 private static ServerAccess server = new ServerAccess(); 51 public static final String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "shutdownHooks" + ".*"; 52 public static final String cnfString = "ClassNotFoundException"; 53 public static final String confirmFailure = "WRONG - ShutdownHook was probably added"; 54 public static final RulesFolowingClosingListener.MatchesRule mr = new RulesFolowingClosingListener.MatchesRule(s); 55 public static final RulesFolowingClosingListener.ContainsRule cnf = new RulesFolowingClosingListener.ContainsRule(cnfString); 56 public static final RulesFolowingClosingListener.ContainsRule cf = new RulesFolowingClosingListener.ContainsRule(confirmFailure); 57 public static final RulesFolowingClosingListener rfc = new RulesFolowingClosingListener(mr); 46 58 47 59 @Test 48 60 public void AddShutdownHookTestLunch1() throws Exception { 49 ServerAccess.ProcessResult pr = server.executeJavawsHeadless(null, "/AddShutdownHook.jnlp"); 50 String s = "(?s).*java.security.AccessControlException.{0,5}access denied.{0,5}java.lang.RuntimePermission.{0,5}" + "shutdownHooks" + ".*"; 51 Assert.assertTrue("stderr should match "+s+" but didn't",pr.stderr.matches(s)); 52 String cc="ClassNotFoundException"; 53 Assert.assertFalse("stderr should NOT contains `"+cc+"`, but did",pr.stderr.contains(cc)); 54 Assert.assertFalse("stdout length should be <=2, but was "+pr.stdout.length(),pr.stdout.length()>2); 55 Assert.assertFalse("AddShutdownHookTestLunch1 should not be terminated, but was",pr.wasTerminated); 61 ProcessResult pr = server.executeJavawsHeadless(null, "/AddShutdownHook.jnlp"); 62 Assert.assertTrue("stderr " + mr.toPassingString(), mr.evaluate(pr.stderr)); 63 Assert.assertFalse("stderr " + cnf.toFailingString(), cnf.evaluate(pr.stderr)); 64 Assert.assertFalse("AddShutdownHookTestLunch1 should not be terminated, but was", pr.wasTerminated); 65 Assert.assertFalse("stderr " + cf.toFailingString(), cf.evaluate(pr.stderr)); 56 66 Assert.assertEquals((Integer) 0, pr.returnValue); 57 67 } 68 69 @Test 70 @TestInBrowsers(testIn = Browsers.one) 71 public void AddShutdownHookApplet() throws Exception { 72 ProcessResult pr = server.executeBrowser("/AddShutdownHook.html", null, rfc); 73 74 if (server.getCurrentBrowsers() == Browsers.firefox) { 75 //lookslike only firefox is able to recieve this 76 Assert.assertTrue("stderr " + mr.toPassingString(), mr.evaluate(pr.stderr)); 77 } 78 Assert.assertFalse("stderr " + cnf.toFailingString(), cnf.evaluate(pr.stderr)); 79 Assert.assertFalse("stderr " + cf.toFailingString(), cf.evaluate(pr.stderr)); 80 } 58 81 }
Note:
See TracChangeset
for help on using the changeset viewer.