author | herrick |
Wed, 06 Nov 2019 07:20:07 -0500 | |
branch | JDK-8200758-branch |
changeset 58993 | b5e1baa9d2c3 |
parent 58147 | 45a9084fe981 |
child 58994 | b09ba68c6a19 |
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 |
57446 | 27 |
* @library ../helpers |
57039 | 28 |
* @build JPackageHelper |
29 |
* @build JPackagePath |
|
30 |
* @modules jdk.jpackage |
|
57446 | 31 |
* @run main/othervm -Xmx512m MissingArgumentsTest |
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 |
|
57446 | 34 |
public class MissingArgumentsTest { |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
35 |
private static final String [] RESULT_1 = {"--input"}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
36 |
private static final String [] CMD_1 = { |
58993
b5e1baa9d2c3
8233592: change --package-type option name to --type and allow -t short form
herrick
parents:
58147
diff
changeset
|
37 |
"--type", "app-image", |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
38 |
"--dest", "output", |
57031
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 |
|
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
44 |
private static final String [] RESULT_2 = {"--input", "--app-image"}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
45 |
private static final String [] CMD_2 = { |
58993
b5e1baa9d2c3
8233592: change --package-type option name to --type and allow -t short form
herrick
parents:
58147
diff
changeset
|
46 |
"--type", "app-image", |
b5e1baa9d2c3
8233592: change --package-type option name to --type and allow -t short form
herrick
parents:
58147
diff
changeset
|
47 |
"--type", "invalid-type", |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
48 |
"--dest", "output", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
49 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
50 |
"--main-jar", "hello.jar", |
57150 | 51 |
"--main-class", "Hello", |
57307 | 52 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
53 |
|
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
54 |
private static final String [] RESULT_3 = {"main class was not specified"}; |
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
55 |
private static final String [] CMD_3 = { |
58993
b5e1baa9d2c3
8233592: change --package-type option name to --type and allow -t short form
herrick
parents:
58147
diff
changeset
|
56 |
"--type", "app-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
57 |
"--input", "input", |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
58 |
"--dest", "output", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
59 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
60 |
"--main-jar", "hello.jar", |
57307 | 61 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
62 |
|
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
63 |
private static final String [] RESULT_4 = {"--main-jar"}; |
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
64 |
private static final String [] CMD_4 = { |
58993
b5e1baa9d2c3
8233592: change --package-type option name to --type and allow -t short form
herrick
parents:
58147
diff
changeset
|
65 |
"--type", "app-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
66 |
"--input", "input", |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
67 |
"--dest", "output", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
68 |
"--name", "test", |
57150 | 69 |
"--main-class", "Hello", |
57307 | 70 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
71 |
|
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
72 |
private static final String [] RESULT_5 = {"--module-path", "--runtime-image"}; |
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
73 |
private static final String [] CMD_5 = { |
58993
b5e1baa9d2c3
8233592: change --package-type option name to --type and allow -t short form
herrick
parents:
58147
diff
changeset
|
74 |
"--type", "app-image", |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
75 |
"--dest", "output", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
76 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
77 |
"--module", "com.hello/com.hello.Hello", |
57307 | 78 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
79 |
|
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
80 |
private static final String [] RESULT_6 = {"--module-path", "--runtime-image", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
81 |
"--app-image"}; |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
82 |
private static final String [] CMD_6 = { |
58993
b5e1baa9d2c3
8233592: change --package-type option name to --type and allow -t short form
herrick
parents:
58147
diff
changeset
|
83 |
"--type", "invalid-type", |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
84 |
"--dest", "output", |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
85 |
"--name", "test", |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
86 |
"--module", "com.hello/com.hello.Hello", |
57307 | 87 |
}; |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
88 |
|
57314 | 89 |
private static void validate(String output, String [] expected, |
90 |
boolean single) throws Exception { |
|
57419
44c2481650ce
8225092: Several jpackage tests failes when run with jcov enabled
herrick
parents:
57414
diff
changeset
|
91 |
String[] result = JPackageHelper.splitAndFilter(output); |
57314 | 92 |
if (single && result.length != 1) { |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
93 |
System.err.println(output); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
94 |
throw new AssertionError("Invalid number of lines in output: " |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
95 |
+ result.length); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
96 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
97 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
98 |
for (String s : expected) { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
99 |
if (!result[0].contains(s)) { |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
100 |
System.err.println("Expected to contain: " + s); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
101 |
System.err.println("Actual: " + result[0]); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
102 |
throw new AssertionError("Unexpected error message"); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
103 |
} |
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 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
107 |
private static void testMissingArg() throws Exception { |
57039 | 108 |
String output = JPackageHelper.executeCLI(false, CMD_1); |
57314 | 109 |
validate(output, RESULT_1, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
110 |
|
57039 | 111 |
output = JPackageHelper.executeCLI(false, CMD_2); |
57314 | 112 |
validate(output, RESULT_2, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
113 |
|
57039 | 114 |
output = JPackageHelper.executeCLI(false, CMD_3); |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
115 |
validate(output, RESULT_3, false); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
116 |
|
57039 | 117 |
output = JPackageHelper.executeCLI(false, CMD_4); |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
118 |
validate(output, RESULT_4, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
119 |
|
57039 | 120 |
output = JPackageHelper.executeCLI(false, CMD_5); |
57314 | 121 |
validate(output, RESULT_5, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
122 |
|
57039 | 123 |
output = JPackageHelper.executeCLI(false, CMD_6); |
57314 | 124 |
validate(output, RESULT_6, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
125 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
126 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
127 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
128 |
private static void testMissingArgToolProvider() throws Exception { |
57039 | 129 |
String output = JPackageHelper.executeToolProvider(false, CMD_1); |
57314 | 130 |
validate(output, RESULT_1, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
131 |
|
57039 | 132 |
output = JPackageHelper.executeToolProvider(false, CMD_2); |
57314 | 133 |
validate(output, RESULT_2, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
134 |
|
57039 | 135 |
output = JPackageHelper.executeToolProvider(false, CMD_3); |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
136 |
validate(output, RESULT_3, false); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
137 |
|
57039 | 138 |
output = JPackageHelper.executeToolProvider(false, CMD_4); |
58147
45a9084fe981
8230521: rename --output/-o option and add default value (".")
herrick
parents:
58114
diff
changeset
|
139 |
validate(output, RESULT_4, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
140 |
|
57039 | 141 |
output = JPackageHelper.executeToolProvider(false, CMD_5); |
57314 | 142 |
validate(output, RESULT_5, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
143 |
|
57039 | 144 |
output = JPackageHelper.executeToolProvider(false, CMD_6); |
57314 | 145 |
validate(output, RESULT_6, true); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
146 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
147 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
148 |
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
|
149 |
JPackageHelper.createHelloImageJar(); |
57031
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
150 |
testMissingArg(); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
151 |
testMissingArgToolProvider(); |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
152 |
} |
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
153 |
|
ea4755429ed8
8214021: Create additional automated tests for jpackager
herrick
parents:
diff
changeset
|
154 |
} |