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