author | mchung |
Wed, 14 Dec 2016 10:51:13 -0800 | |
changeset 42693 | 6645de32a866 |
parent 42338 | a60f280f803c |
child 43503 | bc7f8619ab70 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
2 |
* Copyright (c) 2015, 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 |
* @library /lib/testlibrary |
|
27 |
* @modules java.se |
|
28 |
* @build ListModsTest CompilerUtils jdk.testlibrary.* |
|
29 |
* @run testng ListModsTest |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
30 |
* @summary Basic test for java --list-modules |
36511 | 31 |
*/ |
32 |
||
33 |
import java.nio.file.Path; |
|
34 |
import java.nio.file.Paths; |
|
35 |
||
36 |
import static jdk.testlibrary.ProcessTools.*; |
|
37 |
import jdk.testlibrary.OutputAnalyzer; |
|
38 |
||
39 |
import org.testng.annotations.BeforeTest; |
|
40 |
import org.testng.annotations.Test; |
|
41 |
import static org.testng.Assert.*; |
|
42 |
||
43 |
/** |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
44 |
* Basic tests for java --list-modules |
36511 | 45 |
*/ |
46 |
||
47 |
public class ListModsTest { |
|
48 |
||
49 |
private static final String TEST_SRC = System.getProperty("test.src"); |
|
50 |
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
|
51 |
private static final Path MODS_DIR = Paths.get("mods"); |
|
52 |
private static final Path UPGRADEMODS_DIR = Paths.get("upgrademods"); |
|
53 |
||
54 |
@BeforeTest |
|
55 |
public void setup() throws Exception { |
|
56 |
boolean compiled; |
|
57 |
||
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
58 |
// javac -d mods/m1 --module-path mods src/m1/** |
36511 | 59 |
compiled = CompilerUtils.compile( |
60 |
SRC_DIR.resolve("m1"), |
|
61 |
MODS_DIR.resolve("m1")); |
|
62 |
assertTrue(compiled); |
|
63 |
||
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
64 |
// javac -d upgrademods/java.transaction --module-path mods src/java.transaction/** |
36511 | 65 |
compiled = CompilerUtils.compile( |
66 |
SRC_DIR.resolve("java.transaction"), |
|
67 |
UPGRADEMODS_DIR.resolve("java.transaction")); |
|
68 |
assertTrue(compiled); |
|
69 |
||
70 |
} |
|
71 |
||
72 |
||
73 |
@Test |
|
74 |
public void testListAll() throws Exception { |
|
75 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
76 |
= executeTestJava("--list-modules") |
36511 | 77 |
.outputTo(System.out) |
78 |
.errorTo(System.out); |
|
79 |
output.shouldContain("java.base"); |
|
80 |
output.shouldContain("java.xml"); |
|
81 |
assertTrue(output.getExitValue() == 0); |
|
82 |
} |
|
83 |
||
84 |
||
85 |
@Test |
|
86 |
public void testListOneModule() throws Exception { |
|
87 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
88 |
= executeTestJava("--list-modules=java.base") |
36511 | 89 |
.outputTo(System.out) |
90 |
.errorTo(System.out); |
|
91 |
output.shouldContain("java.base"); |
|
92 |
output.shouldContain("exports java.lang"); |
|
93 |
assertTrue(output.getExitValue() == 0); |
|
94 |
} |
|
95 |
||
96 |
||
97 |
@Test |
|
98 |
public void testListTwoModules() throws Exception { |
|
99 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
100 |
= executeTestJava("--list-modules", "java.base,java.xml") |
36511 | 101 |
.outputTo(System.out) |
102 |
.errorTo(System.out); |
|
103 |
output.shouldContain("java.base"); |
|
104 |
output.shouldContain("exports java.lang"); |
|
105 |
output.shouldContain("java.xml"); |
|
106 |
output.shouldContain("exports javax.xml"); |
|
107 |
assertTrue(output.getExitValue() == 0); |
|
108 |
} |
|
109 |
||
110 |
||
111 |
@Test |
|
112 |
public void testListUnknownModule() throws Exception { |
|
113 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
114 |
= executeTestJava("--list-modules", "java.rhubarb") |
36511 | 115 |
.outputTo(System.out) |
116 |
.errorTo(System.out); |
|
117 |
output.shouldNotContain("java.base"); |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40261
diff
changeset
|
118 |
output.shouldContain("java.rhubarb not observable"); |
36511 | 119 |
assertTrue(output.getExitValue() == 0); |
120 |
} |
|
121 |
||
122 |
||
123 |
@Test |
|
124 |
public void testListWithModulePath() throws Exception { |
|
125 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
126 |
= executeTestJava("--module-path", MODS_DIR.toString(), "--list-modules") |
36511 | 127 |
.outputTo(System.out) |
128 |
.errorTo(System.out); |
|
129 |
output.shouldContain("java.base"); |
|
130 |
output.shouldContain("m1"); |
|
131 |
assertTrue(output.getExitValue() == 0); |
|
132 |
} |
|
133 |
||
134 |
||
135 |
@Test |
|
136 |
public void testListWithUpgradeModulePath() throws Exception { |
|
137 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
138 |
= executeTestJava("--upgrade-module-path", UPGRADEMODS_DIR.toString(), |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
139 |
"--list-modules", "java.transaction") |
36511 | 140 |
.outputTo(System.out) |
141 |
.errorTo(System.out); |
|
142 |
output.shouldContain("exports javax.transaction.atomic"); |
|
143 |
assertTrue(output.getExitValue() == 0); |
|
144 |
} |
|
145 |
||
146 |
||
147 |
@Test |
|
148 |
public void testListWithLimitMods1() throws Exception { |
|
149 |
OutputAnalyzer output |
|
42693 | 150 |
= executeTestJava("--limit-modules", "java.management", "--list-modules") |
36511 | 151 |
.outputTo(System.out) |
152 |
.errorTo(System.out); |
|
42693 | 153 |
output.shouldContain("java.rmi"); |
36511 | 154 |
output.shouldContain("java.base"); |
42693 | 155 |
output.shouldNotContain("java.scripting"); |
36511 | 156 |
assertTrue(output.getExitValue() == 0); |
157 |
} |
|
158 |
||
159 |
||
160 |
@Test |
|
161 |
public void testListWithLimitMods2() throws Exception { |
|
162 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
163 |
= executeTestJava("--module-path", MODS_DIR.toString(), |
42693 | 164 |
"--limit-modules", "java.management", |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
165 |
"--list-modules") |
36511 | 166 |
.outputTo(System.out) |
167 |
.errorTo(System.out); |
|
168 |
output.shouldContain("java.base"); |
|
169 |
output.shouldNotContain("m1"); |
|
170 |
assertTrue(output.getExitValue() == 0); |
|
171 |
} |
|
172 |
||
173 |
||
174 |
/** |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
175 |
* java -version --list-modules => should print version and exit |
36511 | 176 |
*/ |
177 |
@Test |
|
178 |
public void testListWithPrintVersion1() throws Exception { |
|
179 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
180 |
= executeTestJava("-version", "--list-modules") |
36511 | 181 |
.outputTo(System.out) |
182 |
.errorTo(System.out); |
|
183 |
output.shouldNotContain("java.base"); |
|
184 |
output.shouldContain("Runtime Environment"); |
|
185 |
assertTrue(output.getExitValue() == 0); |
|
186 |
} |
|
187 |
||
188 |
||
189 |
/** |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
190 |
* java --list-modules -version => should list modules and exit |
36511 | 191 |
*/ |
192 |
@Test |
|
193 |
public void testListWithPrintVersion2() throws Exception { |
|
194 |
OutputAnalyzer output |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
36511
diff
changeset
|
195 |
= executeTestJava("--list-modules", "-version") |
36511 | 196 |
.outputTo(System.out) |
197 |
.errorTo(System.out); |
|
198 |
output.shouldContain("java.base"); |
|
199 |
output.shouldNotContain("Runtime Environment"); |
|
200 |
assertTrue(output.getExitValue() == 0); |
|
201 |
} |
|
202 |
||
203 |
} |