test/jdk/tools/jpackage/share/InstallDirTest.java
branchJDK-8200758-branch
changeset 58416 f09bf58c1f17
parent 58301 e0efb29609bd
child 58434 b00cbf427368
equal deleted inserted replaced
58415:73f8e557549a 58416:f09bf58c1f17
    23 
    23 
    24 import java.nio.file.Path;
    24 import java.nio.file.Path;
    25 import java.util.HashMap;
    25 import java.util.HashMap;
    26 import java.util.Map;
    26 import java.util.Map;
    27 import java.util.function.Supplier;
    27 import java.util.function.Supplier;
    28 import jdk.jpackage.test.Test;
    28 import jdk.jpackage.test.TKit;
    29 import jdk.jpackage.test.PackageTest;
    29 import jdk.jpackage.test.PackageTest;
    30 import jdk.jpackage.test.PackageType;
    30 import jdk.jpackage.test.PackageType;
       
    31 import jdk.jpackage.test.Functional;
    31 
    32 
    32 /**
    33 /**
    33  * Test --install-dir parameter. Output of the test should be installdirtest*.*
    34  * Test --install-dir parameter. Output of the test should be installdirtest*.*
    34  * package bundle. The output package should provide the same functionality as
    35  * package bundle. The output package should provide the same functionality as
    35  * the default package but install test application in specified directory.
    36  * the default package but install test application in specified directory.
    51 
    52 
    52 /*
    53 /*
    53  * @test
    54  * @test
    54  * @summary jpackage with --install-dir
    55  * @summary jpackage with --install-dir
    55  * @library ../helpers
    56  * @library ../helpers
       
    57  * @build jdk.jpackage.test.*
    56  * @modules jdk.jpackage/jdk.jpackage.internal
    58  * @modules jdk.jpackage/jdk.jpackage.internal
    57  * @run main/othervm/timeout=360 -Xmx512m InstallDirTest
    59  * @run main/othervm/timeout=360 -Xmx512m InstallDirTest
    58  */
    60  */
    59 public class InstallDirTest {
    61 public class InstallDirTest {
    60 
    62 
    61     public static void main(String[] args) {
    63     public static void main(String[] args) {
    62         final Map<PackageType, Path> INSTALL_DIRS = new Supplier<Map<PackageType, Path>>() {
    64         final Map<PackageType, Path> INSTALL_DIRS = Functional.identity(() -> {
    63             @Override
    65             Map<PackageType, Path> reply = new HashMap<>();
    64             public Map<PackageType, Path> get() {
    66             reply.put(PackageType.WIN_MSI, Path.of("TestVendor\\InstallDirTest1234"));
    65                 Map<PackageType, Path> reply = new HashMap<>();
    67             reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI));
    66                 reply.put(PackageType.WIN_MSI, Path.of(
       
    67                         "TestVendor\\InstallDirTest1234"));
       
    68                 reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI));
       
    69 
    68 
    70                 reply.put(PackageType.LINUX_DEB, Path.of("/opt/jpackage"));
    69             reply.put(PackageType.LINUX_DEB, Path.of("/opt/jpackage"));
    71                 reply.put(PackageType.LINUX_RPM,
    70             reply.put(PackageType.LINUX_RPM, reply.get(PackageType.LINUX_DEB));
    72                         reply.get(PackageType.LINUX_DEB));
       
    73 
    71 
    74                 reply.put(PackageType.MAC_PKG, Path.of("/Application/jpackage"));
    72             reply.put(PackageType.MAC_PKG, Path.of("/Application/jpackage"));
    75                 reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG));
    73             reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG));
    76 
    74 
    77                 return reply;
    75             return reply;
    78             }
    76         }).get();
    79         }.get();
       
    80 
    77 
    81         Test.run(args, () -> {
    78         TKit.run(args, () -> {
    82             new PackageTest().configureHelloApp()
    79             new PackageTest().configureHelloApp()
    83             .addInitializer(cmd -> {
    80             .addInitializer(cmd -> {
    84                 cmd.addArguments("--install-dir", INSTALL_DIRS.get(
    81                 cmd.addArguments("--install-dir", INSTALL_DIRS.get(
    85                         cmd.packageType()));
    82                         cmd.packageType()));
    86             }).run();
    83             }).run();