< prev index next >

test/tools/launcher/modules/patch/basic/PatchTest.java

Print this page

        

@@ -23,11 +23,12 @@
 
 /**
  * @test
  * @library /lib/testlibrary
  * @modules jdk.compiler
- * @build PatchTest CompilerUtils JarUtils jdk.testlibrary.*
+ *          java.naming
+ * @build PatchTest CompilerUtils JarUtils jdk.testlibrary.tasks.JavaTask
  * @run testng PatchTest
  * @summary Basic test for --patch-module
  */
 
 import java.io.File;

@@ -35,11 +36,11 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import static jdk.testlibrary.ProcessTools.*;
+import jdk.testlibrary.tasks.JavaTask;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 

@@ -128,39 +129,34 @@
     }
 
     /**
      * Run test with patches to java.base, jdk.naming.dns and jdk.compiler
      */
-    void runTest(String basePatches, String dnsPatches, String compilerPatches)
-        throws Exception
-    {
+    void runTest(String basePatches, String dnsPatches, String compilerPatches) {
         // the argument to the test is the list of classes overridden or added
         String arg = Stream.of(CLASSES).collect(Collectors.joining(","));
 
-        int exitValue
-            =  executeTestJava("--patch-module", "java.base=" + basePatches,
-                               "--patch-module", "jdk.naming.dns=" + dnsPatches,
-                               "--patch-module", "jdk.compiler=" + compilerPatches,
-                               "--add-exports", "java.base/java.lang2=test",
-                               "--add-exports", "jdk.naming.dns/com.sun.jndi.dns=test",
-                               "--add-exports", "jdk.naming.dns/com.sun.jndi.dns2=test",
-                               "--add-exports", "jdk.compiler/com.sun.tools.javac2=test",
-                               "--add-modules", "jdk.naming.dns,jdk.compiler",
-                               "--module-path", MODS_DIR.toString(),
-                               "-m", "test/jdk.test.Main", arg)
-                .outputTo(System.out)
-                .errorTo(System.out)
-                .getExitValue();
-
-        assertTrue(exitValue == 0);
+        new JavaTask()
+            .patchModule("java.base", basePatches)
+            .patchModule("jdk.naming.dns", dnsPatches)
+            .patchModule("jdk.compiler", compilerPatches)
+            .addExports("java.base", "java.lang2", "test")
+            .addExports("jdk.naming.dns", "com.sun.jndi.dns", "test")
+            .addExports("jdk.naming.dns", "com.sun.jndi.dns2", "test")
+            .addExports("jdk.compiler", "com.sun.tools.javac2", "test")
+            .addModules("jdk.naming.dns,jdk.compiler")
+            .modulePath(MODS_DIR)
+            .module("test", "jdk.test.Main")
+            .classArgs(arg)
+            .run();
     }
 
 
     /**
      * Run test with ---patch-module and exploded patches
      */
-    public void testWithExplodedPatches() throws Exception {
+    public void testWithExplodedPatches() {
 
         // patches1/java.base:patches2/java.base
         String basePatches = PATCHES1_DIR.resolve("java.base")
                 + File.pathSeparator + PATCHES2_DIR.resolve("java.base");
 

@@ -175,11 +171,11 @@
 
 
     /**
      * Run test with ---patch-module and patches in JAR files
      */
-    public void testWithJarPatches() throws Exception {
+    public void testWithJarPatches() {
 
         // patches/java.base-1.jar:patches/java-base-2.jar
         String basePatches = PATCHES_DIR.resolve("java.base-1.jar")
                 + File.pathSeparator + PATCHES_DIR.resolve("java.base-2.jar");
 

@@ -195,11 +191,11 @@
 
 
     /**
      * Run test with ---patch-module and patches in JAR files and exploded patches
      */
-    public void testWithJarAndExplodedPatches() throws Exception {
+    public void testWithJarAndExplodedPatches() {
 
         // patches/java.base-1.jar:patches2/java.base
         String basePatches = PATCHES_DIR.resolve("java.base-1.jar")
                 + File.pathSeparator + PATCHES2_DIR.resolve("java.base");
 
< prev index next >