test/jdk/tools/jpackage/share/HelpTest.java
author herrick
Wed, 11 Sep 2019 13:26:36 -0400
branchJDK-8200758-branch
changeset 58115 4a27283b542d
parent 57446 5a5b85f00a63
permissions -rw-r--r--
/home/aherrick/comment
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     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
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     4
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     8
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    13
 * accompanied this code).
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    14
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    18
 *
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    21
 * questions.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    22
 */
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    23
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    24
 /*
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    25
 * @test
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
    26
 * @summary jpackage help test
57446
5a5b85f00a63 8226891: rename and re-layout jpackage tests.
herrick
parents: 57258
diff changeset
    27
 * @library ../helpers
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
    28
 * @build JPackageHelper
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
    29
 * @build JPackagePath
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
    30
 * @modules jdk.jpackage
57446
5a5b85f00a63 8226891: rename and re-layout jpackage tests.
herrick
parents: 57258
diff changeset
    31
 * @run main/othervm -Xmx512m HelpTest
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    32
 */
57446
5a5b85f00a63 8226891: rename and re-layout jpackage tests.
herrick
parents: 57258
diff changeset
    33
public class HelpTest {
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    34
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    35
    // Platform specific help messages.
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    36
    private static final String WINDOWS_HELP =
57258
ea75e8d7e34f 8220471: two test fixes missed in push.
herrick
parents: 57106
diff changeset
    37
            "--win-dir-chooser";
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    38
    private static final String OSX_HELP =
58115
4a27283b542d /home/aherrick/comment
herrick
parents: 57446
diff changeset
    39
            "--mac-package-identifier";
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    40
    private static final String LINUX_HELP =
58115
4a27283b542d /home/aherrick/comment
herrick
parents: 57446
diff changeset
    41
            "--linux-package-name";
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    42
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    43
    private static void validate(String output1, String output2)
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    44
            throws Exception {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    45
        if (output1.split("\n").length < 25) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    46
            throw new AssertionError("jpacakger --help failed");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    47
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    48
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    49
        if (output2.split("\n").length < 25) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    50
            throw new AssertionError("jpacakger -h failed");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    51
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    52
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    53
        // Make sure output matches for --help and -h
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    54
        if (!output1.equals(output2)) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    55
            System.err.println("================= --help =================");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    56
            System.err.println(output1);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    57
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    58
            System.err.println("=================== -h ===================");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    59
            System.err.println(output2);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    60
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    61
            throw new AssertionError(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    62
                    "jpacakger help text does not match between --help and -h");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    63
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    64
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
    65
        if (JPackageHelper.isWindows()) {
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    66
            if (!output1.contains(WINDOWS_HELP)) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    67
                throw new AssertionError(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    68
                  "jpacakger help text missing Windows specific help");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    69
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    70
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    71
            if (output1.contains(OSX_HELP) || output1.contains(LINUX_HELP)) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    72
                throw new AssertionError(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    73
                  "jpacakger help text contains other platforms specific help");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    74
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    75
            }
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
    76
        } else if (JPackageHelper.isOSX()) {
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    77
            if (!output1.contains(OSX_HELP)) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    78
                throw new AssertionError(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    79
                  "jpacakger help text missing OS X specific help");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    80
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    81
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    82
            if (output1.contains(WINDOWS_HELP) ||
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    83
                    output1.contains(LINUX_HELP)) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    84
                throw new AssertionError(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    85
                 "jpacakger help text contains other platforms specific help");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    86
            }
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
    87
        } else if (JPackageHelper.isLinux()) {
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    88
            if (!output1.contains(LINUX_HELP)) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    89
                throw new AssertionError(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    90
                  "jpacakger help text missing Linux specific help");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    91
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    92
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    93
            if (output1.contains(OSX_HELP) || output1.contains(WINDOWS_HELP)) {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    94
                throw new AssertionError(
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    95
                  "jpacakger help text contains other platforms specific help");
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    96
            }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    97
        }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    98
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
    99
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   100
    private static void testHelp() throws Exception {
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
   101
        String output1 = JPackageHelper.executeCLI(true, "--help");
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
   102
        String output2 = JPackageHelper.executeCLI(true, "-h");
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   103
        validate(output1, output2);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   104
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   105
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   106
    private static void testHelpToolProvider() throws Exception {
57039
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
   107
        String output1 = JPackageHelper.executeToolProvider(true, "--help");
98d3963b0b7b 8214051: rename jpackager tool to jpackage
herrick
parents: 57030
diff changeset
   108
        String output2 = JPackageHelper.executeToolProvider(true, "-h");
57023
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   109
        validate(output1, output2);
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   110
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   111
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   112
    public static void main(String[] args) throws Exception {
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   113
        testHelp();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   114
        testHelpToolProvider();
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   115
    }
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   116
8bf89434f0a5 8213332: Create minimal automated tests for jpackager
herrick
parents:
diff changeset
   117
}