Ignore:
Timestamp:
Sep 24, 2014, 9:34:21 PM (11 years ago)
Author:
dmik
Message:

icedtea-web: Merge version 1.5.1 from vendor to trunk.

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
     2import java.applet.Applet;
     3
    14/* AddShutdownHook.java
    2 Copyright (C) 2011 Red Hat, Inc.
     5 Copyright (C) 2011 Red Hat, Inc.
    36
    4 This file is part of IcedTea.
     7 This file is part of IcedTea.
    58
    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 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.
    912
    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.
     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.
    1417
    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.
     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.
    1922
    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.
     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.
    2427
    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.
     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.
    3639 */
     40public class AddShutdownHook extends Applet {
    3741
    38 public class AddShutdownHook {
    3942    public static void main(String[] args) {
    4043
    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");
    4756    }
    4857}
  • trunk/icedtea-web/tests/reproducers/simple/AddShutdownHook/testcases/AddShutdownHookTest.java

    r418 r429  
    11/* AddShutdownHookTest.java
    2 Copyright (C) 2011 Red Hat, Inc.
     2 Copyright (C) 2011 Red Hat, Inc.
    33
    4 This file is part of IcedTea.
     4 This file is part of IcedTea.
    55
    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.
     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.
    99
    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.
     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.
    1414
    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.
     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.
    1919
    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.
     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.
    2424
    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.
     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.
    3636 */
    3737
    38 import net.sourceforge.jnlp.ServerAccess;
     38import net.sourceforge.jnlp.ClosingListener;
     39import net.sourceforge.jnlp.ProcessResult;
     40import net.sourceforge.jnlp.annotations.TestInBrowsers;
     41import net.sourceforge.jnlp.browsertesting.BrowserTest;
     42import net.sourceforge.jnlp.browsertesting.Browsers;
     43import net.sourceforge.jnlp.closinglisteners.RulesFolowingClosingListener;
     44import net.sourceforge.jnlp.closinglisteners.StringMatchClosingListener;
    3945import org.junit.Assert;
    4046
    4147import org.junit.Test;
    4248
    43 public class AddShutdownHookTest {
     49public class AddShutdownHookTest extends BrowserTest {
    4450
    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);
    4658
    4759    @Test
    4860    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));
    5666        Assert.assertEquals((Integer) 0, pr.returnValue);
    5767    }
     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    }
    5881}
Note: See TracChangeset for help on using the changeset viewer.