58113
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
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 |
}
|