8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.nio.file.Path; 25 import java.util.HashMap; 26 import java.util.Map; 27 import java.util.function.Supplier; 28 import jdk.jpackage.test.PackageTest; 29 import jdk.jpackage.test.PackageType; 30 31 /** 32 * Test --install-dir parameter. Output of the test should be installdirtest*.* 33 * package bundle. The output package should provide the same functionality as 34 * the default package but install test application in specified directory. 35 * 36 * Linux: 37 * 38 * Application should be installed in /opt/jpackage/installdirtest folder. 39 * 40 * Mac: 41 * 42 * Application should be installed in /Applications/jpackage/installdirtest.app 43 * folder. 44 * 45 * Windows: 46 * 47 * Application should be installed in %ProgramFiles%/TestVendor/InstallDirTest1234 48 * folder. 49 */ 50 51 /* 52 * @test 53 * @summary jpackage with --install-dir 54 * @library ../helpers 55 * @modules jdk.jpackage/jdk.jpackage.internal 56 * @run main/othervm/timeout=360 -Xmx512m InstallDirTest 57 */ 58 public class InstallDirTest { 59 60 public static void main(String[] args) throws Exception { 61 final Map<PackageType, String> INSTALL_DIRS = new Supplier<Map<PackageType, String>>() { 62 @Override 63 public Map<PackageType, String> get() { 64 Map<PackageType, String> reply = new HashMap<>(); 65 reply.put(PackageType.WIN_MSI, Path.of("TestVendor", 66 "InstallDirTest1234").toString()); 67 reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI)); 68 69 reply.put(PackageType.LINUX_DEB, 70 Path.of("/opt", "jpackage").toString()); 71 reply.put(PackageType.LINUX_RPM, 72 reply.get(PackageType.LINUX_DEB)); 73 74 reply.put(PackageType.MAC_PKG, Path.of("/Application", 75 "jpackage").toString()); 76 reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG)); 77 78 return reply; 79 } 80 }.get(); 81 82 new PackageTest().configureHelloApp() 83 .addInitializer(cmd -> { 84 cmd.addArguments("--install-dir", INSTALL_DIRS.get( 85 cmd.packageType())); 86 }).run(); 87 } 88 } | 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.nio.file.Path; 25 import java.util.HashMap; 26 import java.util.Map; 27 import java.util.function.Supplier; 28 import jdk.jpackage.test.Test; 29 import jdk.jpackage.test.PackageTest; 30 import jdk.jpackage.test.PackageType; 31 32 /** 33 * Test --install-dir parameter. Output of the test should be installdirtest*.* 34 * package bundle. The output package should provide the same functionality as 35 * the default package but install test application in specified directory. 36 * 37 * Linux: 38 * 39 * Application should be installed in /opt/jpackage/installdirtest folder. 40 * 41 * Mac: 42 * 43 * Application should be installed in /Applications/jpackage/installdirtest.app 44 * folder. 45 * 46 * Windows: 47 * 48 * Application should be installed in %ProgramFiles%/TestVendor/InstallDirTest1234 49 * folder. 50 */ 51 52 /* 53 * @test 54 * @summary jpackage with --install-dir 55 * @library ../helpers 56 * @modules jdk.jpackage/jdk.jpackage.internal 57 * @run main/othervm/timeout=360 -Xmx512m InstallDirTest 58 */ 59 public class InstallDirTest { 60 61 public static void main(String[] args) { 62 final Map<PackageType, Path> INSTALL_DIRS = new Supplier<Map<PackageType, Path>>() { 63 @Override 64 public Map<PackageType, Path> get() { 65 Map<PackageType, Path> reply = new HashMap<>(); 66 reply.put(PackageType.WIN_MSI, Path.of( 67 "TestVendor\\InstallDirTest1234")); 68 reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI)); 69 70 reply.put(PackageType.LINUX_DEB, Path.of("/opt/jpackage")); 71 reply.put(PackageType.LINUX_RPM, 72 reply.get(PackageType.LINUX_DEB)); 73 74 reply.put(PackageType.MAC_PKG, Path.of("/Application/jpackage")); 75 reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG)); 76 77 return reply; 78 } 79 }.get(); 80 81 Test.run(args, () -> { 82 new PackageTest().configureHelloApp() 83 .addInitializer(cmd -> { 84 cmd.addArguments("--install-dir", INSTALL_DIRS.get( 85 cmd.packageType())); 86 }).run(); 87 }); 88 } 89 } |