Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/macosx/HostArchPkgTest.java
41152 views
1
/*
2
* Copyright (c) 2021, 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 javax.xml.parsers.DocumentBuilder;
27
import javax.xml.parsers.DocumentBuilderFactory;
28
import javax.xml.xpath.XPath;
29
import javax.xml.xpath.XPathConstants;
30
import javax.xml.xpath.XPathFactory;
31
import jdk.jpackage.test.JPackageCommand;
32
import jdk.jpackage.test.PackageTest;
33
import jdk.jpackage.test.PackageType;
34
import jdk.jpackage.test.TKit;
35
import jdk.jpackage.test.Annotations.Test;
36
37
/**
38
* Test will generation default pkg package and will validate "hostArchitectures"
39
* attribute in unpacked pkg package inside Distribution file. See JDK-8266179.
40
*/
41
42
/*
43
* @test
44
* @summary jpackage test to validate "hostArchitectures" attribute
45
* @library ../helpers
46
* @build jdk.jpackage.test.*
47
* @modules jdk.jpackage/jdk.jpackage.internal
48
* @compile HostArchPkgTest.java
49
* @requires (os.family == "mac")
50
* @key jpackagePlatformPackage
51
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
52
* --jpt-run=HostArchPkgTest
53
*/
54
public class HostArchPkgTest {
55
56
private static void verifyHostArch(JPackageCommand cmd) throws Exception {
57
Path distributionFile = cmd.pathToUnpackedPackageFile(Path.of("/"))
58
.toAbsolutePath()
59
.getParent()
60
.resolve("data")
61
.resolve("Distribution");
62
63
DocumentBuilderFactory dbf
64
= DocumentBuilderFactory.newDefaultInstance();
65
dbf.setFeature("http://apache.org/xml/features/" +
66
"nonvalidating/load-external-dtd", false);
67
DocumentBuilder b = dbf.newDocumentBuilder();
68
org.w3c.dom.Document doc
69
= b.parse(Files.newInputStream(distributionFile));
70
71
XPath xPath = XPathFactory.newInstance().newXPath();
72
73
String v = (String) xPath.evaluate(
74
"/installer-gui-script/options/@hostArchitectures",
75
doc, XPathConstants.STRING);
76
77
if ("aarch64".equals(System.getProperty("os.arch"))) {
78
TKit.assertEquals(v, "arm64",
79
"Check value of \"hostArchitectures\" attribute");
80
} else {
81
TKit.assertEquals(v, "x86_64",
82
"Check value of \"hostArchitectures\" attribute");
83
}
84
}
85
86
@Test
87
public static void test() {
88
new PackageTest()
89
.forTypes(PackageType.MAC_PKG)
90
.configureHelloApp()
91
.addInstallVerifier(HostArchPkgTest::verifyHostArch)
92
.run(PackageTest.Action.CREATE_AND_UNPACK);
93
}
94
}
95
96