test/jdk/tools/jpackage/share/InstallDirTest.java
author herrick
Tue, 10 Sep 2019 09:18:19 -0400
branchJDK-8200758-branch
changeset 58113 885b0543f6e4
child 58301 e0efb29609bd
permissions -rw-r--r--
8230726: Improve jpackage jtreg tests Submitted-by: asemenyuk Reviewed-by: herrick, almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58113
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     1
/*
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     4
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     7
 * published by the Free Software Foundation.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     8
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    13
 * accompanied this code).
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    14
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    18
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    21
 * questions.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    22
 */
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    23
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    24
import java.nio.file.Path;
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    25
import java.util.HashMap;
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    26
import java.util.Map;
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    27
import java.util.function.Supplier;
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    28
import jdk.jpackage.test.PackageTest;
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    29
import jdk.jpackage.test.PackageType;
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    30
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    31
/**
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    32
 * Test --install-dir parameter. Output of the test should be installdirtest*.*
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    33
 * package bundle. The output package should provide the same functionality as
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    34
 * the default package but install test application in specified directory.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    35
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    36
 * Linux:
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    37
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    38
 * Application should be installed in /opt/jpackage/installdirtest folder.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    39
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    40
 * Mac:
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    41
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    42
 * Application should be installed in /Applications/jpackage/installdirtest.app
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    43
 * folder.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    44
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    45
 * Windows:
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    46
 *
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    47
 * Application should be installed in %ProgramFiles%/TestVendor/InstallDirTest1234
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    48
 * folder.
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    49
 */
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    50
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    51
/*
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    52
 * @test
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    53
 * @summary jpackage with --install-dir
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    54
 * @library ../helpers
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    55
 * @modules jdk.jpackage/jdk.jpackage.internal
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    56
 * @run main/othervm/timeout=360 -Xmx512m InstallDirTest
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    57
 */
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    58
public class InstallDirTest {
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    59
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    60
    public static void main(String[] args) throws Exception {
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    61
        final Map<PackageType, String> INSTALL_DIRS = new Supplier<Map<PackageType, String>>() {
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    62
            @Override
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    63
            public Map<PackageType, String> get() {
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    64
                Map<PackageType, String> reply = new HashMap<>();
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    65
                reply.put(PackageType.WIN_MSI, Path.of("TestVendor",
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    66
                        "InstallDirTest1234").toString());
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    67
                reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI));
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    68
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    69
                reply.put(PackageType.LINUX_DEB,
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    70
                        Path.of("/opt", "jpackage").toString());
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    71
                reply.put(PackageType.LINUX_RPM,
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    72
                        reply.get(PackageType.LINUX_DEB));
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    73
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    74
                reply.put(PackageType.MAC_PKG, Path.of("/Application",
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    75
                        "jpackage").toString());
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    76
                reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG));
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    77
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    78
                return reply;
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    79
            }
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    80
        }.get();
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    81
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    82
        new PackageTest().configureHelloApp()
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    83
                .addInitializer(cmd -> {
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    84
                    cmd.addArguments("--install-dir", INSTALL_DIRS.get(
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    85
                            cmd.packageType()));
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    86
                }).run();
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    87
    }
885b0543f6e4 8230726: Improve jpackage jtreg tests
herrick
parents:
diff changeset
    88
}