Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/windows/WinResourceTest.java
41149 views
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.io.IOException;
25
import java.nio.file.Path;
26
import jdk.jpackage.test.TKit;
27
import jdk.jpackage.test.PackageTest;
28
import jdk.jpackage.test.PackageType;
29
import jdk.jpackage.test.JPackageCommand;
30
import jdk.jpackage.test.Annotations.Test;
31
import jdk.jpackage.test.Annotations.Parameters;
32
import java.util.List;
33
34
/**
35
* Test --resource-dir option. The test should set --resource-dir to point to
36
* a dir with an empty "main.wxs" file. As a result, jpackage should try to
37
* use the customized resource and fail.
38
*/
39
40
/*
41
* @test
42
* @summary jpackage with --resource-dir
43
* @library ../helpers
44
* @build jdk.jpackage.test.*
45
* @requires (os.family == "windows")
46
* @modules jdk.jpackage/jdk.jpackage.internal
47
* @compile WinResourceTest.java
48
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
49
* --jpt-run=WinResourceTest
50
*/
51
52
public class WinResourceTest {
53
54
public WinResourceTest(String wixSource, String expectedLogMessage) {
55
this.wixSource = wixSource;
56
this.expectedLogMessage = expectedLogMessage;
57
}
58
59
@Parameters
60
public static List<Object[]> data() {
61
return List.of(new Object[][]{
62
{"main.wxs", "Using custom package resource [Main WiX project file]"},
63
{"overrides.wxi", "Using custom package resource [Overrides WiX project file]"},
64
});
65
}
66
67
@Test
68
public void test() throws IOException {
69
new PackageTest()
70
.forTypes(PackageType.WINDOWS)
71
.configureHelloApp()
72
.addInitializer(cmd -> {
73
Path resourceDir = TKit.createTempDirectory("resources");
74
75
// 1. Set fake run time to save time by skipping jlink step of jpackage.
76
// 2. Instruct test to save jpackage output.
77
cmd.setFakeRuntime().saveConsoleOutput(true);
78
79
cmd.addArguments("--resource-dir", resourceDir);
80
// Create invalid WiX source file in a resource dir.
81
TKit.createTextFile(resourceDir.resolve(wixSource), List.of(
82
"any string that is an invalid WiX source file"));
83
})
84
.addBundleVerifier((cmd, result) -> {
85
// Assert jpackage picked custom main.wxs and failed as expected by
86
// examining its output
87
TKit.assertTextStream(expectedLogMessage)
88
.predicate(String::startsWith)
89
.apply(JPackageCommand.stripTimestamps(
90
result.getOutput().stream()));
91
TKit.assertTextStream("error CNDL0104 : Not a valid source file")
92
.apply(result.getOutput().stream());
93
})
94
.setExpectedExitCode(1)
95
.run();
96
}
97
98
final String wixSource;
99
final String expectedLogMessage;
100
}
101
102