57023
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
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 jpackager help test
|
|
27 |
* @build JPackagerHelper
|
|
28 |
* @modules jdk.jpackager
|
|
29 |
* @run main/othervm -Xmx512m JPackagerHelpTest
|
|
30 |
*/
|
|
31 |
public class JPackagerHelpTest {
|
|
32 |
|
|
33 |
// Platform specific help messages.
|
|
34 |
private static final String WINDOWS_HELP =
|
|
35 |
"The following options are valid for Windows platforms";
|
|
36 |
private static final String OSX_HELP =
|
|
37 |
"The following options are valid for Mac OS X platforms";
|
|
38 |
private static final String LINUX_HELP =
|
|
39 |
"The following options are valid for Linux platforms";
|
|
40 |
|
|
41 |
private static void validate(String output1, String output2)
|
|
42 |
throws Exception {
|
|
43 |
if (output1.split("\n").length < 25) {
|
|
44 |
throw new AssertionError("jpacakger --help failed");
|
|
45 |
}
|
|
46 |
|
|
47 |
if (output2.split("\n").length < 25) {
|
|
48 |
throw new AssertionError("jpacakger -h failed");
|
|
49 |
}
|
|
50 |
|
|
51 |
// Make sure output matches for --help and -h
|
|
52 |
if (!output1.equals(output2)) {
|
|
53 |
System.err.println("================= --help =================");
|
|
54 |
System.err.println(output1);
|
|
55 |
|
|
56 |
System.err.println("=================== -h ===================");
|
|
57 |
System.err.println(output2);
|
|
58 |
|
|
59 |
throw new AssertionError(
|
|
60 |
"jpacakger help text does not match between --help and -h");
|
|
61 |
}
|
|
62 |
|
|
63 |
if (JPackagerHelper.isWindows()) {
|
|
64 |
if (!output1.contains(WINDOWS_HELP)) {
|
|
65 |
throw new AssertionError(
|
|
66 |
"jpacakger help text missing Windows specific help");
|
|
67 |
}
|
|
68 |
|
|
69 |
if (output1.contains(OSX_HELP) || output1.contains(LINUX_HELP)) {
|
|
70 |
throw new AssertionError(
|
|
71 |
"jpacakger help text contains other platforms specific help");
|
|
72 |
|
|
73 |
}
|
|
74 |
} else if (JPackagerHelper.isOSX()) {
|
|
75 |
if (!output1.contains(OSX_HELP)) {
|
|
76 |
throw new AssertionError(
|
|
77 |
"jpacakger help text missing OS X specific help");
|
|
78 |
}
|
|
79 |
|
|
80 |
if (output1.contains(WINDOWS_HELP) ||
|
|
81 |
output1.contains(LINUX_HELP)) {
|
|
82 |
throw new AssertionError(
|
|
83 |
"jpacakger help text contains other platforms specific help");
|
|
84 |
}
|
|
85 |
} else if (JPackagerHelper.isLinux()) {
|
|
86 |
if (!output1.contains(LINUX_HELP)) {
|
|
87 |
throw new AssertionError(
|
|
88 |
"jpacakger help text missing Linux specific help");
|
|
89 |
}
|
|
90 |
|
|
91 |
if (output1.contains(OSX_HELP) || output1.contains(WINDOWS_HELP)) {
|
|
92 |
throw new AssertionError(
|
|
93 |
"jpacakger help text contains other platforms specific help");
|
|
94 |
}
|
|
95 |
}
|
|
96 |
}
|
|
97 |
|
|
98 |
private static void testHelp() throws Exception {
|
|
99 |
String output1 = JPackagerHelper.executeCLI(true, "--help");
|
|
100 |
String output2 = JPackagerHelper.executeCLI(true, "-h");
|
|
101 |
validate(output1, output2);
|
|
102 |
}
|
|
103 |
|
|
104 |
private static void testHelpToolProvider() throws Exception {
|
|
105 |
String output1 = JPackagerHelper.executeToolProvider(true, "--help");
|
|
106 |
String output2 = JPackagerHelper.executeToolProvider(true, "-h");
|
|
107 |
validate(output1, output2);
|
|
108 |
}
|
|
109 |
|
|
110 |
public static void main(String[] args) throws Exception {
|
|
111 |
testHelp();
|
|
112 |
testHelpToolProvider();
|
|
113 |
}
|
|
114 |
|
|
115 |
}
|