1 /* 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @bug 8037776 27 @summary tests that the WarningWindow is properly disposed 28 @author Petr Pchelko 29 @library ../../regtesthelpers/process 30 @build ProcessResults ProcessCommunicator 31 @run main WarningWindowDisposeTest 32 */ 33 34 import java.awt.*; 35 import java.awt.Toolkit; 36 import java.util.concurrent.atomic.AtomicBoolean; 37 import java.security.Permission; 38 import java.io.File; 39 40 import test.java.awt.regtesthelpers.process.ProcessCommunicator; 41 import test.java.awt.regtesthelpers.process.ProcessResults; 42 43 public class WarningWindowDisposeTest { 44 45 public static void main(String[] args) { 46 final AtomicBoolean passed = new AtomicBoolean(false); 47 new Thread(() -> { 48 try { 49 Thread.sleep(5000); 50 } catch (InterruptedException e) { 51 throw new RuntimeException("Test FAILED!", e); 52 } 53 if (!passed.get()) { 54 throw new RuntimeException("Test FAILED! The child process never exits"); 55 } 56 }, "TimeoutThread").start(); 57 58 String classpath = System.getProperty("java.class.path"); 59 String policyPath = System.getProperty("test.src")+File.separatorChar+"policy"; 60 System.out.println("policyPath in main: "+policyPath); 61 ProcessResults pres = ProcessCommunicator.executeChildProcess(TestApplication.class, classpath+" -Djava.security.manager -Djava.security.policy="+policyPath, new String[0]); 62 passed.set(true); 63 if (pres.getStdErr() != null && pres.getStdErr().length() > 0) { 64 System.err.println("========= Child VM System.err ========"); 65 System.err.print(pres.getStdErr()); 66 System.err.println("======================================"); 67 } 68 69 if (pres.getStdOut() != null && pres.getStdOut().length() > 0) { 70 System.err.println("========= Child VM System.out ========"); 71 System.err.print(pres.getStdOut()); 72 System.err.println("======================================"); 73 } 74 } | 1 /* 2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @key headful 27 @bug 8037776 8167288 28 @summary tests that the WarningWindow is properly disposed 29 @library ../../regtesthelpers/process 30 @build ProcessResults ProcessCommunicator 31 @run main WarningWindowDisposeTest 32 */ 33 34 import java.awt.*; 35 import java.awt.Toolkit; 36 import java.util.concurrent.atomic.AtomicBoolean; 37 import java.security.Permission; 38 import java.io.File; 39 40 import test.java.awt.regtesthelpers.process.ProcessCommunicator; 41 import test.java.awt.regtesthelpers.process.ProcessResults; 42 43 public class WarningWindowDisposeTest { 44 45 public static void main(String[] args) { 46 final AtomicBoolean passed = new AtomicBoolean(false); 47 new Thread(() -> { 48 for (int trial = 0; trial < 5; ++trial) { 49 try { 50 Thread.sleep(2000); 51 } catch (InterruptedException e) { 52 throw new RuntimeException("Test FAILED!", e); 53 } 54 if (passed.get()) { 55 break; 56 } else if (trial == 4) { 57 throw new RuntimeException("Child process never exits"); 58 } 59 } 60 }, "TimeoutThread").start(); 61 62 String classpath = System.getProperty("java.class.path"); 63 String policyPath = System.getProperty("test.src")+File.separatorChar+"policy"; 64 System.out.println("policyPath in main: "+policyPath); 65 ProcessResults pres = ProcessCommunicator.executeChildProcess(TestApplication.class, classpath+" -Djava.security.manager -Djava.security.policy="+policyPath, new String[0]); 66 passed.set(true); 67 if (pres.getStdErr() != null && pres.getStdErr().length() > 0) { 68 System.err.println("========= Child VM System.err ========"); 69 System.err.print(pres.getStdErr()); 70 System.err.println("======================================"); 71 } 72 73 if (pres.getStdOut() != null && pres.getStdOut().length() > 0) { 74 System.err.println("========= Child VM System.out ========"); 75 System.err.print(pres.getStdOut()); 76 System.err.println("======================================"); 77 } 78 } |