author | ssahoo |
Thu, 25 Jan 2018 05:57:22 -0800 | |
changeset 48668 | 2da4a52715d8 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
44673 | 1 |
/* |
48668 | 2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
44673 | 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 |
|
48668 | 26 |
* @bug 8164437 8194486 |
44673 | 27 |
* @summary GSSContext type when jdk.security.jgss is not available |
28 |
* @library /test/lib |
|
29 |
* @compile -XDignore.symbol.file ModuleName.java |
|
45467
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
44673
diff
changeset
|
30 |
* @build jdk.test.lib.Utils |
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
44673
diff
changeset
|
31 |
* jdk.test.lib.Asserts |
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
44673
diff
changeset
|
32 |
* jdk.test.lib.JDKToolFinder |
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
44673
diff
changeset
|
33 |
* jdk.test.lib.JDKToolLauncher |
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
44673
diff
changeset
|
34 |
* jdk.test.lib.Platform |
99c87a16a8e4
8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
iignatyev
parents:
44673
diff
changeset
|
35 |
* jdk.test.lib.process.* |
48668 | 36 |
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts |
37 |
* @run main/othervm -Djdk.net.hosts.file=TestHosts ModuleName |
|
44673 | 38 |
*/ |
39 |
||
40 |
import jdk.test.lib.process.ProcessTools; |
|
41 |
import sun.security.jgss.GSSUtil; |
|
42 |
||
43 |
import java.util.List; |
|
44 |
import java.util.stream.Stream; |
|
45 |
||
46 |
public class ModuleName { |
|
47 |
||
48 |
public static void main(String[] args) throws Throwable { |
|
49 |
||
50 |
if (args.length == 0) { // jtreg launched here |
|
51 |
||
52 |
// With all modules |
|
53 |
test("jdk.security.jgss"); |
|
54 |
||
55 |
// With limited modules |
|
56 |
List<String> cmd = ProcessTools.createJavaProcessBuilder().command(); |
|
57 |
Stream.of(jdk.internal.misc.VM.getRuntimeArguments()) |
|
58 |
.filter(arg -> arg.startsWith("--add-exports=") || |
|
59 |
arg.startsWith("--add-opens=")) |
|
60 |
.forEach(cmd::add); |
|
61 |
cmd.addAll(List.of( |
|
48668 | 62 |
"-Djdk.net.hosts.file=TestHosts", |
44673 | 63 |
"-Dtest.src=" + System.getProperty("test.src"), |
64 |
"--add-modules", |
|
65 |
"java.base,java.security.jgss,jdk.security.auth", |
|
66 |
"--limit-modules", |
|
67 |
"java.security.jgss,jdk.security.auth", |
|
68 |
"ModuleName", |
|
69 |
"launched-limited")); |
|
70 |
ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()])) |
|
71 |
.shouldHaveExitValue(0); |
|
72 |
} else { // Launched by ProcessTools above, with limited modules. |
|
73 |
test("java.security.jgss"); |
|
74 |
} |
|
75 |
} |
|
76 |
||
77 |
static void test(String expected) throws Exception { |
|
78 |
||
79 |
new OneKDC(null).writeJAASConf(); |
|
80 |
||
81 |
Context c = Context.fromJAAS("client"); |
|
82 |
c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID); |
|
83 |
||
84 |
String moduleName = c.x().getClass().getModule().getName(); |
|
85 |
if (!moduleName.equals(expected)) { |
|
86 |
throw new Exception("Expected: " + expected |
|
87 |
+ ". Actual: " + moduleName); |
|
88 |
} |
|
89 |
} |
|
90 |
} |