test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerWinMenuGroupBase.java
author herrick
Tue, 12 Feb 2019 11:54:56 -0500
branchJDK-8200758-branch
changeset 57180 1d6f8a7c6d5a
parent 57150 fa68c2ab636d
child 57241 e11f3bf34083
permissions -rw-r--r--
8217687: jpackage --help improvements Reviewed-by: almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57079
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
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.
57079
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
     4
 *
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
     8
 *
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    13
 * accompanied this code).
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    14
 *
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    18
 *
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    21
 * questions.
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    22
 */
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    23
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    24
import java.io.File;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    25
import java.util.ArrayList;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    26
import java.util.List;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    27
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    28
public class JPackageCreateInstallerWinMenuGroupBase {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    29
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    30
    private static String TEST_NAME;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    31
    private static String EXT;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    32
    private static String OUTPUT;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    33
    private static String[] CMD;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    34
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    35
    private static void copyResults() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    36
        List<String> files = new ArrayList<>();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    37
        files.add(OUTPUT);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    38
        JPackageInstallerHelper.copyTestResults(files);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    39
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    40
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    41
    private static void testCreateInstaller() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    42
        JPackageHelper.executeCLI(true, CMD);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    43
        JPackageInstallerHelper.validateOutput(OUTPUT);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    44
        copyResults();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    45
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    46
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    47
    private static void verifyInstall() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    48
        String app = JPackagePath.getWinInstalledApp(TEST_NAME);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    49
        JPackageInstallerHelper.validateApp(app);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    50
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    51
        // Validate start menu
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    52
        JPackageInstallerHelper.validateStartMenu(TEST_NAME, TEST_NAME, true);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    53
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    54
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    55
    private static void verifyUnInstall() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    56
        String folderPath = JPackagePath.getWinInstallFolder(TEST_NAME);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    57
        File folder = new File(folderPath);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    58
        if (folder.exists()) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    59
            throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist");
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    60
        }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    61
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    62
        // Validate start menu
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    63
        JPackageInstallerHelper.validateStartMenu(TEST_NAME, TEST_NAME, false);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    64
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    65
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    66
    private static void init(String name, String ext) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    67
        TEST_NAME = name;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    68
        EXT = ext;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    69
        OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    70
        CMD = new String[]{
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    71
            "create-installer",
57180
1d6f8a7c6d5a 8217687: jpackage --help improvements
herrick
parents: 57150
diff changeset
    72
            "--installer-type", EXT,
57079
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    73
            "--input", "input",
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    74
            "--output", "output",
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    75
            "--name", TEST_NAME,
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    76
            "--main-jar", "hello.jar",
57150
fa68c2ab636d 8217894: jpackage CLI syntax changes
herrick
parents: 57106
diff changeset
    77
            "--main-class", "Hello",
fa68c2ab636d 8217894: jpackage CLI syntax changes
herrick
parents: 57106
diff changeset
    78
            "--overwrite",
57079
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    79
            "--files", "hello.jar",
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    80
            "--win-menu",
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    81
            "--win-menu-group", TEST_NAME};
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    82
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    83
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    84
    public static void run(String name, String ext) throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    85
        init(name, ext);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    86
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    87
        if (JPackageInstallerHelper.isVerifyInstall()) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    88
            verifyInstall();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    89
        } else if (JPackageInstallerHelper.isVerifyUnInstall()) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    90
            verifyUnInstall();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    91
        } else {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    92
            JPackageHelper.createHelloInstallerJar();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    93
            testCreateInstaller();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    94
        }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    95
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    96
}