--- old/test/tools/launcher/modules/addreads/AddReadsTest.java 2016-10-14 15:06:53.000000000 -0700 +++ new/test/tools/launcher/modules/addreads/AddReadsTest.java 2016-10-14 15:06:53.000000000 -0700 @@ -25,7 +25,7 @@ * @test * @library /lib/testlibrary * @modules jdk.compiler - * @build AddReadsTest CompilerUtils JarUtils jdk.testlibrary.* + * @build AddReadsTest CompilerUtils JarUtils jdk.testlibrary.tasks.* * @run testng AddReadsTest * @summary Basic tests for java --add-reads */ @@ -33,8 +33,8 @@ import java.nio.file.Path; import java.nio.file.Paths; -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.*; +import jdk.testlibrary.tasks.JavaTask; +import jdk.testlibrary.tasks.Task; import org.testng.annotations.BeforeTest; import org.testng.annotations.DataProvider; @@ -57,7 +57,8 @@ private static final Path CLASSES_DIR = Paths.get("classes"); private static final Path MODS_DIR = Paths.get("mods"); - private static final String MAIN = "m1/p.Main"; + private static final String M1 = "m1"; + private static final String MAIN = "p.Main"; @BeforeTest @@ -79,27 +80,17 @@ } - private OutputAnalyzer run(String... options) throws Exception { - return executeTestJava(options) - .outputTo(System.out) - .errorTo(System.out); - } - - /** * Run with junit as a module on the module path. */ public void testJUnitOnModulePath() throws Exception { - // java --module-path mods --add-modules junit --add-reads m1=junit -m .. - int exitValue - = run("--module-path", MODS_DIR.toString(), - "--add-modules", "junit", - "--add-reads", "m1=junit", - "-m", MAIN) - .getExitValue(); - - assertTrue(exitValue == 0); + new JavaTask() + .modulePath(MODS_DIR) + .addModules("junit") + .addReads("m1=junit") + .module(M1, MAIN) + .run(); } @@ -108,17 +99,13 @@ * class path. */ public void testJUnitOnClassPath() throws Exception { - // java --module-path mods -cp mods/junit.jar --add-reads m1=ALL-UNNAMED -m .. - String cp = MODS_DIR.resolve("junit.jar").toString(); - int exitValue - = run("--module-path", MODS_DIR.toString(), - "-cp", cp, - "--add-reads", "m1=ALL-UNNAMED", - "-m", MAIN) - .getExitValue(); - - assertTrue(exitValue == 0); + new JavaTask() + .modulePath(MODS_DIR) + .classPath(MODS_DIR.resolve("junit.jar")) + .addReads("m1=ALL-UNNAMED") + .module(M1, MAIN) + .run(); } @@ -127,14 +114,12 @@ */ public void testJUnitOnModulePathMissingAddReads() throws Exception { // java --module-path mods --add-modules junit --module .. - int exitValue - = run("--module-path", MODS_DIR.toString(), - "--add-modules", "junit", - "--module", MAIN) - .shouldContain("IllegalAccessError") - .getExitValue(); - - assertTrue(exitValue != 0); + new JavaTask() + .modulePath(MODS_DIR) + .addModules("junit") + .module(M1, MAIN) + .run(Task.Expect.FAIL) + .shouldContain(Task.OutputKind.STDERR, "IllegalAccessError"); } @@ -143,15 +128,12 @@ */ public void testJUnitOnClassPathMissingAddReads() throws Exception { // java --module-path mods -cp mods/junit.jar -m .. - String cp = MODS_DIR.resolve("junit.jar").toString(); - int exitValue - = run("--module-path", MODS_DIR.toString(), - "-cp", cp, - "-m", MAIN) - .shouldContain("IllegalAccessError") - .getExitValue(); - - assertTrue(exitValue != 0); + new JavaTask() + .modulePath(MODS_DIR) + .classPath(MODS_DIR.resolve("junit.jar")) + .module(M1, MAIN) + .run(Task.Expect.FAIL) + .shouldContain(Task.OutputKind.STDERR, "IllegalAccessError"); } @@ -159,15 +141,12 @@ * Exercise --add-reads with a more than one source module. */ public void testJUnitWithMultiValueOption() throws Exception { - - int exitValue - = run("--module-path", MODS_DIR.toString(), - "--add-modules", "java.xml,junit", - "--add-reads", "m1=java.xml,junit", - "--module", MAIN) - .getExitValue(); - - assertTrue(exitValue == 0); + new JavaTask() + .modulePath(MODS_DIR) + .addModules("java.xml", "junit") + .addReads("m1=java.xml,junit") + .module(M1, MAIN) + .run(); } @@ -175,17 +154,13 @@ * Exercise --add-reads where the target module is specified more than once */ public void testWithTargetSpecifiedManyTimes() throws Exception { - - int exitValue - = run("--module-path", MODS_DIR.toString(), - "--add-modules", "java.xml,junit", - "--add-reads", "m1=java.xml", - "--add-reads", "m1=junit", - "-m", MAIN) - .shouldContain("specified more than once") - .getExitValue(); - - assertTrue(exitValue != 0); + new JavaTask() + .modulePath(MODS_DIR) + .addModules("java.xml", "junit") + .addReads("m1=java.xml", "m1=junit") + .module(M1, MAIN) + .run(Task.Expect.FAIL) + .shouldContain(Task.OutputKind.STDOUT, "specified more than once"); } @@ -194,9 +169,11 @@ */ @Test(dataProvider = "badvalues") public void testWithBadValue(String value, String ignore) throws Exception { - // --add-exports $VALUE -version - assertTrue(run("--add-reads", value, "-version").getExitValue() != 0); + new JavaTask() + .addReads(value) + .vmOptions("-version") + .run(Task.Expect.FAIL); } @DataProvider(name = "badvalues")