50 private static final String [] CMD1 = {
51 "--package-type", "app-image",
52 "--input", "input",
53 "--dest", OUTPUT,
54 "--name", "test",
55 "--main-jar", "non-existant.jar",
56 };
57 private static final String EXP1 = "main jar does not exist";
58
59 private static final String [] CMD2 = {
60 "--package-type", "app-image",
61 "--input", "input",
62 "--dest", OUTPUT,
63 "--name", "test",
64 "--main-jar", "hello.jar",
65 };
66 private static final String EXP2 = "class was not specified nor was";
67
68 private static void validate(String output, String expected, boolean single)
69 throws Exception {
70 String[] result = output.split("\n");
71 if (single && result.length != 1) {
72 System.err.println(output);
73 throw new AssertionError("Unexpected multiple lines of output: "
74 + output);
75 }
76
77 if (!result[0].trim().contains(expected)) {
78 throw new AssertionError("Unexpected output: " + result[0]
79 + " - expected output to contain: " + expected);
80 }
81 }
82
83
84 public static void main(String[] args) throws Exception {
85 JPackageHelper.createHelloImageJar();
86
87 validate(JPackageHelper.executeToolProvider(false,
88 "--package-type", "app-image", ARG1), EXPECTED1, true);
89 validate(JPackageHelper.executeToolProvider(false,
90 "--package-type", "app-image", ARG2), EXPECTED2, true);
|
50 private static final String [] CMD1 = {
51 "--package-type", "app-image",
52 "--input", "input",
53 "--dest", OUTPUT,
54 "--name", "test",
55 "--main-jar", "non-existant.jar",
56 };
57 private static final String EXP1 = "main jar does not exist";
58
59 private static final String [] CMD2 = {
60 "--package-type", "app-image",
61 "--input", "input",
62 "--dest", OUTPUT,
63 "--name", "test",
64 "--main-jar", "hello.jar",
65 };
66 private static final String EXP2 = "class was not specified nor was";
67
68 private static void validate(String output, String expected, boolean single)
69 throws Exception {
70 String[] result = JPackageHelper.splitAndFilter(output);
71 if (single && result.length != 1) {
72 System.err.println(output);
73 throw new AssertionError("Unexpected multiple lines of output: "
74 + output);
75 }
76
77 if (!result[0].trim().contains(expected)) {
78 throw new AssertionError("Unexpected output: " + result[0]
79 + " - expected output to contain: " + expected);
80 }
81 }
82
83
84 public static void main(String[] args) throws Exception {
85 JPackageHelper.createHelloImageJar();
86
87 validate(JPackageHelper.executeToolProvider(false,
88 "--package-type", "app-image", ARG1), EXPECTED1, true);
89 validate(JPackageHelper.executeToolProvider(false,
90 "--package-type", "app-image", ARG2), EXPECTED2, true);
|