test/jdk/tools/jpackage/share/InstallDirTest.java
branchJDK-8200758-branch
changeset 58301 e0efb29609bd
parent 58113 885b0543f6e4
child 58416 f09bf58c1f17
equal deleted inserted replaced
58172:bf06a1d3aef6 58301:e0efb29609bd
    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.PackageTest;
    29 import jdk.jpackage.test.PackageTest;
    29 import jdk.jpackage.test.PackageType;
    30 import jdk.jpackage.test.PackageType;
    30 
    31 
    31 /**
    32 /**
    32  * Test --install-dir parameter. Output of the test should be installdirtest*.*
    33  * Test --install-dir parameter. Output of the test should be installdirtest*.*
    55  * @modules jdk.jpackage/jdk.jpackage.internal
    56  * @modules jdk.jpackage/jdk.jpackage.internal
    56  * @run main/othervm/timeout=360 -Xmx512m InstallDirTest
    57  * @run main/othervm/timeout=360 -Xmx512m InstallDirTest
    57  */
    58  */
    58 public class InstallDirTest {
    59 public class InstallDirTest {
    59 
    60 
    60     public static void main(String[] args) throws Exception {
    61     public static void main(String[] args) {
    61         final Map<PackageType, String> INSTALL_DIRS = new Supplier<Map<PackageType, String>>() {
    62         final Map<PackageType, Path> INSTALL_DIRS = new Supplier<Map<PackageType, Path>>() {
    62             @Override
    63             @Override
    63             public Map<PackageType, String> get() {
    64             public Map<PackageType, Path> get() {
    64                 Map<PackageType, String> reply = new HashMap<>();
    65                 Map<PackageType, Path> reply = new HashMap<>();
    65                 reply.put(PackageType.WIN_MSI, Path.of("TestVendor",
    66                 reply.put(PackageType.WIN_MSI, Path.of(
    66                         "InstallDirTest1234").toString());
    67                         "TestVendor\\InstallDirTest1234"));
    67                 reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI));
    68                 reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI));
    68 
    69 
    69                 reply.put(PackageType.LINUX_DEB,
    70                 reply.put(PackageType.LINUX_DEB, Path.of("/opt/jpackage"));
    70                         Path.of("/opt", "jpackage").toString());
       
    71                 reply.put(PackageType.LINUX_RPM,
    71                 reply.put(PackageType.LINUX_RPM,
    72                         reply.get(PackageType.LINUX_DEB));
    72                         reply.get(PackageType.LINUX_DEB));
    73 
    73 
    74                 reply.put(PackageType.MAC_PKG, Path.of("/Application",
    74                 reply.put(PackageType.MAC_PKG, Path.of("/Application/jpackage"));
    75                         "jpackage").toString());
       
    76                 reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG));
    75                 reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG));
    77 
    76 
    78                 return reply;
    77                 return reply;
    79             }
    78             }
    80         }.get();
    79         }.get();
    81 
    80 
    82         new PackageTest().configureHelloApp()
    81         Test.run(args, () -> {
    83                 .addInitializer(cmd -> {
    82             new PackageTest().configureHelloApp()
    84                     cmd.addArguments("--install-dir", INSTALL_DIRS.get(
    83             .addInitializer(cmd -> {
    85                             cmd.packageType()));
    84                 cmd.addArguments("--install-dir", INSTALL_DIRS.get(
    86                 }).run();
    85                         cmd.packageType()));
       
    86             }).run();
       
    87         });
    87     }
    88     }
    88 }
    89 }