|
1 /* |
|
2 * Copyright (c) 2017, 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 * @modules jdk.jdeps jdk.zipfs |
|
27 * @library /lib/testlibrary |
|
28 * @build ShowModuleResolutionTest jdk.testlibrary.* |
|
29 * @run testng ShowModuleResolutionTest |
|
30 * @summary Basic test for java --show-module-resolution |
|
31 */ |
|
32 |
|
33 import jdk.testlibrary.ProcessTools; |
|
34 |
|
35 import org.testng.annotations.Test; |
|
36 import static org.testng.Assert.*; |
|
37 |
|
38 @Test |
|
39 public class ShowModuleResolutionTest { |
|
40 |
|
41 /** |
|
42 * Test that the resolution does not bind any services |
|
43 */ |
|
44 private void expectJavaBase(String... args) throws Exception { |
|
45 int exitValue = ProcessTools.executeTestJava(args) |
|
46 .outputTo(System.out) |
|
47 .errorTo(System.out) |
|
48 .stdoutShouldContain("root java.base") |
|
49 .stdoutShouldNotContain("java.base binds") |
|
50 .getExitValue(); |
|
51 assertTrue(exitValue == 0); |
|
52 } |
|
53 |
|
54 /** |
|
55 * Test that the resolution binds services that resolves additional |
|
56 * modules |
|
57 */ |
|
58 private void expectProviders(String... args) throws Exception { |
|
59 int exitValue = ProcessTools.executeTestJava(args) |
|
60 .outputTo(System.out) |
|
61 .errorTo(System.out) |
|
62 .stdoutShouldContain("root java.base") |
|
63 .stdoutShouldContain("root java.compiler") |
|
64 .stdoutShouldContain("root jdk.compiler") |
|
65 .stdoutShouldContain("root java.compiler") |
|
66 .stdoutShouldContain("jdk.compiler requires java.compiler") |
|
67 .stdoutShouldContain("java.base binds jdk.compiler") |
|
68 .stdoutShouldContain("java.base binds jdk.jdeps") |
|
69 .stdoutShouldContain("java.base binds jdk.zipfs") |
|
70 .stdoutShouldContain("java.compiler binds jdk.compiler") |
|
71 .stdoutShouldContain("jdk.jdeps requires jdk.compiler") |
|
72 .getExitValue(); |
|
73 assertTrue(exitValue == 0); |
|
74 } |
|
75 |
|
76 public void test() throws Exception { |
|
77 expectJavaBase("--show-module-resolution", |
|
78 "--limit-modules", "java.base", |
|
79 "-version"); |
|
80 expectProviders("--show-module-resolution", |
|
81 "--limit-modules", "java.base,jdk.jdeps,jdk.zipfs", |
|
82 "-version"); |
|
83 } |
|
84 } |