17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @summary jpackage create image missing arguments test 27 * @library ../helpers 28 * @build JPackageHelper 29 * @build JPackagePath 30 * @modules jdk.jpackage 31 * @run main/othervm -Xmx512m MissingArgumentsTest 32 */ 33 34 public class MissingArgumentsTest { 35 private static final String [] RESULT_1 = {"--output"}; 36 private static final String [] CMD_1 = { 37 "--input", "input", 38 "--name", "test", 39 "--main-jar", "hello.jar", 40 "--main-class", "Hello", 41 }; 42 43 private static final String [] RESULT_2 = {"--input"}; 44 private static final String [] CMD_2 = { 45 "--output", "output", 46 "--name", "test", 47 "--main-jar", "hello.jar", 48 "--main-class", "Hello", 49 }; 50 51 private static final String [] RESULT_3 = {"--input", "--app-image"}; 52 private static final String [] CMD_3 = { 53 "--package-type", "invalid-package-type", 54 "--output", "output", 55 "--name", "test", 56 "--main-jar", "hello.jar", 57 "--main-class", "Hello", 58 }; 59 60 private static final String [] RESULT_4 = {"main class was not specified"}; 61 private static final String [] CMD_4 = { 62 "--input", "input", 63 "--output", "output", 64 "--name", "test", 65 "--main-jar", "hello.jar", 66 }; 67 68 private static final String [] RESULT_5 = {"--main-jar"}; 69 private static final String [] CMD_5 = { 70 "--input", "input", 71 "--output", "output", 72 "--name", "test", 73 "--main-class", "Hello", 74 }; 75 76 private static final String [] RESULT_6 = {"--module-path", "--runtime-image"}; 77 private static final String [] CMD_6 = { 78 "--output", "output", 79 "--name", "test", 80 "--module", "com.hello/com.hello.Hello", 81 }; 82 83 private static final String [] RESULT_7 = {"--module-path", "--runtime-image", 84 "--app-image"}; 85 private static final String [] CMD_7 = { 86 "--package-type", "invalid-package-type", 87 "--output", "output", 88 "--name", "test", 89 "--module", "com.hello/com.hello.Hello", 90 }; 91 92 private static void validate(String output, String [] expected, 93 boolean single) throws Exception { 94 String[] result = JPackageHelper.splitAndFilter(output); 95 if (single && result.length != 1) { 96 System.err.println(output); 97 throw new AssertionError("Invalid number of lines in output: " | 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @summary jpackage create image missing arguments test 27 * @library ../helpers 28 * @build JPackageHelper 29 * @build JPackagePath 30 * @modules jdk.jpackage 31 * @run main/othervm -Xmx512m MissingArgumentsTest 32 */ 33 34 public class MissingArgumentsTest { 35 private static final String [] RESULT_1 = {"--output"}; 36 private static final String [] CMD_1 = { 37 "--package-type", "app-image", 38 "--input", "input", 39 "--name", "test", 40 "--main-jar", "hello.jar", 41 "--main-class", "Hello", 42 }; 43 44 private static final String [] RESULT_2 = {"--input"}; 45 private static final String [] CMD_2 = { 46 "--package-type", "app-image", 47 "--output", "output", 48 "--name", "test", 49 "--main-jar", "hello.jar", 50 "--main-class", "Hello", 51 }; 52 53 private static final String [] RESULT_3 = {"--input", "--app-image"}; 54 private static final String [] CMD_3 = { 55 "--package-type", "app-image", 56 "--package-type", "invalid-package-type", 57 "--output", "output", 58 "--name", "test", 59 "--main-jar", "hello.jar", 60 "--main-class", "Hello", 61 }; 62 63 private static final String [] RESULT_4 = {"main class was not specified"}; 64 private static final String [] CMD_4 = { 65 "--package-type", "app-image", 66 "--input", "input", 67 "--output", "output", 68 "--name", "test", 69 "--main-jar", "hello.jar", 70 }; 71 72 private static final String [] RESULT_5 = {"--main-jar"}; 73 private static final String [] CMD_5 = { 74 "--package-type", "app-image", 75 "--input", "input", 76 "--output", "output", 77 "--name", "test", 78 "--main-class", "Hello", 79 }; 80 81 private static final String [] RESULT_6 = {"--module-path", "--runtime-image"}; 82 private static final String [] CMD_6 = { 83 "--package-type", "app-image", 84 "--output", "output", 85 "--name", "test", 86 "--module", "com.hello/com.hello.Hello", 87 }; 88 89 private static final String [] RESULT_7 = {"--module-path", "--runtime-image", 90 "--app-image"}; 91 private static final String [] CMD_7 = { 92 "--package-type", "invalid-package-type", 93 "--output", "output", 94 "--name", "test", 95 "--module", "com.hello/com.hello.Hello", 96 }; 97 98 private static void validate(String output, String [] expected, 99 boolean single) throws Exception { 100 String[] result = JPackageHelper.splitAndFilter(output); 101 if (single && result.length != 1) { 102 System.err.println(output); 103 throw new AssertionError("Invalid number of lines in output: " |