author | herrick |
Wed, 23 Oct 2019 10:37:54 -0400 | |
branch | JDK-8200758-branch |
changeset 58762 | 0fe62353385b |
parent 58671 | 3b578a5976df |
child 58888 | d802578912f3 |
permissions | -rw-r--r-- |
58416 | 1 |
/* |
2 |
* Copyright (c) 2019, 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 |
package jdk.jpackage.tests; |
|
25 |
||
26 |
import java.io.IOException; |
|
27 |
import java.nio.file.Files; |
|
28 |
import java.nio.file.Path; |
|
29 |
import java.util.List; |
|
30 |
import java.util.ArrayList; |
|
58648 | 31 |
import java.util.function.Function; |
32 |
import java.util.function.Predicate; |
|
58463 | 33 |
import java.util.regex.Pattern; |
58416 | 34 |
import java.util.stream.Collectors; |
58648 | 35 |
import java.util.stream.Stream; |
36 |
import jdk.jpackage.test.*; |
|
58671
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
37 |
import jdk.jpackage.test.Functional.ThrowingConsumer; |
58416 | 38 |
import jdk.jpackage.test.Annotations.*; |
39 |
||
40 |
/* |
|
41 |
* @test |
|
42 |
* @summary jpackage basic testing |
|
43 |
* @library ../../../../helpers |
|
44 |
* @build jdk.jpackage.test.* |
|
58648 | 45 |
* @modules jdk.jpackage/jdk.jpackage.internal |
58416 | 46 |
* @compile BasicTest.java |
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
47 |
* @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main |
58416 | 48 |
* --jpt-run=jdk.jpackage.tests.BasicTest |
49 |
*/ |
|
50 |
||
58648 | 51 |
public final class BasicTest { |
58416 | 52 |
@Test |
53 |
public void testNoArgs() { |
|
54 |
List<String> output = JPackageCommand.filterOutput( |
|
58463 | 55 |
getJPackageToolProvider().executeAndGetOutput()); |
58416 | 56 |
TKit.assertStringListEquals(List.of("Usage: jpackage <mode> <options>", |
57 |
"Use jpackage --help (or -h) for a list of possible options"), |
|
58 |
output, "Check jpackage output"); |
|
59 |
} |
|
60 |
||
61 |
@Test |
|
62 |
public void testVersion() { |
|
63 |
List<String> output = JPackageCommand.filterOutput( |
|
58463 | 64 |
getJPackageToolProvider() |
58416 | 65 |
.addArgument("--version") |
66 |
.executeAndGetOutput()); |
|
67 |
TKit.assertStringListEquals(List.of(System.getProperty("java.version")), |
|
68 |
output, "Check jpackage output"); |
|
69 |
} |
|
70 |
||
71 |
@Test |
|
58648 | 72 |
public void testHelp() { |
73 |
List<String> hOutput = getJPackageToolProvider() |
|
74 |
.addArgument("-h").executeAndGetOutput(); |
|
75 |
List<String> helpOutput = getJPackageToolProvider() |
|
76 |
.addArgument("--help").executeAndGetOutput(); |
|
77 |
||
78 |
TKit.assertStringListEquals(hOutput, helpOutput, |
|
79 |
"Check -h and --help parameters produce the same output"); |
|
80 |
||
81 |
final String windowsPrefix = "--win-"; |
|
82 |
final String linuxPrefix = "--linux-"; |
|
83 |
final String osxPrefix = "--mac-"; |
|
84 |
||
85 |
final String expectedPrefix; |
|
86 |
final List<String> unexpectedPrefixes; |
|
87 |
||
88 |
if (TKit.isWindows()) { |
|
89 |
expectedPrefix = windowsPrefix; |
|
90 |
unexpectedPrefixes = List.of(osxPrefix, linuxPrefix); |
|
91 |
} else if (TKit.isLinux()) { |
|
92 |
expectedPrefix = linuxPrefix; |
|
93 |
unexpectedPrefixes = List.of(windowsPrefix, osxPrefix); |
|
94 |
} else if (TKit.isOSX()) { |
|
95 |
expectedPrefix = osxPrefix; |
|
96 |
unexpectedPrefixes = List.of(linuxPrefix, windowsPrefix); |
|
97 |
} else { |
|
98 |
throw TKit.throwUnknownPlatformError(); |
|
99 |
} |
|
100 |
||
101 |
Function<String, Predicate<String>> createPattern = (prefix) -> { |
|
102 |
return Pattern.compile("^ " + prefix).asPredicate(); |
|
103 |
}; |
|
104 |
||
105 |
Function<List<String>, Long> countStrings = (prefixes) -> { |
|
106 |
return hOutput.stream().filter( |
|
107 |
prefixes.stream().map(createPattern).reduce(x -> false, |
|
108 |
Predicate::or)).peek(TKit::trace).count(); |
|
109 |
}; |
|
110 |
||
111 |
TKit.trace("Check parameters in help text"); |
|
112 |
TKit.assertNotEquals(0, countStrings.apply(List.of(expectedPrefix)), |
|
113 |
"Check help text contains plaform specific parameters"); |
|
114 |
TKit.assertEquals(0, countStrings.apply(unexpectedPrefixes), |
|
115 |
"Check help text doesn't contain unexpected parameters"); |
|
116 |
} |
|
117 |
||
118 |
@Test |
|
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
119 |
@SuppressWarnings("unchecked") |
58648 | 120 |
public void testVerbose() { |
121 |
JPackageCommand cmd = JPackageCommand.helloAppImage() |
|
122 |
.setFakeRuntime().executePrerequisiteActions(); |
|
123 |
||
124 |
List<String> expectedVerboseOutputStrings = new ArrayList<>(); |
|
125 |
expectedVerboseOutputStrings.add("Creating app package:"); |
|
126 |
if (TKit.isWindows()) { |
|
127 |
expectedVerboseOutputStrings.add("Result application bundle:"); |
|
128 |
expectedVerboseOutputStrings.add( |
|
129 |
"Succeeded in building Windows Application Image package"); |
|
130 |
} else if (TKit.isLinux()) { |
|
131 |
expectedVerboseOutputStrings.add( |
|
132 |
"Succeeded in building Linux Application Image package"); |
|
133 |
} else if (TKit.isOSX()) { |
|
134 |
expectedVerboseOutputStrings.add("Preparing Info.plist:"); |
|
135 |
expectedVerboseOutputStrings.add( |
|
136 |
"Succeeded in building Mac Application Image package"); |
|
137 |
} else { |
|
138 |
TKit.throwUnknownPlatformError(); |
|
139 |
} |
|
140 |
||
141 |
TKit.deleteDirectoryContentsRecursive(cmd.outputDir()); |
|
142 |
List<String> nonVerboseOutput = cmd.createExecutor().executeAndGetOutput(); |
|
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
143 |
List<String>[] verboseOutput = (List<String>[])new List<?>[1]; |
58648 | 144 |
|
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
145 |
// Directory clean up is not 100% reliable on Windows because of |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
146 |
// antivirus software that can lock .exe files. Setup |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
147 |
// diffreent output directory instead of cleaning the default one for |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
148 |
// verbose jpackage run. |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
149 |
TKit.withTempDirectory("verbose-output", tempDir -> { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
150 |
cmd.setArgumentValue("--dest", tempDir); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
151 |
verboseOutput[0] = cmd.createExecutor().addArgument( |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
152 |
"--verbose").executeAndGetOutput(); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
153 |
}); |
58648 | 154 |
|
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
155 |
TKit.assertTrue(nonVerboseOutput.size() < verboseOutput[0].size(), |
58648 | 156 |
"Check verbose output is longer than regular"); |
157 |
||
158 |
expectedVerboseOutputStrings.forEach(str -> { |
|
159 |
TKit.assertTextStream(str).label("regular output") |
|
160 |
.predicate(String::contains).negate() |
|
161 |
.apply(nonVerboseOutput.stream()); |
|
162 |
}); |
|
163 |
||
164 |
expectedVerboseOutputStrings.forEach(str -> { |
|
165 |
TKit.assertTextStream(str).label("verbose output") |
|
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58671
diff
changeset
|
166 |
.apply(verboseOutput[0].stream()); |
58648 | 167 |
}); |
168 |
} |
|
169 |
||
170 |
@Test |
|
58416 | 171 |
public void testNoName() { |
172 |
final String mainClassName = "Greetings"; |
|
173 |
||
58648 | 174 |
JPackageCommand cmd = JPackageCommand.helloAppImage(mainClassName) |
58416 | 175 |
.removeArgumentWithValue("--name"); |
176 |
||
177 |
Path expectedImageDir = cmd.outputDir().resolve(mainClassName); |
|
178 |
if (TKit.isOSX()) { |
|
179 |
expectedImageDir = expectedImageDir.getParent().resolve( |
|
180 |
expectedImageDir.getFileName().toString() + ".app"); |
|
181 |
} |
|
182 |
||
183 |
cmd.executeAndAssertHelloAppImageCreated(); |
|
184 |
TKit.assertEquals(expectedImageDir.toAbsolutePath().normalize().toString(), |
|
58648 | 185 |
cmd.outputBundle().toAbsolutePath().normalize().toString(), |
58416 | 186 |
String.format( |
187 |
"Check [%s] directory is filled with application image data", |
|
188 |
expectedImageDir)); |
|
189 |
} |
|
190 |
||
191 |
@Test |
|
58648 | 192 |
// Regular app |
193 |
@Parameter("Hello") |
|
194 |
// Modular app |
|
195 |
@Parameter("com.other/com.other.Hello") |
|
196 |
public void testApp(String javaAppDesc) { |
|
197 |
JPackageCommand.helloAppImage(javaAppDesc) |
|
58416 | 198 |
.executeAndAssertHelloAppImageCreated(); |
199 |
} |
|
200 |
||
201 |
@Test |
|
58648 | 202 |
public void testWhitespaceInPaths() { |
203 |
JPackageCommand.helloAppImage("a/b c.jar:Hello") |
|
204 |
.setArgumentValue("--input", TKit.workDir().resolve("The quick brown fox")) |
|
205 |
.setArgumentValue("--dest", TKit.workDir().resolve("jumps over the lazy dog")) |
|
58416 | 206 |
.executeAndAssertHelloAppImageCreated(); |
207 |
} |
|
208 |
||
209 |
@Test |
|
58466
47f0d21c7e8d
8231882: --add-modules ALL-MODULE-PATH is not handled properly
herrick
parents:
58463
diff
changeset
|
210 |
@Parameter("ALL-MODULE-PATH") |
58416 | 211 |
@Parameter("ALL-DEFAULT") |
58648 | 212 |
@Parameter("java.desktop") |
213 |
@Parameter("java.desktop,jdk.jartool") |
|
214 |
@Parameter({ "java.desktop", "jdk.jartool" }) |
|
215 |
public void testAddModules(String... addModulesArg) { |
|
216 |
JPackageCommand cmd = JPackageCommand |
|
217 |
.helloAppImage("goodbye.jar:com.other/com.other.Hello"); |
|
218 |
Stream.of(addModulesArg).map(v -> Stream.of("--add-modules", v)).flatMap( |
|
219 |
s -> s).forEachOrdered(cmd::addArgument); |
|
58416 | 220 |
cmd.executeAndAssertHelloAppImageCreated(); |
221 |
} |
|
222 |
||
223 |
/** |
|
224 |
* Test --temp option. Doesn't make much sense for app image as temporary |
|
58648 | 225 |
* directory is used only on Windows. Test it in packaging mode. |
58416 | 226 |
* @throws IOException |
227 |
*/ |
|
58648 | 228 |
@Test |
58416 | 229 |
public void testTemp() throws IOException { |
58671
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
230 |
TKit.withTempDirectory("temp-root", tempRoot -> { |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
231 |
Function<JPackageCommand, Path> getTempDir = cmd -> { |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
232 |
return tempRoot.resolve(cmd.outputBundle().getFileName()); |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
233 |
}; |
58648 | 234 |
|
58671
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
235 |
ThrowingConsumer<JPackageCommand> addTempDir = cmd -> { |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
236 |
Path tempDir = getTempDir.apply(cmd); |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
237 |
Files.createDirectories(tempDir); |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
238 |
cmd.addArguments("--temp", tempDir); |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
239 |
}; |
58416 | 240 |
|
58671
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
241 |
new PackageTest().configureHelloApp().addInitializer(addTempDir) |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
242 |
.addBundleVerifier(cmd -> { |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
243 |
// Check jpackage actually used the supplied directory. |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
244 |
Path tempDir = getTempDir.apply(cmd); |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
245 |
TKit.assertNotEquals(0, tempDir.toFile().list().length, |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
246 |
String.format( |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
247 |
"Check jpackage wrote some data in the supplied temporary directory [%s]", |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
248 |
tempDir)); |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
249 |
}) |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
250 |
.run(); |
58416 | 251 |
|
58671
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
252 |
new PackageTest().configureHelloApp().addInitializer(addTempDir) |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
253 |
.addInitializer(cmd -> { |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
254 |
// Clean output from the previus jpackage run. |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
255 |
Files.delete(cmd.outputBundle()); |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
256 |
}) |
58416 | 257 |
// Temporary directory should not be empty, |
258 |
// jpackage should exit with error. |
|
58671
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
259 |
.setExpectedExitCode(1) |
3b578a5976df
8232387 : tools/jpackage/share/jdk/jpackage/tests/BasicTest.java fails
herrick
parents:
58648
diff
changeset
|
260 |
.run(); |
58416 | 261 |
}); |
262 |
} |
|
263 |
||
264 |
@Test |
|
265 |
public void testAtFile() throws IOException { |
|
58648 | 266 |
JPackageCommand cmd = JPackageCommand.helloAppImage(); |
58416 | 267 |
|
268 |
// Init options file with the list of options configured |
|
269 |
// for JPackageCommand instance. |
|
270 |
final Path optionsFile = TKit.workDir().resolve("options"); |
|
271 |
Files.write(optionsFile, |
|
272 |
List.of(String.join(" ", cmd.getAllArguments()))); |
|
273 |
||
274 |
// Build app jar file. |
|
275 |
cmd.executePrerequisiteActions(); |
|
276 |
||
277 |
// Make sure output directory is empty. Normally JPackageCommand would |
|
278 |
// do this automatically. |
|
279 |
TKit.deleteDirectoryContentsRecursive(cmd.outputDir()); |
|
280 |
||
281 |
// Instead of running jpackage command through configured |
|
282 |
// JPackageCommand instance, run vanilla jpackage command with @ file. |
|
58463 | 283 |
getJPackageToolProvider() |
58416 | 284 |
.addArgument(String.format("@%s", optionsFile)) |
285 |
.execute().assertExitCodeIsZero(); |
|
286 |
||
287 |
// Verify output of jpackage command. |
|
288 |
cmd.assertImageCreated(); |
|
289 |
HelloApp.executeLauncherAndVerifyOutput(cmd); |
|
290 |
} |
|
291 |
||
292 |
@Parameter("Hello") |
|
293 |
@Parameter("com.foo/com.foo.main.Aloha") |
|
294 |
@Test |
|
295 |
public void testJLinkRuntime(String javaAppDesc) { |
|
58463 | 296 |
JPackageCommand cmd = JPackageCommand.helloAppImage(javaAppDesc); |
58416 | 297 |
|
298 |
// If `--module` parameter was set on jpackage command line, get its |
|
299 |
// value and extract module name. |
|
300 |
// E.g.: foo.bar2/foo.bar.Buz -> foo.bar2 |
|
301 |
// Note: HelloApp class manages `--module` parameter on jpackage command line |
|
302 |
final String moduleName = cmd.getArgumentValue("--module", () -> null, |
|
303 |
(v) -> v.split("/", 2)[0]); |
|
304 |
||
305 |
if (moduleName != null) { |
|
306 |
// Build module jar. |
|
307 |
cmd.executePrerequisiteActions(); |
|
308 |
} |
|
309 |
||
310 |
TKit.withTempDirectory("runtime", runtimeDir -> { |
|
311 |
TKit.deleteDirectoryRecursive(runtimeDir, String.format( |
|
312 |
"Delete [%s] output directory for jlink command", runtimeDir)); |
|
58463 | 313 |
Executor jlink = getToolProvider(JavaTool.JLINK) |
58416 | 314 |
.saveOutput(false) |
315 |
.addArguments( |
|
316 |
"--add-modules", "java.base", |
|
317 |
"--output", runtimeDir.toString(), |
|
318 |
"--strip-debug", |
|
319 |
"--no-header-files", |
|
320 |
"--no-man-pages"); |
|
321 |
||
322 |
if (moduleName != null) { |
|
323 |
jlink.addArguments("--add-modules", moduleName, "--module-path", |
|
324 |
Path.of(cmd.getArgumentValue("--module-path")).resolve( |
|
325 |
"hello.jar").toString()); |
|
326 |
} |
|
327 |
||
328 |
jlink.execute().assertExitCodeIsZero(); |
|
329 |
||
330 |
cmd.addArguments("--runtime-image", runtimeDir); |
|
331 |
cmd.executeAndAssertHelloAppImageCreated(); |
|
332 |
||
58648 | 333 |
final Path appImageRuntimePath = cmd.appRuntimeDirectory(); |
58416 | 334 |
|
58463 | 335 |
// |
58416 | 336 |
// This is an overkill to list modules in jlink output as we have |
337 |
// already verified that Java app is functional and thus app's runtime |
|
338 |
// is likely to be OK, but let's double check. |
|
58463 | 339 |
// |
340 |
// Filter out all first strings with whitespace. They are java |
|
341 |
// launcher output like `Picked up ...` unrelated to module names. |
|
342 |
// |
|
343 |
Pattern whitespaceChar = Pattern.compile("\\s"); |
|
58416 | 344 |
List<String> moduleList = new Executor().dumpOutput().setExecutable( |
345 |
appImageRuntimePath.resolve( |
|
346 |
JPackageCommand.relativePathInRuntime(JavaTool.JAVA))).addArguments( |
|
58463 | 347 |
"--list-modules").executeAndGetOutput().stream().dropWhile( |
348 |
s -> whitespaceChar.matcher(s).find()).sorted().collect( |
|
349 |
Collectors.toList()); |
|
58416 | 350 |
|
351 |
List<String> expectedModules = new ArrayList<>(); |
|
352 |
expectedModules.add(String.format("java.base@%s", |
|
353 |
System.getProperty("java.version"))); |
|
354 |
if (moduleName != null) { |
|
355 |
expectedModules.add(moduleName); |
|
356 |
} |
|
357 |
expectedModules = expectedModules.stream().sorted().collect( |
|
358 |
Collectors.toList()); |
|
359 |
||
360 |
TKit.assertStringListEquals(expectedModules, moduleList, |
|
361 |
String.format( |
|
362 |
"Check modules in application image runtime directory at [%s]", |
|
363 |
appImageRuntimePath)); |
|
364 |
}); |
|
365 |
} |
|
366 |
||
58463 | 367 |
private static Executor getJPackageToolProvider() { |
368 |
return getToolProvider(JavaTool.JPACKAGE); |
|
58416 | 369 |
} |
370 |
||
58463 | 371 |
private static Executor getToolProvider(JavaTool tool) { |
58648 | 372 |
return new Executor().dumpOutput().saveOutput().setToolProvider(tool); |
58416 | 373 |
} |
374 |
} |