Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/net/URLClassLoader/getresourceasstream/TestDriver.java
41153 views
1
/*
2
* Copyright (c) 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
* @bug 5103449
27
* @summary REGRESSION: getResourceAsStream is broken in JDK1.5.0-rc
28
* @library /test/lib
29
* @build jdk.test.lib.Utils
30
* jdk.test.lib.Asserts
31
* jdk.test.lib.JDKToolFinder
32
* jdk.test.lib.JDKToolLauncher
33
* jdk.test.lib.Platform
34
* jdk.test.lib.process.*
35
* Test
36
* @run main/othervm TestDriver
37
*/
38
39
import jdk.test.lib.JDKToolFinder;
40
import jdk.test.lib.process.ProcessTools;
41
42
import java.io.IOException;
43
import java.nio.file.Files;
44
import java.nio.file.Path;
45
import java.nio.file.Paths;
46
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
47
48
public class TestDriver {
49
private static final String ARCHIVE_NAME = "test.jar";
50
private static final String TEST_NAME = "Test";
51
private static final String POLICY_FILE = "policy";
52
public static void main(String[] args)
53
throws Throwable {
54
55
Path userDir = Paths.get(System.getProperty("user.dir"));
56
String java = JDKToolFinder.getTestJDKTool("java");
57
String basename = userDir.getFileName().toString();
58
setup(userDir);
59
ProcessBuilder[] tests = new ProcessBuilder[]{
60
new ProcessBuilder(
61
java, TEST_NAME, "./" + ARCHIVE_NAME
62
),
63
new ProcessBuilder(
64
java, "-cp", ".",
65
"-Djava.security.policy=file:./policy",
66
"-Djava.security.manager",
67
TEST_NAME, "./" + ARCHIVE_NAME
68
),
69
new ProcessBuilder(
70
java, "-cp", ".",
71
"-Djava.security.policy=file:./policy",
72
"-Djava.security.manager",
73
TEST_NAME, "./" + ARCHIVE_NAME
74
),
75
new ProcessBuilder(
76
java, "-cp", "..",
77
"-Djava.security.policy=file:../policy",
78
"-Djava.security.manager",
79
TEST_NAME, "../" + ARCHIVE_NAME
80
).directory(userDir.resolve("tmp").toFile()),
81
new ProcessBuilder(
82
java, "-cp", basename,
83
"-Djava.security.policy=file:" + basename + "/policy",
84
"-Djava.security.manager",
85
TEST_NAME, basename + "/" + ARCHIVE_NAME
86
).directory(userDir.resolve("..").toFile())};
87
for (ProcessBuilder test : tests) {
88
runTest(test);
89
}
90
}
91
92
private static void setup(Path userDir) throws IOException {
93
Path src = Paths.get(System.getProperty("test.src"));
94
Path testJar = src.resolve(ARCHIVE_NAME);
95
Path policy = src.resolve(POLICY_FILE);
96
Path testClass = Paths.get(System.getProperty("test.classes"),
97
TEST_NAME + ".class");
98
Files.copy(testJar, userDir.resolve(ARCHIVE_NAME), REPLACE_EXISTING);
99
Files.copy(policy, userDir.resolve(POLICY_FILE), REPLACE_EXISTING);
100
Files.copy(testClass, userDir.resolve(TEST_NAME + ".class"),
101
REPLACE_EXISTING);
102
Files.createDirectories(userDir.resolve("tmp"));
103
}
104
105
private static void runTest(ProcessBuilder pb) throws Exception {
106
System.out.println("Testing with command: [" + pb.command() + "]");
107
ProcessTools.executeProcess(pb)
108
.outputTo(System.out)
109
.errorTo(System.err)
110
.shouldHaveExitValue(0);
111
}
112
}
113
114