author | herrick |
Wed, 11 Sep 2019 13:26:36 -0400 | |
branch | JDK-8200758-branch |
changeset 58115 | 4a27283b542d |
parent 57446 | 5a5b85f00a63 |
permissions | -rw-r--r-- |
57023 | 1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57039
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
57023 | 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 |
|
57039 | 26 |
* @summary jpackage help test |
57446 | 27 |
* @library ../helpers |
57039 | 28 |
* @build JPackageHelper |
29 |
* @build JPackagePath |
|
30 |
* @modules jdk.jpackage |
|
57446 | 31 |
* @run main/othervm -Xmx512m HelpTest |
57023 | 32 |
*/ |
57446 | 33 |
public class HelpTest { |
57023 | 34 |
|
35 |
// Platform specific help messages. |
|
36 |
private static final String WINDOWS_HELP = |
|
57258 | 37 |
"--win-dir-chooser"; |
57023 | 38 |
private static final String OSX_HELP = |
58115 | 39 |
"--mac-package-identifier"; |
57023 | 40 |
private static final String LINUX_HELP = |
58115 | 41 |
"--linux-package-name"; |
57023 | 42 |
|
43 |
private static void validate(String output1, String output2) |
|
44 |
throws Exception { |
|
45 |
if (output1.split("\n").length < 25) { |
|
46 |
throw new AssertionError("jpacakger --help failed"); |
|
47 |
} |
|
48 |
||
49 |
if (output2.split("\n").length < 25) { |
|
50 |
throw new AssertionError("jpacakger -h failed"); |
|
51 |
} |
|
52 |
||
53 |
// Make sure output matches for --help and -h |
|
54 |
if (!output1.equals(output2)) { |
|
55 |
System.err.println("================= --help ================="); |
|
56 |
System.err.println(output1); |
|
57 |
||
58 |
System.err.println("=================== -h ==================="); |
|
59 |
System.err.println(output2); |
|
60 |
||
61 |
throw new AssertionError( |
|
62 |
"jpacakger help text does not match between --help and -h"); |
|
63 |
} |
|
64 |
||
57039 | 65 |
if (JPackageHelper.isWindows()) { |
57023 | 66 |
if (!output1.contains(WINDOWS_HELP)) { |
67 |
throw new AssertionError( |
|
68 |
"jpacakger help text missing Windows specific help"); |
|
69 |
} |
|
70 |
||
71 |
if (output1.contains(OSX_HELP) || output1.contains(LINUX_HELP)) { |
|
72 |
throw new AssertionError( |
|
73 |
"jpacakger help text contains other platforms specific help"); |
|
74 |
||
75 |
} |
|
57039 | 76 |
} else if (JPackageHelper.isOSX()) { |
57023 | 77 |
if (!output1.contains(OSX_HELP)) { |
78 |
throw new AssertionError( |
|
79 |
"jpacakger help text missing OS X specific help"); |
|
80 |
} |
|
81 |
||
82 |
if (output1.contains(WINDOWS_HELP) || |
|
83 |
output1.contains(LINUX_HELP)) { |
|
84 |
throw new AssertionError( |
|
85 |
"jpacakger help text contains other platforms specific help"); |
|
86 |
} |
|
57039 | 87 |
} else if (JPackageHelper.isLinux()) { |
57023 | 88 |
if (!output1.contains(LINUX_HELP)) { |
89 |
throw new AssertionError( |
|
90 |
"jpacakger help text missing Linux specific help"); |
|
91 |
} |
|
92 |
||
93 |
if (output1.contains(OSX_HELP) || output1.contains(WINDOWS_HELP)) { |
|
94 |
throw new AssertionError( |
|
95 |
"jpacakger help text contains other platforms specific help"); |
|
96 |
} |
|
97 |
} |
|
98 |
} |
|
99 |
||
100 |
private static void testHelp() throws Exception { |
|
57039 | 101 |
String output1 = JPackageHelper.executeCLI(true, "--help"); |
102 |
String output2 = JPackageHelper.executeCLI(true, "-h"); |
|
57023 | 103 |
validate(output1, output2); |
104 |
} |
|
105 |
||
106 |
private static void testHelpToolProvider() throws Exception { |
|
57039 | 107 |
String output1 = JPackageHelper.executeToolProvider(true, "--help"); |
108 |
String output2 = JPackageHelper.executeToolProvider(true, "-h"); |
|
57023 | 109 |
validate(output1, output2); |
110 |
} |
|
111 |
||
112 |
public static void main(String[] args) throws Exception { |
|
113 |
testHelp(); |
|
114 |
testHelpToolProvider(); |
|
115 |
} |
|
116 |
||
117 |
} |