Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/tools/jinfo/BasicJInfoTest.java
41149 views
1
/*
2
* Copyright (c) 2005, 2020, 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.util.Arrays;
25
26
import jdk.test.lib.JDKToolLauncher;
27
import jdk.test.lib.Utils;
28
import jdk.test.lib.process.OutputAnalyzer;
29
import jdk.test.lib.process.ProcessTools;
30
31
/*
32
* @test
33
* @summary Unit test for jinfo utility
34
* @library /test/lib
35
* @run main BasicJInfoTest
36
*/
37
public class BasicJInfoTest {
38
39
private static ProcessBuilder processBuilder = new ProcessBuilder();
40
41
public static void main(String[] args) throws Exception {
42
testJinfoNoArgs();
43
testJinfoFlags();
44
testJinfoProps();
45
testJinfoFlagInvalid();
46
}
47
48
private static void testJinfoNoArgs() throws Exception {
49
OutputAnalyzer output = jinfo();
50
output.shouldContain("-XX");
51
output.shouldContain("test.jdk=");
52
output.shouldHaveExitValue(0);
53
}
54
55
private static void testJinfoFlagInvalid() throws Exception {
56
OutputAnalyzer output = jinfo("-flag");
57
output.shouldHaveExitValue(1);
58
}
59
60
private static void testJinfoFlags() throws Exception {
61
OutputAnalyzer output = jinfo("-flags");
62
output.shouldContain("-XX");
63
output.shouldHaveExitValue(0);
64
}
65
66
private static void testJinfoProps() throws Exception {
67
OutputAnalyzer output = jinfo("-props");
68
output.shouldContain("test.jdk=");
69
output.shouldHaveExitValue(0);
70
}
71
72
private static OutputAnalyzer jinfo(String... toolArgs) throws Exception {
73
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jinfo");
74
launcher.addVMArgs(Utils.getTestJavaOpts());
75
if (toolArgs != null) {
76
for (String toolArg : toolArgs) {
77
launcher.addToolArg(toolArg);
78
}
79
}
80
launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
81
82
processBuilder.command(launcher.getCommand());
83
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
84
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
85
System.out.println(output.getOutput());
86
87
return output;
88
}
89
90
}
91
92