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 public class JavadocCommentsAstRegressionTest extends AbstractTreeTestSupport {
30
31 @Override
32 public String getPackageLocation() {
33 return "com/puppycrawl/tools/checkstyle/grammar/javadoc/";
34 }
35
36 private String getInlineTagsPath(String filename) throws IOException {
37 return getPath("inlinetags" + File.separator + filename);
38 }
39
40 private String getHtmlTagsPath(String filename) throws IOException {
41 return getPath("htmltags" + File.separator + filename);
42 }
43
44 private String getBlockTagsPath(String filename) throws IOException {
45 return getPath("blockTags" + File.separator + filename);
46 }
47
48 @Test
49 public void testEmptyJavadoc() throws Exception {
50 verifyJavadocTree(getPath("ExpectedEmptyJavadoc.txt"),
51 getPath("InputEmptyJavadoc.javadoc"));
52 }
53
54 @Test
55 public void testEmptyJavadocWithTabs() throws Exception {
56 verifyJavadocTree(getPath("ExpectedEmptyJavadocWithTabs.txt"),
57 getPath("InputEmptyJavadocWithTabs.javadoc"));
58 }
59
60 @Test
61 public void testEmptyJavadocStartsWithNewline() throws Exception {
62 verifyJavadocTree(getPath("ExpectedEmptyJavadocStartsWithNewline.txt"),
63 getPath("InputEmptyJavadocStartsWithNewline.javadoc"));
64 }
65
66 @Test
67 public void testSimpleJavadocWithText() throws Exception {
68 verifyJavadocTree(getPath("ExpectedSimpleJavadocWithText.txt"),
69 getPath("InputSimpleJavadocWithText.javadoc"));
70 }
71
72 @Test
73 public void testSimpleJavadocWithText2() throws Exception {
74 verifyJavadocTree(getPath("ExpectedSimpleJavadocWithText2.txt"),
75 getPath("InputSimpleJavadocWithText2.javadoc"));
76 }
77
78 @Test
79 public void testLeadingAsteriskColumnPosition() throws Exception {
80 verifyJavadocTree(getPath("ExpectedLeadingAsteriskColumnPosition.txt"),
81 getPath("InputLeadingAsteriskColumnPosition.javadoc"));
82 }
83
84 @Test
85 public void testDoubleAtAsText() throws Exception {
86 verifyJavadocTree(getPath("ExpectedDoubleAtAsText.txt"),
87 getPath("InputDoubleAtAsText.javadoc"));
88 }
89
90 @Test
91 public void testAuthorTag() throws Exception {
92 verifyJavadocTree(getBlockTagsPath("ExpectedAuthorTag.txt"),
93 getBlockTagsPath("InputAuthorTags.javadoc"));
94 }
95
96 @Test
97 public void testAuthorTagWithLeadingAsterisks() throws Exception {
98 verifyJavadocTree(getBlockTagsPath("ExpectedAuthorTagWithLeadingAsterisks.txt"),
99 getBlockTagsPath("InputAuthorTagWithLeadingAsterisks.javadoc"));
100 }
101
102 @Test
103 public void testCommonBlockTagsWithLeadingAsterisks() throws Exception {
104 verifyJavadocTree(getBlockTagsPath("ExpectedCommonBlockTagsWithLeadingAsterisks.txt"),
105 getBlockTagsPath("InputCommonBlockTagsWithLeadingAsterisks.javadoc"));
106 }
107
108 @Test
109 public void testReferenceBlockTagsWithLeadingAsterisks() throws Exception {
110 verifyJavadocTree(getBlockTagsPath("ExpectedReferenceBlockTagsWithLeadingAsterisks.txt"),
111 getBlockTagsPath("InputReferenceBlockTagsWithLeadingAsterisks.javadoc"));
112 }
113
114 @Test
115 public void testDeprecatedTag() throws Exception {
116 verifyJavadocTree(getBlockTagsPath("ExpectedDeprecatedTag.txt"),
117 getBlockTagsPath("InputDeprecatedTag.javadoc"));
118 }
119
120 @Test
121 public void testReturnTag() throws Exception {
122 verifyJavadocTree(getBlockTagsPath("ExpectedReturnTag.txt"),
123 getBlockTagsPath("InputReturnTag.javadoc"));
124 }
125
126 @Test
127 public void testParamTag() throws Exception {
128 verifyJavadocTree(getBlockTagsPath("ExpectedParamTag.txt"),
129 getBlockTagsPath("InputParamTag.javadoc"));
130 }
131
132 @Test
133 public void testThrowsAndExceptionTag() throws Exception {
134 verifyJavadocTree(getBlockTagsPath("ExpectedThrowsAndExceptionTag.txt"),
135 getBlockTagsPath("InputThrowsAndExceptionTag.javadoc"));
136 }
137
138 @Test
139 public void testSinceAndVersionTag() throws Exception {
140 verifyJavadocTree(getBlockTagsPath("ExpectedSinceAndVersionTag.txt"),
141 getBlockTagsPath("InputSinceAndVersionTag.javadoc"));
142 }
143
144 @Test
145 public void testSeeTag() throws Exception {
146 verifyJavadocTree(getBlockTagsPath("ExpectedSeeTag.txt"),
147 getBlockTagsPath("InputSeeTag.javadoc"));
148 }
149
150 @Test
151 public void testHiddenAndUsesAndProvidesTag() throws Exception {
152 verifyJavadocTree(getBlockTagsPath("ExpectedHiddenAndUsesAndProvidesTag.txt"),
153 getBlockTagsPath("InputHiddenAndUsesAndProvidesTag.javadoc"));
154 }
155
156 @Test
157 public void testSerialTags() throws Exception {
158 verifyJavadocTree(getBlockTagsPath("ExpectedSerialTags.txt"),
159 getBlockTagsPath("InputSerialTags.javadoc"));
160 }
161
162 @Test
163 public void testCustomBlockTag() throws Exception {
164 verifyJavadocTree(getBlockTagsPath("ExpectedCustomBlockTag.txt"),
165 getBlockTagsPath("InputCustomBlockTag.javadoc"));
166 }
167
168 @Test
169 public void testSpecTag() throws Exception {
170 verifyJavadocTree(getBlockTagsPath("ExpectedSpecTag.txt"),
171 getBlockTagsPath("InputSpecTag.javadoc"));
172 }
173
174 @Test
175 public void testCodeInlineTag() throws Exception {
176 verifyJavadocTree(getInlineTagsPath("ExpectedCodeInlineTag.txt"),
177 getInlineTagsPath("InputCodeInlineTag.javadoc"));
178 }
179
180 @Test
181 public void testLinkInlineTag() throws Exception {
182 verifyJavadocTree(getInlineTagsPath("ExpectedLinkInlineTag.txt"),
183 getInlineTagsPath("InputLinkInlineTag.javadoc"));
184 }
185
186 @Test
187 public void testLinkInlineTag2() throws Exception {
188 verifyJavadocTree(getInlineTagsPath("ExpectedLinkInlineTag2.txt"),
189 getInlineTagsPath("InputLinkInlineTag2.javadoc"));
190 }
191
192 @Test
193 public void testLinkInlineTag3() throws Exception {
194 verifyJavadocTree(getInlineTagsPath("ExpectedLinkInlineTag3.txt"),
195 getInlineTagsPath("InputLinkInlineTag3.javadoc"));
196 }
197
198 @Test
199 public void testLinkInlineTagGenericInner() throws Exception {
200 verifyJavadocTree(getInlineTagsPath("ExpectedLinkInlineTagGenericInner.txt"),
201 getInlineTagsPath("InputLinkInlineTagGenericInner.javadoc"));
202 }
203
204 @Test
205 public void testLinkInlineTagWithArrayInitializerLabel() throws Exception {
206 verifyJavadocTree(getInlineTagsPath("ExpectedLinkInlineTagWithArrayInitializerLabel.txt"),
207 getInlineTagsPath("InputLinkInlineTagWithArrayInitializerLabel.javadoc"));
208 }
209
210 @Test
211 public void testLinkInlineTagGenericParameterType() throws Exception {
212 verifyJavadocTree(
213 getInlineTagsPath("ExpectedLinkInlineTagGenericParameterType.txt"),
214 getInlineTagsPath("InputLinkInlineTagGenericParameterType.javadoc"));
215 }
216
217 @Test
218 public void testLinkInlineTagGenericParameterTypeWithWhitespace() throws Exception {
219 verifyJavadocTree(
220 getInlineTagsPath("ExpectedLinkInlineTagGenericParameterTypeWithWhitespace.txt"),
221 getInlineTagsPath("InputLinkInlineTagGenericParameterTypeWithWhitespace.javadoc"));
222 }
223
224 @Test
225 public void testLinkInlineTagUnicode() throws Exception {
226 verifyJavadocTree(getInlineTagsPath("ExpectedLinkInlineTagUnicode.txt"),
227 getInlineTagsPath("InputLinkInlineTagUnicode.javadoc"));
228 }
229
230 @Test
231 public void testValueAndInheritDocInlineTag() throws Exception {
232 verifyJavadocTree(getInlineTagsPath("ExpectedValueAndInheritDocInlineTag.txt"),
233 getInlineTagsPath("InputValueAndInheritDocInlineTag.javadoc"));
234 }
235
236 @Test
237 public void testValueInlineTagWithQuotedFormat() throws Exception {
238 verifyJavadocTree(getInlineTagsPath("ExpectedValueInlineTagWithQuotedFormat.txt"),
239 getInlineTagsPath("InputValueInlineTagWithQuotedFormat.javadoc"));
240 }
241
242 @Test
243 public void testSystemPropertyInlineTag() throws Exception {
244 verifyJavadocTree(getInlineTagsPath("ExpectedSystemPropertyTag.txt"),
245 getInlineTagsPath("InputSystemPropertyTag.javadoc"));
246 }
247
248 @Test
249 public void testLiteralAndCustomInlineTag() throws Exception {
250 verifyJavadocTree(getInlineTagsPath("ExpectedLiteralAndCustomInline.txt"),
251 getInlineTagsPath("InputLiteralAndCustomInline.javadoc"));
252 }
253
254 @Test
255 public void testReturnAndIndexInlineTag() throws Exception {
256 verifyJavadocTree(getInlineTagsPath("ExpectedReturnAndIndexInlineTag.txt"),
257 getInlineTagsPath("InputReturnAndIndexInlineTag.javadoc"));
258 }
259
260 @Test
261 public void testSnippetAttributeInline() throws Exception {
262 verifyJavadocTree(getInlineTagsPath("ExpectedSnippetAttributeInlineTag.txt"),
263 getInlineTagsPath("InputSnippetAttributeInlineTag.javadoc"));
264 }
265
266 @Test
267 public void testSnippetAttributeInline2() throws Exception {
268 verifyJavadocTree(getInlineTagsPath("ExpectedSnippetAttributeInlineTag2.txt"),
269 getInlineTagsPath("InputSnippetAttributeInlineTag2.javadoc"));
270 }
271
272 @Test
273 public void testHtmlElements() throws Exception {
274 verifyJavadocTree(getHtmlTagsPath("ExpectedHtmlElements.txt"),
275 getHtmlTagsPath("InputHtmlElements.javadoc"));
276 }
277
278 @Test
279 public void testHtmlVoidTags() throws Exception {
280 verifyJavadocTree(getHtmlTagsPath("ExpectedHtmlVoidTags.txt"),
281 getHtmlTagsPath("InputHtmlVoidTags.javadoc"));
282 }
283
284 @Test
285 public void testEmptyHtmlContent() throws Exception {
286 verifyJavadocTree(getHtmlTagsPath("ExpectedEmptyHtmlContent.txt"),
287 getHtmlTagsPath("InputEmptyHtmlContent.javadoc"));
288 }
289
290 @Test
291 public void testNonTightTags1() throws Exception {
292 verifyJavadocTree(getHtmlTagsPath("ExpectedNonTightTags1.txt"),
293 getHtmlTagsPath("InputNonTightTags1.javadoc"));
294 }
295
296 @Test
297 public void testNonTightTags2() throws Exception {
298 verifyJavadocTree(getHtmlTagsPath("ExpectedNonTightTags2.txt"),
299 getHtmlTagsPath("InputNonTightTags2.javadoc"));
300 }
301
302 @Test
303 public void testNonTightTags3() throws Exception {
304 verifyJavadocTree(getHtmlTagsPath("ExpectedNonTightTags3.txt"),
305 getHtmlTagsPath("InputNonTightTags3.javadoc"));
306 }
307
308 @Test
309 public void testNonTightTags4() throws Exception {
310 verifyJavadocTree(getHtmlTagsPath("ExpectedNonTightTags4.txt"),
311 getHtmlTagsPath("InputNonTightTags4.javadoc"));
312 }
313
314 @Test
315 public void testJavadocWithoutLeadingAsterisks() throws Exception {
316 verifyJavadocTree(getPath("ExpectedJavadocWithoutLeadingAsterisk.txt"),
317 getPath("InputJavadocWithoutLeadingAsterisk.javadoc"));
318 }
319
320 @Test
321 public void testNewlinesInHtmlAttributes() throws Exception {
322 verifyJavadocTree(getHtmlTagsPath("ExpectedNewlinesInHtmlAttributes.txt"),
323 getHtmlTagsPath("InputNewlinesInHtmlAttributes.javadoc"));
324 }
325
326 @Test
327 public void testCrAsNewLine() throws Exception {
328 verifyJavadocTree(getPath("ExpectedCrAsNewline.txt"),
329 getPath("InputCrAsNewline.javadoc"));
330 }
331
332 @Test
333 public void testHtmlComments() throws Exception {
334 verifyJavadocTree(getHtmlTagsPath("ExpectedHtmlComment.txt"),
335 getHtmlTagsPath("InputHtmlComment.javadoc"));
336 }
337
338 @Test
339 public void testHtmlCommentWithHyphens() throws Exception {
340 verifyJavadocTree(getHtmlTagsPath("ExpectedHtmlCommentWithHyphens.txt"),
341 getHtmlTagsPath("InputHtmlCommentWithHyphens.javadoc"));
342 }
343
344 @Test
345 public void testHtmlAttributeWithLessThan() throws Exception {
346 verifyJavadocTree(getHtmlTagsPath("ExpectedHtmlAttributeWithLessThan.txt"),
347 getHtmlTagsPath("InputHtmlAttributeWithLessThan.javadoc"));
348 }
349
350 @Test
351 public void testHtmlAttributeUnclosedQuote() throws Exception {
352 verifyJavadocTree(getHtmlTagsPath("ExpectedHtmlAttributeUnclosedQuote.txt"),
353 getHtmlTagsPath("InputHtmlAttributeUnclosedQuote.javadoc"));
354 }
355
356 @Test
357 public void testHtmlAttributeUnclosedHrefFollowedByTag() throws Exception {
358 verifyJavadocTree(getHtmlTagsPath("ExpectedHtmlAttributeUnclosedHrefFollowedByTag.txt"),
359 getHtmlTagsPath("InputHtmlAttributeUnclosedHrefFollowedByTag.javadoc"));
360 }
361
362 @Test
363 public void testReferencesToUriFragments() throws Exception {
364 verifyJavadocTree(getPath("ExpectedReferencesToUriFragments.txt"),
365 getPath("InputReferencesToUriFragments.javadoc"));
366 }
367
368 @Test
369 public void testReferencesToUriFragments2() throws Exception {
370 verifyJavadocTree(getPath("ExpectedReferencesToUriFragments2.txt"),
371 getPath("InputReferencesToUriFragments2.javadoc"));
372 }
373
374 @Test
375 public void testMethodReferencesWithoutHash() throws Exception {
376 verifyJavadocTree(getPath("ExpectedMethodReferencesWithoutHash.txt"),
377 getPath("InputMethodReferencesWithoutHash.javadoc"));
378 }
379
380 }