< prev index next >
test/tools/launcher/modules/basic/BasicTest.java
Print this page
@@ -22,32 +22,35 @@
*/
/**
* @test
* @library /lib/testlibrary
- * @modules jdk.jartool/sun.tools.jar
- * jdk.jlink/jdk.tools.jmod
- * jdk.compiler
+ * @modules jdk.compiler
+ * jdk.jartool
+ * jdk.jlink
* @build BasicTest CompilerUtils jdk.testlibrary.*
* @run testng BasicTest
* @summary Basic test of starting an application as a module
*/
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.spi.ToolProvider;
import jdk.testlibrary.ProcessTools;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@Test
public class BasicTest {
+ private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar").get();
+ private static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod").get();
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
private static final String TEST_SRC = System.getProperty("test.src");
@@ -130,14 +133,12 @@
"--create",
"--file=" + jar,
"--main-class=" + MAIN_CLASS,
"-C", classes, "."
};
- boolean success
- = new sun.tools.jar.Main(System.out, System.out, "jar")
- .run(args);
- assertTrue(success);
+ int rc = JAR_TOOL.run(System.out, System.out, args);
+ assertTrue(rc == 0);
// java --module-path mlib -module $TESTMODULE
int exitValue = exec("--module-path", dir.toString(),
"--module", TEST_MODULE);
assertTrue(exitValue == 0);
@@ -162,12 +163,12 @@
"create",
"--class-path", cp,
"--main-class", MAIN_CLASS,
jmod
};
- jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask();
- assertEquals(task.run(args), 0);
+
+ assertEquals(JMOD_TOOL.run(System.out, System.out, args), 0);
// java --module-path mods --module $TESTMODULE
int exitValue = exec("--module-path", dir.toString(),
"--module", TEST_MODULE);
assertTrue(exitValue != 0);
@@ -227,14 +228,12 @@
String[] args = {
"--create",
"--file=" + jar,
"-C", classes, "."
};
- boolean success
- = new sun.tools.jar.Main(System.out, System.out, "jar")
- .run(args);
- assertTrue(success);
+ int rc = JAR_TOOL.run(System.out, System.out, args);
+ assertTrue(rc == 0);
// java --module-path mods -m $TESTMODULE
int exitValue = exec("--module-path", dir.toString(), "-m", TEST_MODULE);
assertTrue(exitValue != 0);
}
< prev index next >