author | hseigel |
Sat, 10 Sep 2016 08:27:40 -0400 | |
changeset 41114 | f83e9aebbab4 |
parent 40261 | 86a49ba76f52 |
child 43539 | b7c4265f40e7 |
permissions | -rw-r--r-- |
36511 | 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 |
* @library /lib/testlibrary |
|
27 |
* @modules jdk.jlink/jdk.tools.jmod |
|
28 |
* jdk.compiler |
|
29 |
* @build AddModsTest CompilerUtils jdk.testlibrary.* |
|
30 |
* @run testng AddModsTest |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
31 |
* @summary Basic test for java --add-modules |
36511 | 32 |
*/ |
33 |
||
41114
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
34 |
import java.io.File; |
36511 | 35 |
import java.nio.file.Path; |
36 |
import java.nio.file.Paths; |
|
37 |
||
38 |
import static jdk.testlibrary.ProcessTools.*; |
|
39 |
||
40 |
import org.testng.annotations.BeforeTest; |
|
41 |
import org.testng.annotations.Test; |
|
42 |
import static org.testng.Assert.*; |
|
43 |
||
44 |
||
45 |
@Test |
|
46 |
public class AddModsTest { |
|
47 |
||
48 |
private static final String TEST_SRC = System.getProperty("test.src"); |
|
49 |
||
50 |
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
51 |
private static final Path MODS1_DIR = Paths.get("mods1"); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
52 |
private static final Path MODS2_DIR = Paths.get("mods2"); |
36511 | 53 |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
54 |
// test module / main class |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
55 |
private static final String TEST_MODULE = "test"; |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
56 |
private static final String TEST_MAIN_CLASS = "test.Main"; |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
57 |
private static final String TEST_MID = TEST_MODULE + "/" + TEST_MAIN_CLASS; |
36511 | 58 |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
59 |
// logger module |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
60 |
private static final String LOGGER_MODULE = "logger"; |
36511 | 61 |
|
62 |
||
63 |
@BeforeTest |
|
64 |
public void compile() throws Exception { |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
65 |
// javac -d mods1/test src/test/** |
36511 | 66 |
boolean compiled = CompilerUtils.compile( |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
67 |
SRC_DIR.resolve(TEST_MODULE), |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
68 |
MODS1_DIR.resolve(TEST_MODULE) |
36511 | 69 |
); |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
70 |
assertTrue(compiled, "test did not compile"); |
36511 | 71 |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
72 |
// javac -d mods1/logger src/logger/** |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
73 |
compiled= CompilerUtils.compile( |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
74 |
SRC_DIR.resolve(LOGGER_MODULE), |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
75 |
MODS2_DIR.resolve(LOGGER_MODULE) |
36511 | 76 |
); |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
77 |
assertTrue(compiled, "test did not compile"); |
36511 | 78 |
} |
79 |
||
80 |
||
81 |
/** |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
82 |
* Basic test of --add-modules ALL-DEFAULT. Module java.sql should be |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
83 |
* resolved and the types in that module should be visible. |
36511 | 84 |
*/ |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
85 |
public void testAddDefaultModules1() throws Exception { |
36511 | 86 |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
87 |
// java --add-modules ALL-DEFAULT --module-path mods1 -m test ... |
36511 | 88 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
89 |
= executeTestJava("--module-path", MODS1_DIR.toString(), |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
90 |
"--add-modules", "ALL-DEFAULT", |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
91 |
"-m", TEST_MID, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
92 |
"java.sql.Connection") |
36511 | 93 |
.outputTo(System.out) |
94 |
.errorTo(System.out) |
|
95 |
.getExitValue(); |
|
96 |
||
97 |
assertTrue(exitValue == 0); |
|
98 |
} |
|
99 |
||
100 |
/** |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
101 |
* Basic test of --add-modules ALL-DEFAULT. Module java.annotations.common |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
102 |
* should not resolved and so the types in that module should not be |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
103 |
* visible. |
36511 | 104 |
*/ |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
105 |
public void testAddDefaultModules2() throws Exception { |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
106 |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
107 |
// java --add-modules ALL-DEFAULT --module-path mods1 -m test ... |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
108 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
109 |
= executeTestJava("--module-path", MODS1_DIR.toString(), |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
110 |
"--add-modules", "ALL-DEFAULT", |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
111 |
"-m", TEST_MID, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
112 |
"javax.annotation.Generated") |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
113 |
.outputTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
114 |
.errorTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
115 |
.shouldContain("ClassNotFoundException") |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
116 |
.getExitValue(); |
36511 | 117 |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
118 |
assertTrue(exitValue != 0); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
119 |
} |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
120 |
|
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
121 |
/** |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
122 |
* Basic test of --add-modules ALL-SYSTEM. All system modules should be resolved |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
123 |
* and thus all types in those modules should be visible. |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
124 |
*/ |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
125 |
public void testAddSystemModules() throws Exception { |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
126 |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
127 |
// java --add-modules ALL-SYSTEM --module-path mods1 -m test ... |
36511 | 128 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
129 |
= executeTestJava("--module-path", MODS1_DIR.toString(), |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
130 |
"--add-modules", "ALL-SYSTEM", |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
131 |
"-m", TEST_MID, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
132 |
"java.sql.Connection", |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
133 |
"javax.annotation.Generated") |
36511 | 134 |
.outputTo(System.out) |
135 |
.errorTo(System.out) |
|
136 |
.getExitValue(); |
|
137 |
||
138 |
assertTrue(exitValue == 0); |
|
139 |
} |
|
140 |
||
141 |
||
142 |
/** |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
143 |
* Run test on class path to load a type in a module on the application |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
144 |
* module path, uses {@code --add-modules logger}. |
36511 | 145 |
*/ |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
146 |
public void testRunWithAddMods() throws Exception { |
36511 | 147 |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
148 |
// java --module-path mods --add-modules logger -cp classes test.Main |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
149 |
String classpath = MODS1_DIR.resolve(TEST_MODULE).toString(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
150 |
String modulepath = MODS2_DIR.toString(); |
36511 | 151 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
152 |
= executeTestJava("--module-path", modulepath, |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
153 |
"--add-modules", LOGGER_MODULE, |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
154 |
"-cp", classpath, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
155 |
TEST_MAIN_CLASS, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
156 |
"logger.Logger") |
36511 | 157 |
.outputTo(System.out) |
158 |
.errorTo(System.out) |
|
159 |
.getExitValue(); |
|
160 |
||
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
161 |
assertTrue(exitValue == 0); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
162 |
} |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
163 |
|
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
164 |
/** |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
165 |
* Run application on class path that makes use of module on the |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
166 |
* application module path. Does not use --add-modules and so should |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
167 |
* fail at run-time. |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
168 |
*/ |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
169 |
public void testRunMissingAddMods() throws Exception { |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
170 |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
171 |
// java --module-path mods -cp classes test.Main |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
172 |
String classpath = MODS1_DIR.resolve(TEST_MODULE).toString(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
173 |
String modulepath = MODS1_DIR.toString(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
174 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
175 |
= executeTestJava("--module-path", modulepath, |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
176 |
"-cp", classpath, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
177 |
TEST_MAIN_CLASS, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
178 |
"logger.Logger") |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
179 |
.outputTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
180 |
.errorTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
181 |
.shouldContain("ClassNotFoundException") |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
182 |
.getExitValue(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
183 |
|
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
184 |
assertTrue(exitValue != 0); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
185 |
} |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
186 |
|
36511 | 187 |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
188 |
/** |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
189 |
* Run test on class path to load a type in a module on the application |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
190 |
* module path, uses {@code --add-modules ALL-MODULE-PATH}. |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
191 |
*/ |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
192 |
public void testAddAllModulePath() throws Exception { |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
193 |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
194 |
// java --module-path mods --add-modules ALL-MODULE-PATH -cp classes test.Main |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
195 |
String classpath = MODS1_DIR.resolve(TEST_MODULE).toString(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
196 |
String modulepath = MODS1_DIR.toString(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
197 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
198 |
= executeTestJava("--module-path", modulepath, |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
199 |
"--add-modules", "ALL-MODULE-PATH", |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
200 |
"-cp", classpath, |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
201 |
TEST_MAIN_CLASS) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
202 |
.outputTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
203 |
.errorTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
204 |
.getExitValue(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
205 |
|
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
206 |
assertTrue(exitValue == 0); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
207 |
} |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
208 |
|
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
209 |
|
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
210 |
/** |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
211 |
* Test {@code --add-modules ALL-MODULE-PATH} without {@code --module-path}. |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
212 |
*/ |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
213 |
public void testAddAllModulePathWithNoModulePath() throws Exception { |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
214 |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
215 |
// java --add-modules ALL-MODULE-PATH -version |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
216 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
217 |
= executeTestJava("--add-modules", "ALL-MODULE-PATH", |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
218 |
"-version") |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
219 |
.outputTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
220 |
.errorTo(System.out) |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
221 |
.getExitValue(); |
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
222 |
|
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
223 |
assertTrue(exitValue == 0); |
36511 | 224 |
} |
225 |
||
226 |
||
227 |
/** |
|
41114
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
228 |
* Tests {@code --add-modules} be specified more than once. |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
229 |
*/ |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
230 |
public void testWithMultipleAddModules() throws Exception { |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
231 |
|
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
232 |
String modulepath = MODS1_DIR.toString() + File.pathSeparator + |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
233 |
MODS2_DIR.toString(); |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
234 |
int exitValue |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
235 |
= executeTestJava("--module-path", modulepath, |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
236 |
"--add-modules", LOGGER_MODULE, |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
237 |
"--add-modules", TEST_MODULE, |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
238 |
"-m", TEST_MID, |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
239 |
"logger.Logger") |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
240 |
.outputTo(System.out) |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
241 |
.errorTo(System.out) |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
242 |
.getExitValue(); |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
243 |
|
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
244 |
assertTrue(exitValue == 0); |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
245 |
} |
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
246 |
|
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
247 |
|
f83e9aebbab4
8165634: Support multiple --add-modules options on the command line
hseigel
parents:
40261
diff
changeset
|
248 |
/** |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
249 |
* Attempt to run with a bad module name specified to --add-modules |
36511 | 250 |
*/ |
251 |
public void testRunWithBadAddMods() throws Exception { |
|
252 |
||
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
253 |
// java --module-path mods --add-modules DoesNotExist -m test ... |
36511 | 254 |
int exitValue |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
255 |
= executeTestJava("--module-path", MODS1_DIR.toString(), |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37779
diff
changeset
|
256 |
"--add-modules", "DoesNotExist", |
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
257 |
"-m", TEST_MID) |
36511 | 258 |
.outputTo(System.out) |
259 |
.errorTo(System.out) |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36511
diff
changeset
|
260 |
.shouldContain("DoesNotExist") |
36511 | 261 |
.getExitValue(); |
262 |
||
263 |
assertTrue(exitValue != 0); |
|
264 |
} |
|
265 |
||
266 |
} |