--- old/test/tools/launcher/modules/addreads/AddReadsTest.java 2016-10-26 11:30:46.000000000 -0700 +++ new/test/tools/launcher/modules/addreads/AddReadsTest.java 2016-10-26 11:30:45.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 { - + public void testJUnitOnModulePath() { // 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(); } @@ -107,85 +98,70 @@ * Exercise --add-reads m1=ALL-UNNAMED by running with junit on the * class path. */ - public void testJUnitOnClassPath() throws Exception { - + public void testJUnitOnClassPath() { // 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) + .module(M1, MAIN) + .run(); } /** * Run with junit as a module on the module path but without --add-reads. */ - public void testJUnitOnModulePathMissingAddReads() throws Exception { + public void testJUnitOnModulePathMissingAddReads() { // 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"); } /** * Run with junit on the class path but without --add-reads. */ - public void testJUnitOnClassPathMissingAddReads() throws Exception { + public void testJUnitOnClassPathMissingAddReads() { // 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"); } /** * 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); + public void testJUnitWithMultiValueOption() { + new JavaTask() + .modulePath(MODS_DIR) + .addModules("java.xml", "junit") + .addReads(M1, "java.xml", "junit") + .module(M1, MAIN) + .run(); } /** * 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); + public void testWithTargetSpecifiedManyTimes() { + new JavaTask() + .modulePath(MODS_DIR) + .addModules("java.xml", "junit") + .addReads(M1, "java.xml") + .addReads(M1, "junit") + .module(M1, MAIN) + .run(Task.Expect.FAIL) + .shouldContain(Task.OutputKind.STDOUT, "specified more than once"); } @@ -193,10 +169,11 @@ * Exercise --add-reads with bad values */ @Test(dataProvider = "badvalues") - public void testWithBadValue(String value, String ignore) throws Exception { - + public void testWithBadValue(String value, String ignore) { // --add-exports $VALUE -version - assertTrue(run("--add-reads", value, "-version").getExitValue() != 0); + new JavaTask() + .vmOptions(value, "-version") + .run(Task.Expect.FAIL); } @DataProvider(name = "badvalues")