Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/launcher/modules/describe/DescribeModuleTest.java
41154 views
1
/*
2
* Copyright (c) 2017, 2018, 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
* @modules java.xml
27
* @library /test/lib
28
* @build DescribeModuleTest
29
* @run testng DescribeModuleTest
30
* @summary Basic test for java --describe-module
31
*/
32
33
import jdk.test.lib.process.ProcessTools;
34
35
import org.testng.annotations.Test;
36
import static org.testng.Assert.*;
37
38
@Test
39
public class DescribeModuleTest {
40
41
/**
42
* Test that the output describes java.base
43
*/
44
private void expectJavaBase(String... args) throws Exception {
45
int exitValue = ProcessTools.executeTestJava(args)
46
.outputTo(System.out)
47
.errorTo(System.out)
48
.stdoutShouldContain("java.base")
49
.stdoutShouldContain("exports java.lang")
50
.stdoutShouldContain("uses java.nio.file.spi.FileSystemProvider")
51
.stdoutShouldContain("contains sun.launcher")
52
.stdoutShouldNotContain("requires ")
53
.getExitValue();
54
assertTrue(exitValue == 0);
55
}
56
57
/**
58
* Test that the output describes java.xml
59
*/
60
private void expectJavaXml(String... args) throws Exception {
61
int exitValue = ProcessTools.executeTestJava(args)
62
.outputTo(System.out)
63
.errorTo(System.out)
64
.stdoutShouldContain("java.xml")
65
.stdoutShouldContain("exports javax.xml")
66
.stdoutShouldContain("requires java.base")
67
.stdoutShouldContain("uses javax.xml.stream.XMLInputFactory")
68
.getExitValue();
69
assertTrue(exitValue == 0);
70
}
71
72
/**
73
* Test output/exitValue when describing an unknown module
74
*/
75
private void expectUnknownModule(String... args) throws Exception {
76
int exitValue = ProcessTools.executeTestJava(args)
77
.outputTo(System.out)
78
.errorTo(System.out)
79
.stdoutShouldNotContain("requires java.base")
80
.getExitValue();
81
assertTrue(exitValue != 0);
82
}
83
84
85
public void testDescribeJavaBase() throws Exception {
86
expectJavaBase("--describe-module", "java.base");
87
expectJavaBase("--describe-module=java.base");
88
expectJavaBase("-d", "java.base");
89
}
90
91
public void testDescribeJavaXml() throws Exception {
92
expectJavaXml("--describe-module", "java.xml");
93
expectJavaXml("--describe-module=java.xml");
94
expectJavaXml("-d", "java.xml");
95
}
96
97
public void testDescribeUnknownModule() throws Exception {
98
expectUnknownModule("--describe-module", "jdk.rhubarb");
99
expectUnknownModule("--describe-module=jdk.rhubarb");
100
expectUnknownModule("-d", "jdk.rhubarb");
101
}
102
103
}
104
105