Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/langtools/jdk/javadoc/doclet/testConditionalPages/TestConditionalPages.java
40971 views
1
/*
2
* Copyright (c) 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
/*
25
* @test
26
* @bug 8254721
27
* @summary Improve support for conditionally generated files
28
* @library /tools/lib ../../lib
29
* @modules jdk.javadoc/jdk.javadoc.internal.tool
30
* @build toolbox.ToolBox javadoc.tester.* TestConditionalPages
31
* @run main TestConditionalPages
32
*/
33
34
35
import java.io.IOException;
36
import java.nio.file.Files;
37
import java.nio.file.Path;
38
import java.util.function.Consumer;
39
40
import javadoc.tester.JavadocTester;
41
import toolbox.Task;
42
import toolbox.ToolBox;
43
44
public class TestConditionalPages extends JavadocTester {
45
46
public static void main(String... args) throws Exception {
47
TestConditionalPages tester = new TestConditionalPages();
48
tester.runTests(m -> new Object[] { Path.of(m.getName()) });
49
}
50
51
ToolBox tb = new ToolBox();
52
53
@Test
54
public void testConstantValues(Path base) throws IOException {
55
test(base, """
56
package p;
57
public class C {
58
public static final int ZERO = 0;
59
}
60
""",
61
"constant-values.html",
62
b -> checkOutput("index-all.html", b, "Constant Field Values"));
63
}
64
65
@Test
66
public void testDeprecated(Path base) throws IOException {
67
test(base, """
68
package p;
69
@Deprecated
70
public class C { }
71
""",
72
"deprecated-list.html",
73
b -> checkOutput("index-all.html", b, "Deprecated"));
74
}
75
76
@Test
77
public void testSerializedForm(Path base) throws IOException {
78
test(base, """
79
package p;
80
import java.io.Serializable;
81
public class C implements Serializable { }
82
""",
83
"serialized-form.html",
84
b -> checkOutput("index-all.html", b, "Serialized Form"));
85
}
86
87
@Test
88
public void testSystemProperties(Path base) throws IOException {
89
test(base, """
90
package p;
91
/** This class uses {@systemProperty line.separator}. */
92
public class C { }
93
""",
94
"system-properties.html",
95
b -> checkOutput("index-all.html", b, "System Properties"));
96
}
97
98
void test(Path base, String code, String file, Consumer<Boolean> extraChecks) throws IOException {
99
test(base.resolve("a"), code, file, extraChecks, true);
100
test(base.resolve("b"), "package p; public class C { }", file, extraChecks, false);
101
}
102
103
void test(Path base, String code, String file, Consumer<Boolean> extraChecks, boolean expect) throws IOException {
104
Path src = Files.createDirectories(base.resolve("src"));
105
tb.writeJavaFiles(src, code);
106
107
javadoc("-d", base.resolve("out").toString(),
108
"-sourcepath", src.toString(),
109
"p");
110
checkExit(Exit.OK);
111
112
checkFiles(expect, file);
113
checkOutput(Output.OUT, expect, "Generating " + base.resolve("out").resolve(file));
114
extraChecks.accept(expect);
115
}
116
}
117
118