Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jar/multiRelease/Basic1.java
41149 views
1
/*
2
* Copyright (c) 2016, 2017, 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
/*
25
* @test
26
* @library /test/lib
27
* @modules java.base/jdk.internal.misc
28
* jdk.compiler
29
* jdk.jartool
30
* @build jdk.test.lib.Utils
31
* jdk.test.lib.Asserts
32
* jdk.test.lib.JDKToolFinder
33
* jdk.test.lib.JDKToolLauncher
34
* jdk.test.lib.Platform
35
* jdk.test.lib.process.*
36
* MRTestBase
37
* @run testng Basic1
38
*/
39
40
import org.testng.annotations.*;
41
42
import java.nio.file.*;
43
import java.util.*;
44
45
public class Basic1 extends MRTestBase {
46
47
@BeforeTest
48
public void setup() throws Throwable {
49
String test = "test01";
50
Path classes = Paths.get("classes");
51
52
Path base = classes.resolve("base");
53
Files.createDirectories(base);
54
Path source = Paths.get(src, "data", test, "base", "version");
55
javac(base, source.resolve("Main.java"), source.resolve("Version.java"));
56
57
Path v9 = classes.resolve("v9");
58
Files.createDirectories(v9);
59
source = Paths.get(src, "data", test, "v9", "version");
60
javac(v9, source.resolve("Version.java"));
61
62
Path v10 = classes.resolve("v10");
63
Files.createDirectories(v10);
64
source = Paths.get(src, "data", test, "v10", "version");
65
javac(v10, source.resolve("Version.java"));
66
67
Path v10_1 = classes.resolve("v10_1").resolve("META-INF").resolve("versions").resolve("v10");
68
Files.createDirectories(v10_1);
69
source = Paths.get(src, "data", test, "v10", "version");
70
javac(v10_1, source.resolve("Version.java"));
71
}
72
73
@Test
74
public void test() throws Throwable {
75
String jarfile = "test.jar";
76
Path classes = Paths.get("classes");
77
78
Path base = classes.resolve("base");
79
Path v9 = classes.resolve("v9");
80
Path v10 = classes.resolve("v10");
81
82
jar("cf", jarfile, "-C", base.toString(), ".",
83
"--release", "9", "-C", v9.toString(), ".",
84
"--release", "10", "-C", v10.toString(), ".")
85
.shouldHaveExitValue(SUCCESS);
86
87
checkMultiRelease(jarfile, true);
88
89
Map<String, String[]> names = Map.of(
90
"version/Main.class",
91
new String[]{"base", "version", "Main.class"},
92
93
"version/Version.class",
94
new String[]{"base", "version", "Version.class"},
95
96
"META-INF/versions/9/version/Version.class",
97
new String[] {"v9", "version", "Version.class"},
98
99
"META-INF/versions/10/version/Version.class",
100
new String[] {"v10", "version", "Version.class"}
101
);
102
103
compare(jarfile, names);
104
}
105
106
@Test
107
public void testFail() throws Throwable {
108
String jarfile = "test.jar";
109
Path classes = Paths.get("classes");
110
Path base = classes.resolve("base");
111
Path v10 = classes.resolve("v10_1");
112
113
jar("cf", jarfile, "-C", base.toString(), ".",
114
"--release", "10", "-C", v10.toString(), ".")
115
.shouldNotHaveExitValue(SUCCESS)
116
.shouldContain("unexpected versioned entry META-INF/versions/");
117
}
118
}
119
120