test/jdk/tools/jpackage/windows/base/RuntimeBase.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/JPackageCreateInstallerRuntimeBase.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:
57404
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     1
/*
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     4
 *
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     8
 *
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    13
 * accompanied this code).
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    14
 *
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    18
 *
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    21
 * questions.
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    22
 */
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    23
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    24
import java.io.File;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    25
import java.util.ArrayList;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    26
import java.util.List;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    27
57446
5a5b85f00a63 8226891: rename and re-layout jpackage tests.
herrick
parents: 57414
diff changeset
    28
public class RuntimeBase {
57404
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    29
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    30
    private static String TEST_NAME;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    31
    private static String EXT;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    32
    private static String OUTPUT;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    33
    private static String[] CMD;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    34
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    35
    private static void copyResults() throws Exception {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    36
        List<String> files = new ArrayList<>();
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    37
        files.add(OUTPUT);
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    38
        JPackageInstallerHelper.copyTestResults(files);
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    39
    }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    40
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    41
    private static void testCreateInstaller() throws Exception {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    42
        JPackageHelper.executeCLI(true, CMD);
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    43
        JPackageInstallerHelper.validateOutput(OUTPUT);
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    44
        copyResults();
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    45
    }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    46
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    47
    private static void verifyInstall() throws Exception {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    48
        // NOP by design.
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    49
    }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    50
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    51
    private static void verifyUnInstall() throws Exception {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    52
        String folderPath = JPackagePath.getWinInstallFolder(TEST_NAME);
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    53
        File folder = new File(folderPath);
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    54
        if (folder.exists()) {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    55
            throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist");
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    56
        }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    57
    }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    58
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    59
    private static void init(String name, String ext) {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    60
        TEST_NAME = name;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    61
        EXT = ext;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    62
        OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    63
        CMD = new String[]{
57414
6eda749d3117 8225428: CLI change to remove "mode", rename to "package", and build only one target
herrick
parents: 57404
diff changeset
    64
            "--package-type", EXT,
57404
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    65
            "--output", "output",
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    66
            "--name", TEST_NAME,
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    67
            "--runtime-image", System.getProperty("java.home")};
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    68
    }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    69
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    70
    public static void run(String name, String ext) throws Exception {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    71
        init(name, ext);
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    72
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    73
        if (JPackageInstallerHelper.isVerifyInstall()) {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    74
            verifyInstall();
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    75
        } else if (JPackageInstallerHelper.isVerifyUnInstall()) {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    76
            verifyUnInstall();
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    77
        } else {
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    78
            testCreateInstaller();
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    79
        }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    80
    }
a477b26bf888 8223643: Provide better defined context for custom installer steps on Windows
herrick
parents:
diff changeset
    81
}