author | herrick |
Thu, 20 Jun 2019 14:13:50 -0400 | |
branch | JDK-8200758-branch |
changeset 57414 | 6eda749d3117 |
parent 57314 | 23da9e6f446f |
child 57419 | 44c2481650ce |
permissions | -rw-r--r-- |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57079
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
4 |
* |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
8 |
* |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
13 |
* accompanied this code). |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
14 |
* |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
18 |
* |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
21 |
* questions. |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
22 |
*/ |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
23 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
24 |
/* |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
25 |
* @test |
57039 | 26 |
* @summary jpackage create image missing arguments test |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
27 |
* @library helpers |
57039 | 28 |
* @build JPackageHelper |
29 |
* @build JPackagePath |
|
30 |
* @modules jdk.jpackage |
|
31 |
* @run main/othervm -Xmx512m JPackageMissingArgumentsTest |
|
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
32 |
*/ |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
33 |
|
57039 | 34 |
public class JPackageMissingArgumentsTest { |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
35 |
private static final String [] RESULT_1 = {"--output"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
36 |
private static final String [] CMD_1 = { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
37 |
"--input", "input", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
38 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
39 |
"--main-jar", "hello.jar", |
57150 | 40 |
"--main-class", "Hello", |
57307 | 41 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
42 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
43 |
private static final String [] RESULT_2 = {"--input"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
44 |
private static final String [] CMD_2 = { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
45 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
46 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
47 |
"--main-jar", "hello.jar", |
57150 | 48 |
"--main-class", "Hello", |
57307 | 49 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
50 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
51 |
private static final String [] RESULT_3 = {"--input", "--app-image"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
52 |
private static final String [] CMD_3 = { |
57414
6eda749d3117
8225428: CLI change to remove "mode", rename to "package", and build only one target
herrick
parents:
57314
diff
changeset
|
53 |
"--package-type", "invalid-package-type", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
54 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
55 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
56 |
"--main-jar", "hello.jar", |
57150 | 57 |
"--main-class", "Hello", |
57307 | 58 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
59 |
|
57314 | 60 |
private static final String [] RESULT_4 = {"main class was not specified"}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
61 |
private static final String [] CMD_4 = { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
62 |
"--input", "input", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
63 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
64 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
65 |
"--main-jar", "hello.jar", |
57307 | 66 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
67 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
68 |
private static final String [] RESULT_5 = {"--main-jar"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
69 |
private static final String [] CMD_5 = { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
70 |
"--input", "input", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
71 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
72 |
"--name", "test", |
57150 | 73 |
"--main-class", "Hello", |
57307 | 74 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
75 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
76 |
private static final String [] RESULT_6 = {"--module-path", "--runtime-image"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
77 |
private static final String [] CMD_6 = { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
78 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
79 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
80 |
"--module", "com.hello/com.hello.Hello", |
57307 | 81 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
82 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
83 |
private static final String [] RESULT_7 = {"--module-path", "--runtime-image", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
84 |
"--app-image"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
85 |
private static final String [] CMD_7 = { |
57414
6eda749d3117
8225428: CLI change to remove "mode", rename to "package", and build only one target
herrick
parents:
57314
diff
changeset
|
86 |
"--package-type", "invalid-package-type", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
87 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
88 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
89 |
"--module", "com.hello/com.hello.Hello", |
57307 | 90 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
91 |
|
57314 | 92 |
private static void validate(String output, String [] expected, |
93 |
boolean single) throws Exception { |
|
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
94 |
String[] result = output.split("\n"); |
57314 | 95 |
if (single && result.length != 1) { |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
96 |
System.err.println(output); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
97 |
throw new AssertionError("Invalid number of lines in output: " |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
98 |
+ result.length); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
99 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
100 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
101 |
for (String s : expected) { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
102 |
if (!result[0].contains(s)) { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
103 |
System.err.println("Expected to contain: " + s); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
104 |
System.err.println("Actual: " + result[0]); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
105 |
throw new AssertionError("Unexpected error message"); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
106 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
107 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
108 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
109 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
110 |
private static void testMissingArg() throws Exception { |
57039 | 111 |
String output = JPackageHelper.executeCLI(false, CMD_1); |
57314 | 112 |
validate(output, RESULT_1, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
113 |
|
57039 | 114 |
output = JPackageHelper.executeCLI(false, CMD_2); |
57314 | 115 |
validate(output, RESULT_2, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
116 |
|
57039 | 117 |
output = JPackageHelper.executeCLI(false, CMD_3); |
57314 | 118 |
validate(output, RESULT_3, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
119 |
|
57039 | 120 |
output = JPackageHelper.executeCLI(false, CMD_4); |
57314 | 121 |
validate(output, RESULT_4, false); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
122 |
|
57039 | 123 |
output = JPackageHelper.executeCLI(false, CMD_5); |
57314 | 124 |
validate(output, RESULT_5, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
125 |
|
57039 | 126 |
output = JPackageHelper.executeCLI(false, CMD_6); |
57314 | 127 |
validate(output, RESULT_6, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
128 |
|
57039 | 129 |
output = JPackageHelper.executeCLI(false, CMD_7); |
57314 | 130 |
validate(output, RESULT_7, true); |
57414
6eda749d3117
8225428: CLI change to remove "mode", rename to "package", and build only one target
herrick
parents:
57314
diff
changeset
|
131 |
|
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
132 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
133 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
134 |
private static void testMissingArgToolProvider() throws Exception { |
57039 | 135 |
String output = JPackageHelper.executeToolProvider(false, CMD_1); |
57314 | 136 |
validate(output, RESULT_1, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
137 |
|
57039 | 138 |
output = JPackageHelper.executeToolProvider(false, CMD_2); |
57314 | 139 |
validate(output, RESULT_2, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
140 |
|
57039 | 141 |
output = JPackageHelper.executeToolProvider(false, CMD_3); |
57314 | 142 |
validate(output, RESULT_3, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
143 |
|
57039 | 144 |
output = JPackageHelper.executeToolProvider(false, CMD_4); |
57314 | 145 |
validate(output, RESULT_4, false); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
146 |
|
57039 | 147 |
output = JPackageHelper.executeToolProvider(false, CMD_5); |
57314 | 148 |
validate(output, RESULT_5, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
149 |
|
57039 | 150 |
output = JPackageHelper.executeToolProvider(false, CMD_6); |
57314 | 151 |
validate(output, RESULT_6, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
152 |
|
57039 | 153 |
output = JPackageHelper.executeToolProvider(false, CMD_7); |
57314 | 154 |
validate(output, RESULT_7, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
155 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
156 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
157 |
public static void main(String[] args) throws Exception { |
57079
c53a2eca0f57
8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
57039
diff
changeset
|
158 |
JPackageHelper.createHelloImageJar(); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
159 |
testMissingArg(); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
160 |
testMissingArgToolProvider(); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
161 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
162 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
163 |
} |