44684
|
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
|
44685
|
26 |
* @bug 8178067
|
44684
|
27 |
* @summary tests the module's services, such as provides and uses
|
|
28 |
* @modules jdk.javadoc/jdk.javadoc.internal.api
|
|
29 |
* jdk.javadoc/jdk.javadoc.internal.tool
|
|
30 |
* jdk.compiler/com.sun.tools.javac.api
|
|
31 |
* jdk.compiler/com.sun.tools.javac.main
|
|
32 |
* @library ../lib /tools/lib
|
|
33 |
* @build toolbox.ToolBox toolbox.ModuleBuilder JavadocTester
|
|
34 |
* @run main TestModuleServices
|
|
35 |
*/
|
|
36 |
|
|
37 |
import java.nio.file.Path;
|
|
38 |
import java.nio.file.Paths;
|
|
39 |
|
|
40 |
import toolbox.*;
|
|
41 |
|
|
42 |
public class TestModuleServices extends JavadocTester {
|
|
43 |
|
|
44 |
public final ToolBox tb;
|
|
45 |
public static void main(String... args) throws Exception {
|
|
46 |
TestModuleServices tester = new TestModuleServices();
|
|
47 |
tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
|
|
48 |
}
|
|
49 |
|
|
50 |
public TestModuleServices() {
|
|
51 |
tb = new ToolBox();
|
|
52 |
}
|
|
53 |
|
|
54 |
@Test
|
|
55 |
public void checkUsesNoApiTagModuleModeDefault(Path base) throws Exception {
|
|
56 |
ModuleBuilder mb = new ModuleBuilder(tb, "m")
|
|
57 |
.comment("module m.\n@provides p1.A abc") // bogus tag
|
|
58 |
.uses("p1.A")
|
|
59 |
.uses("p1.B")
|
|
60 |
.exports("p1")
|
|
61 |
.classes("package p1; public class A {}")
|
|
62 |
.classes("package p1; public class B {}");
|
|
63 |
mb.write(base);
|
|
64 |
|
|
65 |
javadoc("-d", base.toString() + "/out",
|
|
66 |
"-quiet",
|
|
67 |
"--module-source-path", base.toString(),
|
|
68 |
"--module", "m");
|
|
69 |
checkExit(Exit.OK);
|
|
70 |
|
|
71 |
checkOutput("m-summary.html", false,
|
|
72 |
"<h3>Services</h3>");
|
|
73 |
}
|
|
74 |
|
|
75 |
@Test
|
|
76 |
public void checkUsesNoApiTagModuleModeAll(Path base) throws Exception {
|
|
77 |
ModuleBuilder mb = new ModuleBuilder(tb, "m")
|
|
78 |
.uses("p1.A")
|
|
79 |
.uses("p1.B")
|
|
80 |
.exports("p1")
|
|
81 |
.classes("package p1; public class A {}")
|
|
82 |
.classes("package p1; public class B {}");
|
|
83 |
mb.write(base);
|
|
84 |
|
|
85 |
javadoc("-d", base.toString() + "/out",
|
|
86 |
"-quiet",
|
|
87 |
"--show-module-contents", "all",
|
|
88 |
"--module-source-path", base.toString(),
|
|
89 |
"--module", "m");
|
|
90 |
checkExit(Exit.OK);
|
|
91 |
|
|
92 |
checkOutput("m-summary.html", true,
|
|
93 |
"<h3>Services</h3>");
|
|
94 |
|
|
95 |
checkOutput("m-summary.html", true,
|
|
96 |
"<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
|
|
97 |
"<caption><span>Uses</span><span class=\"tabEnd\"> </span></caption>\n" +
|
|
98 |
"<tr>\n" +
|
|
99 |
"<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
|
|
100 |
"<th class=\"colLast\" scope=\"col\">Description</th>\n" +
|
|
101 |
"</tr>\n" +
|
|
102 |
"<tbody>\n" +
|
|
103 |
"<tr class=\"altColor\">\n" +
|
|
104 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"class in p1\">A</a></th>\n" +
|
|
105 |
"<td class=\"colLast\"> </td>\n" +
|
|
106 |
"</tr>\n" +
|
|
107 |
"<tr class=\"rowColor\">\n" +
|
|
108 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p1/B.html\" title=\"class in p1\">B</a></th>\n" +
|
|
109 |
"<td class=\"colLast\"> </td>\n" +
|
|
110 |
"</tr>\n" +
|
|
111 |
"</tbody>\n" +
|
|
112 |
"</table>\n");
|
|
113 |
}
|
|
114 |
|
|
115 |
@Test
|
|
116 |
public void checkUsesWithApiTagModuleModeDefault(Path base) throws Exception {
|
|
117 |
ModuleBuilder mb = new ModuleBuilder(tb, "m")
|
|
118 |
.comment("module m.\n@uses p1.A")
|
|
119 |
.uses("p1.A")
|
|
120 |
.uses("p1.B")
|
|
121 |
.exports("p1")
|
|
122 |
.classes("package p1; public class A {}")
|
|
123 |
.classes("package p1; public class B {}");
|
|
124 |
mb.write(base);
|
|
125 |
|
|
126 |
javadoc("-d", base.toString() + "/out",
|
|
127 |
"-quiet",
|
|
128 |
"--module-source-path", base.toString(),
|
|
129 |
"--module", "m");
|
|
130 |
checkExit(Exit.OK);
|
|
131 |
|
|
132 |
checkOutput("m-summary.html", true,
|
|
133 |
"<h3>Services</h3>");
|
|
134 |
|
|
135 |
checkOutput("m-summary.html", true,
|
|
136 |
"<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
|
|
137 |
"<caption><span>Uses</span><span class=\"tabEnd\"> </span></caption>\n" +
|
|
138 |
"<tr>\n" +
|
|
139 |
"<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
|
|
140 |
"<th class=\"colLast\" scope=\"col\">Description</th>\n" +
|
|
141 |
"</tr>\n" +
|
|
142 |
"<tbody>\n" +
|
|
143 |
"<tr class=\"altColor\">\n" +
|
|
144 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"class in p1\">A</a></th>\n" +
|
|
145 |
"<td class=\"colLast\"> </td>\n" +
|
|
146 |
"</tr>\n" +
|
|
147 |
"</tbody>\n" +
|
|
148 |
"</table>\n");
|
|
149 |
}
|
|
150 |
|
|
151 |
@Test
|
|
152 |
public void checkProvidesNoApiTagModuleModeDefault(Path base) throws Exception {
|
|
153 |
ModuleBuilder mb = new ModuleBuilder(tb, "m")
|
|
154 |
.comment("module m.\n@uses p1.A")
|
|
155 |
.provides("p1.A", "p1.B")
|
|
156 |
.exports("p1")
|
|
157 |
.classes("package p1; public interface A {}")
|
|
158 |
.classes("package p1; public class B implements A {}")
|
|
159 |
.provides("p2.A", "p2.B")
|
|
160 |
.exports("p2")
|
|
161 |
.classes("package p2; public interface A {}")
|
|
162 |
.classes("package p2; public class B implements A {}");
|
|
163 |
mb.write(base);
|
|
164 |
|
|
165 |
javadoc("-d", base.toString() + "/out",
|
|
166 |
"-quiet",
|
|
167 |
"--module-source-path", base.toString(),
|
|
168 |
"--module", "m");
|
|
169 |
|
|
170 |
checkExit(Exit.OK);
|
|
171 |
|
|
172 |
checkOutput("m-summary.html", false,
|
|
173 |
"<h3>Services</h3>");
|
|
174 |
}
|
|
175 |
|
|
176 |
@Test
|
|
177 |
public void checkProvidesNoApiTagModuleModeAll(Path base) throws Exception {
|
|
178 |
ModuleBuilder mb = new ModuleBuilder(tb, "m")
|
|
179 |
.comment("module m.\n@uses p1.A") // bogus uses tag
|
|
180 |
.provides("p1.A", "p1.B")
|
|
181 |
.exports("p1")
|
|
182 |
.classes("package p1; public interface A {}")
|
|
183 |
.classes("package p1; public class B implements A {}")
|
|
184 |
.provides("p2.A", "p2.B")
|
|
185 |
.exports("p2")
|
|
186 |
.classes("package p2; public interface A {}")
|
|
187 |
.classes("package p2; public class B implements A {}");
|
|
188 |
mb.write(base);
|
|
189 |
|
|
190 |
javadoc("-d", base.toString() + "/out",
|
|
191 |
"-quiet",
|
|
192 |
"--show-module-contents", "all",
|
|
193 |
"--module-source-path", base.toString(),
|
|
194 |
"--module", "m");
|
|
195 |
|
|
196 |
checkExit(Exit.OK);
|
|
197 |
|
|
198 |
checkOutput("m-summary.html", true,
|
|
199 |
"<h3>Services</h3>");
|
|
200 |
|
|
201 |
checkOutput("m-summary.html", true,
|
|
202 |
"<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
|
|
203 |
"<caption><span>Provides</span><span class=\"tabEnd\"> </span></caption>\n" +
|
|
204 |
"<tr>\n" +
|
|
205 |
"<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
|
|
206 |
"<th class=\"colLast\" scope=\"col\">Description</th>\n" +
|
|
207 |
"</tr>\n" +
|
|
208 |
"<tbody>\n" +
|
|
209 |
"<tr class=\"altColor\">\n" +
|
|
210 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"interface in p1\">A</a></th>\n" +
|
|
211 |
"<td class=\"colLast\"> <br>(<span class=\"implementationLabel\">Implementation(s):</span> <a href=\"p1/B.html\" title=\"class in p1\">B</a>)</td>\n" +
|
|
212 |
"</tr>\n" +
|
|
213 |
"<tr class=\"rowColor\">\n" +
|
|
214 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p2/A.html\" title=\"interface in p2\">A</a></th>\n" +
|
|
215 |
"<td class=\"colLast\"> <br>(<span class=\"implementationLabel\">Implementation(s):</span> <a href=\"p2/B.html\" title=\"class in p2\">B</a>)</td>\n" +
|
|
216 |
"</tr>\n" +
|
|
217 |
"</tbody>\n");
|
|
218 |
}
|
|
219 |
|
|
220 |
@Test
|
|
221 |
public void checkProvidesWithApiTagModuleModeDefault(Path base) throws Exception {
|
|
222 |
ModuleBuilder mb = new ModuleBuilder(tb, "m")
|
|
223 |
.comment("module m.\n@provides p1.A abc")
|
|
224 |
.provides("p1.A", "p1.B")
|
|
225 |
.exports("p1")
|
|
226 |
.classes("package p1; public interface A {}")
|
|
227 |
.classes("package p1; public class B implements A {}")
|
|
228 |
.provides("p2.A", "p2.B")
|
|
229 |
.exports("p2")
|
|
230 |
.classes("package p2; public interface A {}")
|
|
231 |
.classes("package p2; public class B implements A {}");
|
|
232 |
mb.write(base);
|
|
233 |
|
|
234 |
javadoc("-d", base.toString() + "/out",
|
|
235 |
"-quiet",
|
|
236 |
"--module-source-path", base.toString(),
|
|
237 |
"--module", "m");
|
|
238 |
|
|
239 |
checkExit(Exit.OK);
|
|
240 |
|
|
241 |
checkOutput("m-summary.html", true,
|
|
242 |
"<h3>Services</h3>");
|
|
243 |
|
|
244 |
checkOutput("m-summary.html", true,
|
|
245 |
"<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
|
|
246 |
"<caption><span>Provides</span><span class=\"tabEnd\"> </span></caption>\n" +
|
|
247 |
"<tr>\n" +
|
|
248 |
"<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
|
|
249 |
"<th class=\"colLast\" scope=\"col\">Description</th>\n" +
|
|
250 |
"</tr>\n" +
|
|
251 |
"<tbody>\n" +
|
|
252 |
"<tr class=\"altColor\">\n" +
|
|
253 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"interface in p1\">A</a></th>\n" +
|
|
254 |
"<td class=\"colLast\">abc </td>\n" +
|
|
255 |
"</tr>\n" +
|
|
256 |
"</tbody>\n" +
|
|
257 |
"</table>\n");
|
|
258 |
}
|
|
259 |
|
|
260 |
@Test
|
|
261 |
public void checkUsesProvidesWithApiTagsModeDefault(Path base) throws Exception {
|
|
262 |
ModuleBuilder mb = new ModuleBuilder(tb, "m")
|
|
263 |
.comment("module m.\n@provides p1.A abc\n@uses p2.B def")
|
|
264 |
.provides("p1.A", "p1.B")
|
|
265 |
.exports("p1")
|
|
266 |
.classes("package p1; public interface A {}")
|
|
267 |
.classes("package p1; public class B implements A {}")
|
|
268 |
.provides("p2.A", "p2.B")
|
|
269 |
.uses("p2.B")
|
|
270 |
.exports("p2")
|
|
271 |
.classes("package p2; public interface A {}")
|
|
272 |
.classes("package p2; public class B implements A {}");
|
|
273 |
mb.write(base);
|
|
274 |
|
|
275 |
javadoc("-d", base.toString() + "/out",
|
|
276 |
"-quiet",
|
|
277 |
"--module-source-path", base.toString(),
|
|
278 |
"--module", "m");
|
|
279 |
|
|
280 |
checkExit(Exit.OK);
|
|
281 |
|
|
282 |
checkOutput("m-summary.html", true,
|
|
283 |
"<h3>Services</h3>");
|
|
284 |
|
|
285 |
checkOutput("m-summary.html", true,
|
|
286 |
"<table class=\"providesSummary\" summary=\"Provides table, listing types, and an explanation\">\n" +
|
|
287 |
"<caption><span>Provides</span><span class=\"tabEnd\"> </span></caption>\n" +
|
|
288 |
"<tr>\n" +
|
|
289 |
"<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
|
|
290 |
"<th class=\"colLast\" scope=\"col\">Description</th>\n" +
|
|
291 |
"</tr>\n" +
|
|
292 |
"<tbody>\n" +
|
|
293 |
"<tr class=\"altColor\">\n" +
|
|
294 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p1/A.html\" title=\"interface in p1\">A</a></th>\n" +
|
|
295 |
"<td class=\"colLast\">abc </td>\n" +
|
|
296 |
"</tr>\n" +
|
|
297 |
"</tbody>\n" +
|
|
298 |
"</table>",
|
|
299 |
"<table class=\"usesSummary\" summary=\"Uses table, listing types, and an explanation\">\n" +
|
|
300 |
"<caption><span>Uses</span><span class=\"tabEnd\"> </span></caption>\n" +
|
|
301 |
"<tr>\n" +
|
|
302 |
"<th class=\"colFirst\" scope=\"col\">Type</th>\n" +
|
|
303 |
"<th class=\"colLast\" scope=\"col\">Description</th>\n" +
|
|
304 |
"</tr>\n" +
|
|
305 |
"<tbody>\n" +
|
|
306 |
"<tr class=\"altColor\">\n" +
|
|
307 |
"<th class=\"colFirst\" scope=\"row\"><a href=\"p2/B.html\" title=\"class in p2\">B</a></th>\n" +
|
|
308 |
"<td class=\"colLast\">def </td>\n" +
|
|
309 |
"</tr>\n" +
|
|
310 |
"</tbody>\n" +
|
|
311 |
"</table>\n");
|
|
312 |
}
|
|
313 |
|
|
314 |
}
|