< prev index next >

test/jdk/tools/jpackage/share/Base.java

Print this page

        

@@ -19,55 +19,62 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
-import java.io.File;
 import java.nio.file.Files;
+import java.nio.file.Path;
 
-public abstract class JPackageCreateAppImageBase {
-    private static final String app = JPackagePath.getApp();
+public abstract class Base {
     private static final String appOutput = JPackagePath.getAppOutputFile();
-    private static final String appWorkingDir = JPackagePath.getAppWorkingDir();
 
     private static void validateResult(String[] result) throws Exception {
         if (result.length != 2) {
             throw new AssertionError(
                    "Unexpected number of lines: " + result.length);
         }
 
-        if (!result[0].trim().equals("jpackage test application")) {
+        if (!result[0].trim().endsWith("jpackage test application")) {
             throw new AssertionError("Unexpected result[0]: " + result[0]);
         }
 
         if (!result[1].trim().equals("args.length: 0")) {
             throw new AssertionError("Unexpected result[1]: " + result[1]);
         }
     }
 
-    private static void validate() throws Exception {
+    public static void validate(String app) throws Exception {
+        Path outPath = Path.of(appOutput);
         int retVal = JPackageHelper.execute(null, app);
+
+        if (outPath.toFile().exists()) {
+             System.out.println("output contents: ");
+             System.out.println(Files.readString(outPath) + "\n");
+        } else {
+             System.out.println("no output file: " + outPath
+                   + " from command: " + app);
+        }
+
         if (retVal != 0) {
             throw new AssertionError(
-                   "Test application exited with error: " + retVal);
+                "Test application (" + app + ") exited with error: " + retVal);
         }
 
-        File outfile = new File(appWorkingDir + File.separator + appOutput);
-        if (!outfile.exists()) {
+        if (!outPath.toFile().exists()) {
             throw new AssertionError(appOutput + " was not created");
         }
 
-        String output = Files.readString(outfile.toPath());
-        String[] result = output.split("\n");
+        String output = Files.readString(outPath);
+        String[] result = JPackageHelper.splitAndFilter(output);
         validateResult(result);
     }
 
     public static void testCreateAppImage(String [] cmd) throws Exception {
         JPackageHelper.executeCLI(true, cmd);
-        validate();
+        validate(JPackagePath.getApp());
     }
 
     public static void testCreateAppImageToolProvider(String [] cmd) throws Exception {
         JPackageHelper.executeToolProvider(true, cmd);
-        validate();
+        validate(JPackagePath.getApp());
     }
 }
< prev index next >