30 * @modules jdk.jpackage |
30 * @modules jdk.jpackage |
31 * @run main/othervm -Xmx512m MissingArgumentsTest |
31 * @run main/othervm -Xmx512m MissingArgumentsTest |
32 */ |
32 */ |
33 |
33 |
34 public class MissingArgumentsTest { |
34 public class MissingArgumentsTest { |
35 private static final String [] RESULT_1 = {"--output"}; |
35 private static final String [] RESULT_1 = {"--input"}; |
36 private static final String [] CMD_1 = { |
36 private static final String [] CMD_1 = { |
37 "--package-type", "app-image", |
37 "--package-type", "app-image", |
38 "--input", "input", |
38 "--dest", "output", |
39 "--name", "test", |
39 "--name", "test", |
40 "--main-jar", "hello.jar", |
40 "--main-jar", "hello.jar", |
41 "--main-class", "Hello", |
41 "--main-class", "Hello", |
42 }; |
42 }; |
43 |
43 |
44 private static final String [] RESULT_2 = {"--input"}; |
44 private static final String [] RESULT_2 = {"--input", "--app-image"}; |
45 private static final String [] CMD_2 = { |
45 private static final String [] CMD_2 = { |
46 "--package-type", "app-image", |
46 "--package-type", "app-image", |
47 "--output", "output", |
47 "--package-type", "invalid-package-type", |
|
48 "--dest", "output", |
48 "--name", "test", |
49 "--name", "test", |
49 "--main-jar", "hello.jar", |
50 "--main-jar", "hello.jar", |
50 "--main-class", "Hello", |
51 "--main-class", "Hello", |
51 }; |
52 }; |
52 |
53 |
53 private static final String [] RESULT_3 = {"--input", "--app-image"}; |
54 private static final String [] RESULT_3 = {"main class was not specified"}; |
54 private static final String [] CMD_3 = { |
55 private static final String [] CMD_3 = { |
55 "--package-type", "app-image", |
56 "--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", |
57 "--input", "input", |
67 "--output", "output", |
58 "--dest", "output", |
68 "--name", "test", |
59 "--name", "test", |
69 "--main-jar", "hello.jar", |
60 "--main-jar", "hello.jar", |
70 }; |
61 }; |
71 |
62 |
72 private static final String [] RESULT_5 = {"--main-jar"}; |
63 private static final String [] RESULT_4 = {"--main-jar"}; |
73 private static final String [] CMD_5 = { |
64 private static final String [] CMD_4 = { |
74 "--package-type", "app-image", |
65 "--package-type", "app-image", |
75 "--input", "input", |
66 "--input", "input", |
76 "--output", "output", |
67 "--dest", "output", |
77 "--name", "test", |
68 "--name", "test", |
78 "--main-class", "Hello", |
69 "--main-class", "Hello", |
79 }; |
70 }; |
80 |
71 |
81 private static final String [] RESULT_6 = {"--module-path", "--runtime-image"}; |
72 private static final String [] RESULT_5 = {"--module-path", "--runtime-image"}; |
82 private static final String [] CMD_6 = { |
73 private static final String [] CMD_5 = { |
83 "--package-type", "app-image", |
74 "--package-type", "app-image", |
84 "--output", "output", |
75 "--dest", "output", |
85 "--name", "test", |
76 "--name", "test", |
86 "--module", "com.hello/com.hello.Hello", |
77 "--module", "com.hello/com.hello.Hello", |
87 }; |
78 }; |
88 |
79 |
89 private static final String [] RESULT_7 = {"--module-path", "--runtime-image", |
80 private static final String [] RESULT_6 = {"--module-path", "--runtime-image", |
90 "--app-image"}; |
81 "--app-image"}; |
91 private static final String [] CMD_7 = { |
82 private static final String [] CMD_6 = { |
92 "--package-type", "invalid-package-type", |
83 "--package-type", "invalid-package-type", |
93 "--output", "output", |
84 "--dest", "output", |
94 "--name", "test", |
85 "--name", "test", |
95 "--module", "com.hello/com.hello.Hello", |
86 "--module", "com.hello/com.hello.Hello", |
96 }; |
87 }; |
97 |
88 |
98 private static void validate(String output, String [] expected, |
89 private static void validate(String output, String [] expected, |
119 |
110 |
120 output = JPackageHelper.executeCLI(false, CMD_2); |
111 output = JPackageHelper.executeCLI(false, CMD_2); |
121 validate(output, RESULT_2, true); |
112 validate(output, RESULT_2, true); |
122 |
113 |
123 output = JPackageHelper.executeCLI(false, CMD_3); |
114 output = JPackageHelper.executeCLI(false, CMD_3); |
124 validate(output, RESULT_3, true); |
115 validate(output, RESULT_3, false); |
125 |
116 |
126 output = JPackageHelper.executeCLI(false, CMD_4); |
117 output = JPackageHelper.executeCLI(false, CMD_4); |
127 validate(output, RESULT_4, false); |
118 validate(output, RESULT_4, true); |
128 |
119 |
129 output = JPackageHelper.executeCLI(false, CMD_5); |
120 output = JPackageHelper.executeCLI(false, CMD_5); |
130 validate(output, RESULT_5, true); |
121 validate(output, RESULT_5, true); |
131 |
122 |
132 output = JPackageHelper.executeCLI(false, CMD_6); |
123 output = JPackageHelper.executeCLI(false, CMD_6); |
133 validate(output, RESULT_6, true); |
124 validate(output, RESULT_6, true); |
134 |
|
135 output = JPackageHelper.executeCLI(false, CMD_7); |
|
136 validate(output, RESULT_7, true); |
|
137 |
125 |
138 } |
126 } |
139 |
127 |
140 private static void testMissingArgToolProvider() throws Exception { |
128 private static void testMissingArgToolProvider() throws Exception { |
141 String output = JPackageHelper.executeToolProvider(false, CMD_1); |
129 String output = JPackageHelper.executeToolProvider(false, CMD_1); |
143 |
131 |
144 output = JPackageHelper.executeToolProvider(false, CMD_2); |
132 output = JPackageHelper.executeToolProvider(false, CMD_2); |
145 validate(output, RESULT_2, true); |
133 validate(output, RESULT_2, true); |
146 |
134 |
147 output = JPackageHelper.executeToolProvider(false, CMD_3); |
135 output = JPackageHelper.executeToolProvider(false, CMD_3); |
148 validate(output, RESULT_3, true); |
136 validate(output, RESULT_3, false); |
149 |
137 |
150 output = JPackageHelper.executeToolProvider(false, CMD_4); |
138 output = JPackageHelper.executeToolProvider(false, CMD_4); |
151 validate(output, RESULT_4, false); |
139 validate(output, RESULT_4, true); |
152 |
140 |
153 output = JPackageHelper.executeToolProvider(false, CMD_5); |
141 output = JPackageHelper.executeToolProvider(false, CMD_5); |
154 validate(output, RESULT_5, true); |
142 validate(output, RESULT_5, true); |
155 |
143 |
156 output = JPackageHelper.executeToolProvider(false, CMD_6); |
144 output = JPackageHelper.executeToolProvider(false, CMD_6); |
157 validate(output, RESULT_6, true); |
145 validate(output, RESULT_6, true); |
158 |
|
159 output = JPackageHelper.executeToolProvider(false, CMD_7); |
|
160 validate(output, RESULT_7, true); |
|
161 } |
146 } |
162 |
147 |
163 public static void main(String[] args) throws Exception { |
148 public static void main(String[] args) throws Exception { |
164 JPackageHelper.createHelloImageJar(); |
149 JPackageHelper.createHelloImageJar(); |
165 testMissingArg(); |
150 testMissingArg(); |