author | herrick |
Tue, 09 Apr 2019 10:57:04 -0400 | |
branch | JDK-8200758-branch |
changeset 57314 | 23da9e6f446f |
parent 57307 | 4948a1944cf9 |
child 57414 | 6eda749d3117 |
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 = { |
57307 | 37 |
"create-app-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
38 |
"--input", "input", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
39 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
40 |
"--main-jar", "hello.jar", |
57150 | 41 |
"--main-class", "Hello", |
57307 | 42 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
43 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
44 |
private static final String [] RESULT_2 = {"--input"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
45 |
private static final String [] CMD_2 = { |
57307 | 46 |
"create-app-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
47 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
48 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
49 |
"--main-jar", "hello.jar", |
57150 | 50 |
"--main-class", "Hello", |
57307 | 51 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
52 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
53 |
private static final String [] RESULT_3 = {"--input", "--app-image"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
54 |
private static final String [] CMD_3 = { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
55 |
"create-installer", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
56 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
57 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
58 |
"--main-jar", "hello.jar", |
57150 | 59 |
"--main-class", "Hello", |
57307 | 60 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
61 |
|
57314 | 62 |
private static final String [] RESULT_4 = {"main class was not specified"}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
63 |
private static final String [] CMD_4 = { |
57307 | 64 |
"create-app-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
65 |
"--input", "input", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
66 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
67 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
68 |
"--main-jar", "hello.jar", |
57307 | 69 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
70 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
71 |
private static final String [] RESULT_5 = {"--main-jar"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
72 |
private static final String [] CMD_5 = { |
57307 | 73 |
"create-app-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
74 |
"--input", "input", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
75 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
76 |
"--name", "test", |
57150 | 77 |
"--main-class", "Hello", |
57307 | 78 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
79 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
80 |
private static final String [] RESULT_6 = {"--module-path", "--runtime-image"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
81 |
private static final String [] CMD_6 = { |
57307 | 82 |
"create-app-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
83 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
84 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
85 |
"--module", "com.hello/com.hello.Hello", |
57307 | 86 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
87 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
88 |
private static final String [] RESULT_7 = {"--module-path", "--runtime-image", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
89 |
"--app-image"}; |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
90 |
private static final String [] CMD_7 = { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
91 |
"create-installer", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
92 |
"--output", "output", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
93 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
94 |
"--module", "com.hello/com.hello.Hello", |
57307 | 95 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
96 |
|
57314 | 97 |
private static void validate(String output, String [] expected, |
98 |
boolean single) throws Exception { |
|
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
99 |
String[] result = output.split("\n"); |
57314 | 100 |
if (single && result.length != 1) { |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
101 |
System.err.println(output); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
102 |
throw new AssertionError("Invalid number of lines in output: " |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
103 |
+ result.length); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
104 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
105 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
106 |
for (String s : expected) { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
107 |
if (!result[0].contains(s)) { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
108 |
System.err.println("Expected to contain: " + s); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
109 |
System.err.println("Actual: " + result[0]); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
110 |
throw new AssertionError("Unexpected error message"); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
111 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
112 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
113 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
114 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
115 |
private static void testMissingArg() throws Exception { |
57039 | 116 |
String output = JPackageHelper.executeCLI(false, CMD_1); |
57314 | 117 |
validate(output, RESULT_1, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
118 |
|
57039 | 119 |
output = JPackageHelper.executeCLI(false, CMD_2); |
57314 | 120 |
validate(output, RESULT_2, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
121 |
|
57039 | 122 |
output = JPackageHelper.executeCLI(false, CMD_3); |
57314 | 123 |
validate(output, RESULT_3, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
124 |
|
57039 | 125 |
output = JPackageHelper.executeCLI(false, CMD_4); |
57314 | 126 |
validate(output, RESULT_4, false); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
127 |
|
57039 | 128 |
output = JPackageHelper.executeCLI(false, CMD_5); |
57314 | 129 |
validate(output, RESULT_5, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
130 |
|
57039 | 131 |
output = JPackageHelper.executeCLI(false, CMD_6); |
57314 | 132 |
validate(output, RESULT_6, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
133 |
|
57039 | 134 |
output = JPackageHelper.executeCLI(false, CMD_7); |
57314 | 135 |
validate(output, RESULT_7, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
136 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
137 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
138 |
private static void testMissingArgToolProvider() throws Exception { |
57039 | 139 |
String output = JPackageHelper.executeToolProvider(false, CMD_1); |
57314 | 140 |
validate(output, RESULT_1, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
141 |
|
57039 | 142 |
output = JPackageHelper.executeToolProvider(false, CMD_2); |
57314 | 143 |
validate(output, RESULT_2, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
144 |
|
57039 | 145 |
output = JPackageHelper.executeToolProvider(false, CMD_3); |
57314 | 146 |
validate(output, RESULT_3, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
147 |
|
57039 | 148 |
output = JPackageHelper.executeToolProvider(false, CMD_4); |
57314 | 149 |
validate(output, RESULT_4, false); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
150 |
|
57039 | 151 |
output = JPackageHelper.executeToolProvider(false, CMD_5); |
57314 | 152 |
validate(output, RESULT_5, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
153 |
|
57039 | 154 |
output = JPackageHelper.executeToolProvider(false, CMD_6); |
57314 | 155 |
validate(output, RESULT_6, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
156 |
|
57039 | 157 |
output = JPackageHelper.executeToolProvider(false, CMD_7); |
57314 | 158 |
validate(output, RESULT_7, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
159 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
160 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
161 |
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
|
162 |
JPackageHelper.createHelloImageJar(); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
163 |
testMissingArg(); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
164 |
testMissingArgToolProvider(); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
165 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
166 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
167 |
} |