test/jdk/tools/jpackage/windows/base/WinDirChooserBase.java
author herrick
Mon, 01 Jul 2019 18:31:16 -0400
branchJDK-8200758-branch
changeset 57446 5a5b85f00a63
parent 57414 test/jdk/tools/jpackage/createinstaller/windows/base/JPackageCreateInstallerWinDirChooserBase.java@6eda749d3117
permissions -rw-r--r--
8226891: rename and re-layout jpackage tests. 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
57446
5a5b85f00a63 8226891: rename and re-layout jpackage tests.
herrick
parents: 57414
diff changeset
    28
public class WinDirChooserBase {
57079
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("Unknown", 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("Unknown", 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[]{
57414
6eda749d3117 8225428: CLI change to remove "mode", rename to "package", and build only one target
herrick
parents: 57307
diff changeset
    71
            "--package-type", EXT,
57079
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    72
            "--input", "input",
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    73
            "--output", "output",
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    74
            "--name", TEST_NAME,
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    75
            "--main-jar", "hello.jar",
57150
fa68c2ab636d 8217894: jpackage CLI syntax changes
herrick
parents: 57106
diff changeset
    76
            "--main-class", "Hello",
57079
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    77
            "--win-dir-chooser"};
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    78
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    79
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    80
    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
    81
        init(name, ext);
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
        if (JPackageInstallerHelper.isVerifyInstall()) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    84
            verifyInstall();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    85
        } else if (JPackageInstallerHelper.isVerifyUnInstall()) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    86
            verifyUnInstall();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    87
        } else {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    88
            JPackageHelper.createHelloInstallerJar();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    89
            testCreateInstaller();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    90
        }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    91
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    92
}