author | prr |
Tue, 01 Jul 2014 10:20:56 -0700 | |
changeset 25211 | 2476da7d73bf |
parent 11687 | f13cadbb0bb5 |
child 31270 | e6470b24700d |
permissions | -rw-r--r-- |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
1 |
/* |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
2 |
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
4 |
* |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
8 |
* |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
14 |
* |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
18 |
* |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
21 |
* questions. |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
22 |
*/ |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
23 |
|
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
24 |
/* |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
25 |
* @test |
8783
2ea9207f2fad
7027288: (launcher) remove jkernel test from MiscTests
ksrini
parents:
6522
diff
changeset
|
26 |
* @bug 6856415 |
2ea9207f2fad
7027288: (launcher) remove jkernel test from MiscTests
ksrini
parents:
6522
diff
changeset
|
27 |
* @summary Miscellaneous tests, Exceptions |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
28 |
* @compile -XDignore.symbol.file MiscTests.java |
6522
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
29 |
* @run main MiscTests |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
30 |
*/ |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
31 |
|
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
32 |
|
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
33 |
import java.io.File; |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
34 |
import java.io.FileNotFoundException; |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
35 |
|
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
36 |
public class MiscTests extends TestHelper { |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
37 |
|
6522
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
38 |
// 6856415: Checks to ensure that proper exceptions are thrown by java |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
39 |
static void test6856415() { |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
40 |
// No pkcs library on win-x64, so we bail out. |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
41 |
if (is64Bit && isWindows) { |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
42 |
return; |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
43 |
} |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
44 |
StringBuilder sb = new StringBuilder(); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
45 |
sb.append("public static void main(String... args) {\n"); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
46 |
sb.append("java.security.Provider p = new sun.security.pkcs11.SunPKCS11(args[0]);\n"); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
47 |
sb.append("java.security.Security.insertProviderAt(p, 1);\n"); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
48 |
sb.append("}"); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
49 |
File testJar = new File("Foo.jar"); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
50 |
testJar.delete(); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
51 |
try { |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
52 |
createJar(testJar, sb.toString()); |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
53 |
} catch (FileNotFoundException fnfe) { |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
54 |
throw new RuntimeException(fnfe); |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
55 |
} |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
56 |
TestResult tr = doExec(javaCmd, |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
57 |
"-Djava.security.manager", "-jar", testJar.getName(), "foo.bak"); |
6522
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
58 |
for (String s : tr.testOutput) { |
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
59 |
System.out.println(s); |
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
60 |
} |
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
61 |
if (!tr.contains("java.security.AccessControlException:" + |
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
62 |
" access denied (\"java.lang.RuntimePermission\"" + |
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
63 |
" \"accessClassInPackage.sun.security.pkcs11\")")) { |
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
64 |
System.out.println(tr.status); |
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
65 |
} |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
66 |
} |
8783
2ea9207f2fad
7027288: (launcher) remove jkernel test from MiscTests
ksrini
parents:
6522
diff
changeset
|
67 |
|
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
68 |
public static void main(String... args) { |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
69 |
test6856415(); |
11687
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
70 |
if (testExitValue != 0) { |
f13cadbb0bb5
7127906: (launcher) convert the launcher regression tests to java
ksrini
parents:
9035
diff
changeset
|
71 |
throw new Error(testExitValue + " tests failed"); |
5982
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
72 |
} |
de622fe4f7d8
6856415: Enabling java security manager will make programe thrown wrong exception ( main method not found )
ksrini
parents:
diff
changeset
|
73 |
} |
6522
1e468849b92c
6981001: (launcher) EnsureJREInstallation is not being called in order
ksrini
parents:
5982
diff
changeset
|
74 |
} |