Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/share/InstallDirTest.java
41149 views
1
/*
2
* Copyright (c) 2018, 2020, 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 jdk.jpackage.test.TKit;
28
import jdk.jpackage.test.PackageTest;
29
import jdk.jpackage.test.PackageType;
30
import jdk.jpackage.test.Functional;
31
import jdk.jpackage.test.Annotations.Parameter;
32
33
/**
34
* Test --install-dir parameter. Output of the test should be
35
* commoninstalldirtest*.* package bundle. The output package should provide the
36
* same functionality as the default package but install test application in
37
* specified directory.
38
*
39
* Linux:
40
*
41
* Application should be installed in /opt/jpackage/commoninstalldirtest folder.
42
*
43
* Mac:
44
*
45
* Application should be installed in /Applications/jpackage/commoninstalldirtest.app
46
* folder.
47
*
48
* Windows:
49
*
50
* Application should be installed in %ProgramFiles%/TestVendor/InstallDirTest1234
51
* folder.
52
*/
53
54
/*
55
* @test
56
* @summary jpackage with --install-dir
57
* @library ../helpers
58
* @key jpackagePlatformPackage
59
* @build jdk.jpackage.test.*
60
* @compile InstallDirTest.java
61
* @modules jdk.jpackage/jdk.jpackage.internal
62
* @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main
63
* --jpt-run=InstallDirTest.testCommon
64
*/
65
66
/*
67
* @test
68
* @summary jpackage with --install-dir
69
* @library ../helpers
70
* @key jpackagePlatformPackage
71
* @build jdk.jpackage.test.*
72
* @compile InstallDirTest.java
73
* @modules jdk.jpackage/jdk.jpackage.internal
74
* @requires (os.family == "linux")
75
* @requires (jpackage.test.SQETest == null)
76
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
77
* --jpt-run=InstallDirTest.testLinuxInvalid
78
*/
79
public class InstallDirTest {
80
81
public static void testCommon() {
82
final Map<PackageType, Path> INSTALL_DIRS = Functional.identity(() -> {
83
Map<PackageType, Path> reply = new HashMap<>();
84
reply.put(PackageType.WIN_MSI, Path.of("TestVendor\\InstallDirTest1234"));
85
reply.put(PackageType.WIN_EXE, reply.get(PackageType.WIN_MSI));
86
87
reply.put(PackageType.LINUX_DEB, Path.of("/opt/jpackage"));
88
reply.put(PackageType.LINUX_RPM, reply.get(PackageType.LINUX_DEB));
89
90
reply.put(PackageType.MAC_PKG, Path.of("/Applications/jpackage"));
91
reply.put(PackageType.MAC_DMG, reply.get(PackageType.MAC_PKG));
92
93
return reply;
94
}).get();
95
96
new PackageTest().configureHelloApp()
97
.addInitializer(cmd -> {
98
cmd.addArguments("--install-dir", INSTALL_DIRS.get(
99
cmd.packageType()));
100
}).run();
101
}
102
103
@Parameter("/")
104
@Parameter(".")
105
@Parameter("foo")
106
@Parameter("/opt/foo/.././.")
107
public static void testLinuxInvalid(String installDir) {
108
testLinuxBad(installDir, "Invalid installation directory");
109
}
110
111
private static void testLinuxBad(String installDir,
112
String errorMessageSubstring) {
113
new PackageTest().configureHelloApp()
114
.setExpectedExitCode(1)
115
.forTypes(PackageType.LINUX)
116
.addInitializer(cmd -> {
117
cmd.addArguments("--install-dir", installDir);
118
cmd.saveConsoleOutput(true);
119
})
120
.addBundleVerifier((cmd, result) -> {
121
TKit.assertTextStream(errorMessageSubstring).apply(
122
result.getOutput().stream());
123
})
124
.run();
125
}
126
}
127
128