21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 import java.io.File; |
24 import java.io.File; |
25 import java.nio.file.Files; |
25 import java.nio.file.Files; |
|
26 import java.nio.file.Path; |
26 |
27 |
27 public abstract class JPackageCreateAppImageBase { |
28 public abstract class JPackageCreateAppImageBase { |
28 private static final String appOutput = JPackagePath.getAppOutputFile(); |
29 private static final String appOutput = JPackagePath.getAppOutputFile(); |
29 private static final String appWorkingDir = JPackagePath.getAppWorkingDir(); |
30 private static final String appWorkingDir = JPackagePath.getAppWorkingDir(); |
30 |
31 |
42 throw new AssertionError("Unexpected result[1]: " + result[1]); |
43 throw new AssertionError("Unexpected result[1]: " + result[1]); |
43 } |
44 } |
44 } |
45 } |
45 |
46 |
46 public static void validate(String app) throws Exception { |
47 public static void validate(String app) throws Exception { |
47 int retVal = JPackageHelper.execute(null, app); |
48 Path outPath = Path.of(appWorkingDir, appOutput); |
|
49 int retVal = JPackageHelper.execute(outPath.toFile(), app); |
|
50 |
|
51 if (outPath.toFile().exists()) { |
|
52 System.out.println("output contents: "); |
|
53 System.out.println(Files.readString(outPath) + "\n"); |
|
54 } else { |
|
55 System.out.println("no output file: " + outPath |
|
56 + " from command: " + app); |
|
57 } |
|
58 |
48 if (retVal != 0) { |
59 if (retVal != 0) { |
49 throw new AssertionError( |
60 throw new AssertionError( |
50 "Test application exited with error: " + retVal); |
61 "Test application (" + app + ") exited with error: " + retVal); |
51 } |
62 } |
52 |
63 |
53 File outfile = new File(appWorkingDir + File.separator + appOutput); |
64 if (!outPath.toFile().exists()) { |
54 if (!outfile.exists()) { |
|
55 throw new AssertionError(appOutput + " was not created"); |
65 throw new AssertionError(appOutput + " was not created"); |
56 } |
66 } |
57 |
67 |
58 String output = Files.readString(outfile.toPath()); |
68 String output = Files.readString(outPath); |
59 String[] result = output.split("\n"); |
69 String[] result = output.split("\n"); |
60 validateResult(result); |
70 validateResult(result); |
61 } |
71 } |
62 |
72 |
63 public static void testCreateAppImage(String [] cmd) throws Exception { |
73 public static void testCreateAppImage(String [] cmd) throws Exception { |