1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.grammar.javadoc;
21
22 import java.io.File;
23 import java.io.IOException;
24
25 import org.junit.jupiter.api.Test;
26
27 import com.puppycrawl.tools.checkstyle.AbstractTreeTestSupport;
28
29
30
31
32
33
34
35 public class JavadocParseTreeTest extends AbstractTreeTestSupport {
36
37 @Override
38 protected String getPackageLocation() {
39 return "com/puppycrawl/tools/checkstyle/grammar/javadoc/";
40 }
41
42 private String getHtmlPath(String filename) throws IOException {
43 return getPath("htmlTags" + File.separator + filename);
44 }
45
46 private String getDocPath(String filename) throws IOException {
47 return getPath("javadocTags" + File.separator + filename);
48 }
49
50 @Test
51 public void oneSimpleHtmlTag() throws Exception {
52 verifyJavadocTree(getHtmlPath("expectedOneSimpleHtmlTagAst.txt"),
53 getHtmlPath("InputOneSimpleHtmlTag.javadoc"));
54 }
55
56 @Test
57 public void textBeforeJavadocTags() throws Exception {
58 verifyJavadocTree(getDocPath("expectedTextBeforeJavadocTagsAst.txt"),
59 getDocPath("InputTextBeforeJavadocTags.javadoc"));
60 }
61
62 @Test
63 public void customJavadocTags() throws Exception {
64 verifyJavadocTree(getDocPath("expectedCustomJavadocTagsAst.txt"),
65 getDocPath("InputCustomJavadocTags.javadoc"));
66 }
67
68 @Test
69 public void javadocTagDescriptionWithInlineTags() throws Exception {
70 verifyJavadocTree(getDocPath("expectedJavadocTagDescriptionWithInlineTagsAst.txt"),
71 getDocPath("InputJavadocTagDescriptionWithInlineTags.javadoc"));
72 }
73
74 @Test
75 public void leadingAsterisks() throws Exception {
76 verifyJavadocTree(getPath("expectedLeadingAsterisksAst.txt"),
77 getPath("InputLeadingAsterisks.javadoc"));
78 }
79
80 @Test
81 public void authorWithMailto() throws Exception {
82 verifyJavadocTree(getDocPath("expectedAuthorWithMailtoAst.txt"),
83 getDocPath("InputAuthorWithMailto.javadoc"));
84 }
85
86 @Test
87 public void htmlTagsInParagraph() throws Exception {
88 verifyJavadocTree(getHtmlPath("expectedHtmlTagsInParagraphAst.txt"),
89 getHtmlPath("InputHtmlTagsInParagraph.javadoc"));
90 }
91
92 @Test
93 public void linkInlineTags() throws Exception {
94 verifyJavadocTree(getDocPath("expectedLinkInlineTagsAst.txt"),
95 getDocPath("InputLinkInlineTags.javadoc"));
96 }
97
98 @Test
99 public void seeReferenceWithFewNestedClasses() throws Exception {
100 verifyJavadocTree(getDocPath("expectedSeeReferenceWithFewNestedClassesAst.txt"),
101 getDocPath("InputSeeReferenceWithFewNestedClasses.javadoc"));
102 }
103
104 @Test
105 public void paramWithGeneric() throws Exception {
106 verifyJavadocTree(getDocPath("expectedParamWithGenericAst.txt"),
107 getDocPath("InputParamWithGeneric.javadoc"));
108 }
109
110 @Test
111 public void serial() throws Exception {
112 verifyJavadocTree(getDocPath("expectedSerialAst.txt"),
113 getDocPath("InputSerial.javadoc"));
114 }
115
116 @Test
117 public void since() throws Exception {
118 verifyJavadocTree(getDocPath("expectedSinceAst.txt"),
119 getDocPath("InputSince.javadoc"));
120 }
121
122 @Test
123 public void unclosedAndClosedParagraphs() throws Exception {
124 verifyJavadocTree(getHtmlPath("expectedUnclosedAndClosedParagraphsAst.txt"),
125 getHtmlPath("InputUnclosedAndClosedParagraphs.javadoc"));
126 }
127
128 @Test
129 public void listWithUnclosedItemInUnclosedParagraph() throws Exception {
130 verifyJavadocTree(getHtmlPath("expectedListWithUnclosedItemInUnclosedParagraphAst.txt"),
131 getHtmlPath("InputListWithUnclosedItemInUnclosedParagraph.javadoc"));
132 }
133
134 @Test
135 public void unclosedParagraphFollowedByJavadocTag() throws Exception {
136 verifyJavadocTree(getHtmlPath("expectedUnclosedParagraphFollowedByJavadocTagAst.txt"),
137 getHtmlPath("InputUnclosedParagraphFollowedByJavadocTag.javadoc"));
138 }
139
140 @Test
141 public void allJavadocInlineTags() throws Exception {
142 verifyJavadocTree(getDocPath("expectedAllJavadocInlineTagsAst.txt"),
143 getDocPath("InputAllJavadocInlineTags.javadoc"));
144 }
145
146 @Test
147 public void docRootInheritDoc() throws Exception {
148 verifyJavadocTree(getDocPath("expectedDocRootInheritDocAst.txt"),
149 getDocPath("InputDocRootInheritDoc.javadoc"));
150 }
151
152 @Test
153 public void fewWhiteSpacesAsSeparator() throws Exception {
154 verifyJavadocTree(getDocPath("expectedFewWhiteSpacesAsSeparatorAst.txt"),
155 getDocPath("InputFewWhiteSpacesAsSeparator.javadoc"));
156 }
157
158 @Test
159 public void mixedCaseOfHtmlTags() throws Exception {
160 verifyJavadocTree(getHtmlPath("expectedMixedCaseOfHtmlTagsAst.txt"),
161 getHtmlPath("InputMixedCaseOfHtmlTags.javadoc"));
162 }
163
164 @Test
165 public void htmlComments() throws Exception {
166 verifyJavadocTree(getHtmlPath("expectedCommentsAst.txt"),
167 getHtmlPath("InputComments.javadoc"));
168 }
169
170 @Test
171 public void negativeNumberInAttribute() throws Exception {
172 verifyJavadocTree(getHtmlPath("expectedNegativeNumberInAttributeAst.txt"),
173 getHtmlPath("InputNegativeNumberInAttribute.javadoc"));
174 }
175
176 @Test
177 public void dollarInLink() throws Exception {
178 verifyJavadocTree(getDocPath("expectedDollarInLinkAst.txt"),
179 getDocPath("InputDollarInLink.javadoc"));
180 }
181
182 @Test
183 public void dotCharacterInCustomTags() throws Exception {
184 verifyJavadocTree(getDocPath("expectedCustomTagWithDotAst.txt"),
185 getDocPath("InputCustomTagWithDot.javadoc"));
186 }
187
188 @Test
189 public void testLinkToPackage() throws Exception {
190 verifyJavadocTree(getDocPath("expectedLinkToPackageAst.txt"),
191 getDocPath("InputLinkToPackage.javadoc"));
192 }
193
194 @Test
195 public void testLeadingAsterisksExtended() throws Exception {
196 verifyJavadocTree(getPath("expectedLeadingAsterisksExtendedAst.txt"),
197 getPath("InputLeadingAsterisksExtended.javadoc"));
198 }
199
200 @Test
201 public void testInlineCustomJavadocTag() throws Exception {
202 verifyJavadocTree(getDocPath("expectedInlineCustomJavadocTagAst.txt"),
203 getDocPath("InputInlineCustomJavadocTag.javadoc"));
204 }
205
206 @Test
207 public void testAttributeValueWithoutQuotes() throws Exception {
208 verifyJavadocTree(getHtmlPath("expectedAttributeValueWithoutQuotesAst.txt"),
209 getHtmlPath("InputAttributeValueWithoutQuotes.javadoc"));
210 }
211
212 @Test
213 public void testClosedOtherTag() throws Exception {
214 verifyJavadocTree(getHtmlPath("expectedClosedOtherTagAst.txt"),
215 getHtmlPath("InputClosedOtherTag.javadoc"));
216 }
217
218 @Test
219 public void testAllStandardJavadocTags() throws Exception {
220 verifyJavadocTree(getDocPath("expectedAllStandardJavadocTagsAst.txt"),
221 getDocPath("InputAllStandardJavadocTags.javadoc"));
222 }
223
224 @Test
225 public void testAsteriskInJavadocInlineTag() throws Exception {
226 verifyJavadocTree(getDocPath("expectedAsteriskInJavadocInlineTagAst.txt"),
227 getDocPath("InputAsteriskInJavadocInlineTag.javadoc"));
228 }
229
230 @Test
231 public void testAsteriskInLiteral() throws Exception {
232 verifyJavadocTree(getDocPath("expectedAsteriskInLiteralAst.txt"),
233 getDocPath("InputAsteriskInLiteral.javadoc"));
234 }
235
236 @Test
237 public void testInnerBracesInCodeTag() throws Exception {
238 verifyJavadocTree(getDocPath("expectedInnerBracesInCodeTagAst.txt"),
239 getDocPath("InputInnerBracesInCodeTag.javadoc"));
240 }
241
242 @Test
243 public void testNewlineAndAsteriskInParameters() throws Exception {
244 verifyJavadocTree(getDocPath("expectedNewlineAndAsteriskInParametersAst.txt"),
245 getDocPath("InputNewlineAndAsteriskInParameters.javadoc"));
246 }
247
248 @Test
249 public void testTwoLinkTagsInRow() throws Exception {
250 verifyJavadocTree(getDocPath("expectedTwoLinkTagsInRowAst.txt"),
251 getDocPath("InputTwoLinkTagsInRow.javadoc"));
252 }
253
254 @Test
255 public void testJavadocWithCrAsNewline() throws Exception {
256 verifyJavadocTree(getPath("expectedJavadocWithCrAsNewlineAst.txt"),
257 getPath("InputJavadocWithCrAsNewline.javadoc"));
258 }
259
260 @Test
261 public void testNestingWithSingletonElement() throws Exception {
262 verifyJavadocTree(getHtmlPath("expectedNestingWithSingletonElementAst.txt"),
263 getHtmlPath("InputNestingWithSingletonElement.javadoc"));
264 }
265
266 @Test
267 public void testVoidElements() throws Exception {
268 verifyJavadocTree(getHtmlPath("expectedVoidElementsAst.txt"),
269 getHtmlPath("InputVoidElements.javadoc"));
270 }
271
272 @Test
273 public void testHtmlVoidElementEmbed() throws Exception {
274 verifyJavadocTree(getHtmlPath("expectedHtmlVoidElementEmbedAst.txt"),
275 getHtmlPath("InputHtmlVoidElementEmbed.javadoc"));
276 }
277
278 @Test
279 public void testSpaceBeforeDescriptionInBlockJavadocTags() throws Exception {
280 verifyJavadocTree(getDocPath("expectedSpaceBeforeDescriptionInBlockJavadocTagsAst.txt"),
281 getDocPath("InputSpaceBeforeDescriptionInBlockJavadocTags.javadoc"));
282 }
283
284 @Test
285 public void testEmptyDescriptionBeforeTags() throws Exception {
286 verifyJavadocTree(getDocPath("expectedEmptyDescriptionBeforeTags.txt"),
287 getDocPath("InputEmptyDescriptionBeforeTags.javadoc"));
288 }
289
290 @Test
291 public void testSpaceBeforeDescriptionInInlineTags() throws Exception {
292 verifyJavadocTree(getDocPath("expectedSpaceBeforeArgsInInlineTagsAst.txt"),
293 getDocPath("InputSpaceBeforeArgsInInlineTags.javadoc"));
294 }
295
296 @Test
297 public void testHtmlVoidElementKeygen() throws Exception {
298 verifyJavadocTree(getHtmlPath("expectedHtmlVoidElementKeygenAst.txt"),
299 getHtmlPath("InputHtmlVoidElementKeygen.javadoc"));
300 }
301
302 @Test
303 public void testHtmlVoidElementSource() throws Exception {
304 verifyJavadocTree(getHtmlPath("expectedHtmlVoidElementSourceAst.txt"),
305 getHtmlPath("InputHtmlVoidElementSource.javadoc"));
306 }
307
308 @Test
309 public void testHtmlVoidElementTrack() throws Exception {
310 verifyJavadocTree(getHtmlPath("expectedHtmlVoidElementTrackAst.txt"),
311 getHtmlPath("InputHtmlVoidElementTrack.javadoc"));
312 }
313
314 @Test
315 public void testHtmlVoidElementWbr() throws Exception {
316 verifyJavadocTree(getHtmlPath("expectedHtmlVoidElementWbrAst.txt"),
317 getHtmlPath("InputHtmlVoidElementWbr.javadoc"));
318 }
319
320 @Test
321 public void testOptgroupHtmlTag() throws Exception {
322 verifyJavadocTree(getHtmlPath("expectedOptgroupHtmlTagAst.txt"),
323 getHtmlPath("InputOptgroupHtmlTag.javadoc"));
324 }
325
326 @Test
327 public void testNonTightOptgroupHtmlTag() throws Exception {
328 verifyJavadocTree(getHtmlPath("expectedNonTightOptgroupHtmlTagAst.txt"),
329 getHtmlPath("InputNonTightOptgroupHtmlTag.javadoc"));
330 }
331
332 @Test
333 public void testRbHtmlTag() throws Exception {
334 verifyJavadocTree(getHtmlPath("expectedRbHtmlTagAst.txt"),
335 getHtmlPath("InputRbHtmlTag.javadoc"));
336 }
337
338 @Test
339 public void testNonTightRbHtmlTag() throws Exception {
340 verifyJavadocTree(getHtmlPath("expectedNonTightRbHtmlTagAst.txt"),
341 getHtmlPath("InputNonTightRbHtmlTag.javadoc"));
342 }
343
344 @Test
345 public void testRtHtmlTag() throws Exception {
346 verifyJavadocTree(getHtmlPath("expectedRtHtmlTagAst.txt"),
347 getHtmlPath("InputRtHtmlTag.javadoc"));
348 }
349
350 @Test
351 public void testNonTightRtHtmlTag() throws Exception {
352 verifyJavadocTree(getHtmlPath("expectedNonTightRtHtmlTagAst.txt"),
353 getHtmlPath("InputNonTightRtHtmlTag.javadoc"));
354 }
355
356 @Test
357 public void testRtcHtmlTag() throws Exception {
358 verifyJavadocTree(getHtmlPath("expectedRtcHtmlTagAst.txt"),
359 getHtmlPath("InputRtcHtmlTag.javadoc"));
360 }
361
362 @Test
363 public void testNonTightRtcHtmlTag() throws Exception {
364 verifyJavadocTree(getHtmlPath("expectedNonTightRtcHtmlTagAst.txt"),
365 getHtmlPath("InputNonTightRtcHtmlTag.javadoc"));
366 }
367
368 @Test
369 public void testRpHtmlTag() throws Exception {
370 verifyJavadocTree(getHtmlPath("expectedRpHtmlTagAst.txt"),
371 getHtmlPath("InputRpHtmlTag.javadoc"));
372 }
373
374 @Test
375 public void testNonTightRpHtmlTag() throws Exception {
376 verifyJavadocTree(getHtmlPath("expectedNonTightRpHtmlTagAst.txt"),
377 getHtmlPath("InputNonTightRpHtmlTag.javadoc"));
378 }
379
380 @Test
381 public void testLeadingAsteriskAfterSeeTag() throws Exception {
382 verifyJavadocTree(getDocPath("expectedLeadingAsteriskAfterSeeTagAst.txt"),
383 getDocPath("InputLeadingAsteriskAfterSeeTag.javadoc"));
384 }
385
386 @Test
387 public void testUppercaseInPackageName() throws Exception {
388 verifyJavadocTree(getDocPath("expectedUppercaseInPackageNameAst.txt"),
389 getDocPath("InputUppercaseInPackageName.javadoc"));
390 }
391
392 @Test
393 public void testParagraph() throws Exception {
394 verifyJavadocTree(getHtmlPath("expectedParagraphAst.txt"),
395 getHtmlPath("InputParagraph.javadoc"));
396 }
397
398 @Test
399 public void testCdata() throws Exception {
400 verifyJavadocTree(getHtmlPath("expectedCdataAst.txt"),
401 getHtmlPath("InputCdata.javadoc"));
402 }
403
404 @Test
405 public void testCrAsNewlineMultiline() throws Exception {
406 verifyJavadocTree(getPath("expectedCrAsNewlineMultiline.txt"),
407 getPath("InputCrAsNewlineMultiline.javadoc"));
408 }
409
410 @Test
411 public void testDosLineEndingAsNewlineMultiline() throws Exception {
412 verifyJavadocTree(getPath("expectedDosLineEndingAsNewlineMultiline.txt"),
413 getPath("InputDosLineEndingAsNewlineMultiline.javadoc"));
414 }
415
416 @Test
417 public void testAnnotationsInsideInlineTag() throws Exception {
418 verifyJavadocTree(getDocPath("expectedAnnotationsInsideInlineTagAst.txt"),
419 getDocPath("InputAnnotationsInsideInlineTag.javadoc"));
420 }
421
422 @Test
423 public void testSeeTagOptionalWhitespaceAfterHtmlTag() throws Exception {
424 verifyJavadocTree(getDocPath("expectedSeeTagOptionalWhitespaceAfterHtmlTag.txt"),
425 getDocPath("InputSeeTagOptionalWhitespaceAfterHtmlTag.javadoc"));
426 }
427
428 @Test
429 public void testEmptyReferenceInLink() throws Exception {
430 verifyJavadocTree(getDocPath("expectedEmptyReferenceInLinkAst.txt"),
431 getDocPath("InputEmptyReferenceInLink.javadoc"));
432 }
433 }