< prev index next >
test/jdk/tools/jpackage/share/jdk/jpackage/tests/ModulePathTest.java
Print this page
@@ -22,10 +22,11 @@
*/
package jdk.jpackage.tests;
import java.io.File;
+import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
@@ -69,11 +70,11 @@
public ModulePathTest(String... modulePathArgs) {
this.modulePathArgs = List.of(modulePathArgs);
}
@Test
- public void test() {
+ public void test() throws IOException {
final String moduleName = "com.foo";
JPackageCommand cmd = JPackageCommand.helloAppImage(
"benvenuto.jar:" + moduleName + "/com.foo.Hello");
// Build app jar file.
cmd.executePrerequisiteActions();
@@ -86,14 +87,13 @@
// --module-path should be set in JPackageCommand.helloAppImage call
String goodModulePath = Objects.requireNonNull(cmd.getArgumentValue(
"--module-path"));
cmd.removeArgumentWithValue("--module-path");
- TKit.withTempDirectory("empty-dir", emptyDir -> {
- Path nonExistingDir = TKit.withTempDirectory("non-existing-dir",
- unused -> {
- });
+
+ Path emptyDir = TKit.createTempDirectory("empty-dir");
+ Path nonExistingDir = TKit.withTempDirectory("non-existing-dir", x -> {});
Function<String, String> substitute = str -> {
String v = str;
v = v.replace(GOOD_PATH, goodModulePath);
v = v.replace(EMPTY_DIR, emptyDir.toString());
@@ -119,16 +119,14 @@
"Error: Module %s not found", moduleName);
}
List<String> output = cmd
.saveConsoleOutput(true)
- .execute()
- .assertExitCodeIs(1)
+ .execute(1)
.getOutput();
TKit.assertTextStream(expectedErrorMessage).apply(output.stream());
}
- });
}
private final List<String> modulePathArgs;
private final static String GOOD_PATH = "@GoodPath@";
< prev index next >