Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/jdk/tools/jpackage/windows/Win8282351Test.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.io.IOException;
25
import java.nio.file.Files;
26
import java.nio.file.Path;
27
import jdk.jpackage.test.PackageTest;
28
import jdk.jpackage.test.JPackageCommand;
29
import jdk.jpackage.test.Annotations.Test;
30
import jdk.jpackage.test.PackageType;
31
import jdk.jpackage.test.RunnablePackageTest.Action;
32
import jdk.jpackage.test.TKit;
33
34
/**
35
* Test packaging of files with paths containing multiple dollar ($$, $$$)
36
* character sequences.
37
*/
38
39
/*
40
* @test
41
* @summary Test case for JDK-8248254
42
* @library ../helpers
43
* @build jdk.jpackage.test.*
44
* @build Win8282351Test
45
* @requires (os.family == "windows")
46
* @modules jdk.jpackage/jdk.jpackage.internal
47
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
48
* --jpt-run=Win8282351Test
49
*/
50
public class Win8282351Test {
51
52
@Test
53
public void test() throws IOException {
54
Path appimageOutput = TKit.createTempDirectory("appimage");
55
56
JPackageCommand appImageCmd = JPackageCommand.helloAppImage()
57
.setFakeRuntime().setArgumentValue("--dest", appimageOutput);
58
59
String[] filesWithDollarCharsInNames = new String[]{
60
"Pane$$anon$$greater$1.class",
61
"$",
62
"$$",
63
"$$$",
64
"$$$$",
65
"$$$$$",
66
"foo$.class",
67
"1$b$$a$$$r$$$$.class"
68
};
69
70
String[] dirsWithDollarCharsInNames = new String[]{
71
Path.of("foo", String.join("/", filesWithDollarCharsInNames)).toString()
72
};
73
74
String name = appImageCmd.name() + "$-$$-$$$";
75
76
new PackageTest()
77
.addRunOnceInitializer(() -> {
78
appImageCmd.execute();
79
for (var path : filesWithDollarCharsInNames) {
80
createImageFile(appImageCmd, Path.of(path));
81
}
82
83
for (var path : dirsWithDollarCharsInNames) {
84
Files.createDirectories(
85
appImageCmd.outputBundle().resolve(path));
86
}
87
})
88
.addInitializer(cmd -> {
89
cmd.setArgumentValue("--name", name);
90
cmd.addArguments("--app-image", appImageCmd.outputBundle());
91
cmd.removeArgumentWithValue("--input");
92
cmd.addArgument("--win-menu");
93
cmd.addArgument("--win-shortcut");
94
})
95
.addInstallVerifier(cmd -> {
96
for (var path : filesWithDollarCharsInNames) {
97
verifyImageFile(appImageCmd, Path.of(path));
98
}
99
100
for (var path : dirsWithDollarCharsInNames) {
101
TKit.assertDirectoryExists(
102
appImageCmd.outputBundle().resolve(path));
103
}
104
}).run(Action.CREATE_AND_UNPACK);
105
}
106
107
private static void createImageFile(JPackageCommand cmd, Path name) throws
108
IOException {
109
Files.writeString(cmd.outputBundle().resolve(name), name.toString());
110
}
111
112
private static void verifyImageFile(JPackageCommand cmd, Path name) throws
113
IOException {
114
TKit.assertEquals(name.toString(), Files.readString(
115
(cmd.outputBundle().resolve(name))), String.format(
116
"Test contents of [%s] image file are euqal to [%s]", name, name));
117
}
118
}
119
120