test/jdk/tools/jpackage/linux/base/BundleNameBase.java
author herrick
Mon, 01 Jul 2019 18:31:16 -0400
branchJDK-8200758-branch
changeset 57446 5a5b85f00a63
parent 57438 test/jdk/tools/jpackage/createinstaller/linux/base/JPLinuxBundleNameBase.java@4a31db8d42bd
child 57543 bcd1ab268a7d
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: 57438
diff changeset
    28
public class BundleNameBase {
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 BUNDLE_NAME;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    32
    private static String EXT;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    33
    private static String OUTPUT;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    34
    private static String[] CMD;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    35
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    36
    private static void copyResults() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    37
        List<String> files = new ArrayList<>();
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    38
        files.add(OUTPUT.toLowerCase());
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    39
        JPackageInstallerHelper.copyTestResults(files);
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
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    42
    private static void testCreateInstaller() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    43
        JPackageHelper.executeCLI(true, CMD);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    44
        JPackageInstallerHelper.validateOutput(OUTPUT);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    45
        copyResults();
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
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    48
    private static void verifyInstall() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    49
        String app = JPackagePath.getLinuxInstalledApp(TEST_NAME);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    50
        JPackageInstallerHelper.validateApp(app);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    51
    }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    52
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    53
    private static void verifyUnInstall() throws Exception {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    54
        String folderPath = JPackagePath.getLinuxInstallFolder(TEST_NAME);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    55
        File folder = new File(folderPath);
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    56
        if (folder.exists()) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    57
            throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist");
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    58
        }
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    59
    }
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
    private static void init(String name, String ext) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    62
        TEST_NAME = name;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    63
        BUNDLE_NAME = "jpackage-test-bundle-name";
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    64
        EXT = ext;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    65
        if (EXT.equals("rpm")) {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    66
            OUTPUT = "output" + File.separator + BUNDLE_NAME + "-1.0-1.x86_64." + EXT;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    67
        } else {
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    68
            OUTPUT = "output" + File.separator + BUNDLE_NAME + "-1.0." + EXT;
c53a2eca0f57 8215036: Create initial set of tests for jpackage create-installer mode
herrick
parents:
diff changeset
    69
        }
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
            "--linux-bundle-name", BUNDLE_NAME};
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
}