Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/jdk/tools/jpackage/macosx/MacAppStoreRuntimeTest.java
66644 views
1
/*
2
* Copyright (c) 2022, 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.Files;
25
import java.nio.file.Path;
26
import java.io.IOException;
27
import java.util.ArrayList;
28
import java.util.List;
29
30
import jdk.jpackage.test.JPackageCommand;
31
import jdk.jpackage.test.Executor;
32
import jdk.jpackage.test.TKit;
33
import jdk.jpackage.test.JavaTool;
34
import jdk.jpackage.test.Annotations.Test;
35
import jdk.jpackage.test.Annotations.Parameter;
36
37
38
/**
39
* Tests generation of app image with --mac-app-store and --runtime-image. jpackage should able
40
* to generate app image if runtime image does not have "bin" folder and fail otherwise.
41
*/
42
43
/*
44
* @test
45
* @summary jpackage with --mac-app-store and --runtime-image
46
* @library ../helpers
47
* @library /test/lib
48
* @build jdk.jpackage.test.*
49
* @build MacAppStoreRuntimeTest
50
* @modules jdk.jpackage/jdk.jpackage.internal
51
* @requires (os.family == "mac")
52
* @run main/othervm -Xmx512m jdk.jpackage.test.Main
53
* --jpt-run=MacAppStoreRuntimeTest
54
*/
55
public class MacAppStoreRuntimeTest {
56
57
private static String getRuntimeImage(boolean stripNativeCommands) throws IOException {
58
final Path workDir = TKit.createTempDirectory("runtime").resolve("data");
59
final Path jlinkOutputDir = workDir.resolve("temp.runtime");
60
Files.createDirectories(jlinkOutputDir.getParent());
61
62
// List of modules required for test app.
63
final var modules = new String[] {
64
"java.base",
65
"java.desktop"
66
};
67
68
List<String> jlinkArgs = new ArrayList<>();
69
jlinkArgs.add("--output");
70
jlinkArgs.add(jlinkOutputDir.toString());
71
jlinkArgs.add("--add-modules");
72
jlinkArgs.add(String.join(",", modules));
73
jlinkArgs.add("--strip-debug");
74
jlinkArgs.add("--no-header-files");
75
jlinkArgs.add("--no-man-pages");
76
if (stripNativeCommands) {
77
jlinkArgs.add("--strip-native-commands");
78
}
79
80
new Executor()
81
.setToolProvider(JavaTool.JLINK)
82
.dumpOutput()
83
.addArguments(jlinkArgs)
84
.execute();
85
86
return jlinkOutputDir.toString();
87
}
88
89
@Test
90
@Parameter("true")
91
@Parameter("false")
92
public static void test(boolean stripNativeCommands) throws Exception {
93
JPackageCommand cmd = JPackageCommand.helloAppImage();
94
cmd.addArguments("--mac-app-store", "--runtime-image", getRuntimeImage(stripNativeCommands));
95
96
if (stripNativeCommands) {
97
cmd.executeAndAssertHelloAppImageCreated();
98
} else {
99
cmd.execute(1);
100
}
101
}
102
}
103
104