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.checks.javadoc;
21
22 import static com.google.common.truth.Truth.assertWithMessage;
23 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.MSG_EMPTY;
24 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.MSG_EXTRA_HTML;
25 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.MSG_INCOMPLETE_TAG;
26 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.MSG_NO_PERIOD;
27 import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.MSG_UNCLOSED_HTML;
28
29 import java.io.File;
30
31 import org.junit.jupiter.api.Test;
32
33 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
34 import com.puppycrawl.tools.checkstyle.api.TokenTypes;
35 import com.puppycrawl.tools.checkstyle.utils.CommonUtil;
36
37 public class JavadocStyleCheckTest
38 extends AbstractModuleTestSupport {
39
40 @Override
41 protected String getPackageLocation() {
42 return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocstyle";
43 }
44
45 @Test
46 public void testGetAcceptableTokens() {
47 final JavadocStyleCheck javadocStyleCheck = new JavadocStyleCheck();
48
49 final int[] actual = javadocStyleCheck.getAcceptableTokens();
50 final int[] expected = {
51 TokenTypes.ANNOTATION_DEF,
52 TokenTypes.ANNOTATION_FIELD_DEF,
53 TokenTypes.CLASS_DEF,
54 TokenTypes.CTOR_DEF,
55 TokenTypes.ENUM_CONSTANT_DEF,
56 TokenTypes.ENUM_DEF,
57 TokenTypes.INTERFACE_DEF,
58 TokenTypes.METHOD_DEF,
59 TokenTypes.PACKAGE_DEF,
60 TokenTypes.VARIABLE_DEF,
61 TokenTypes.RECORD_DEF,
62 TokenTypes.COMPACT_CTOR_DEF,
63 };
64
65 assertWithMessage("Default acceptable tokens are invalid")
66 .that(actual)
67 .isEqualTo(expected);
68 }
69
70 @Test
71 public void testJavadocStyleDefaultSettingsOne()
72 throws Exception {
73 final String[] expected = {
74 "24: " + getCheckMessage(MSG_NO_PERIOD),
75 "50: " + getCheckMessage(MSG_NO_PERIOD),
76 "62:11: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
77 "65:7: " + getCheckMessage(MSG_EXTRA_HTML, "</td>"),
78 "66:49: " + getCheckMessage(MSG_EXTRA_HTML, "</style>"),
79 "67:19: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>dummy"),
80 "73: " + getCheckMessage(MSG_NO_PERIOD),
81 "74:23: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
82 "80: " + getCheckMessage(MSG_NO_PERIOD),
83 "81:31: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
84 "88: " + getCheckMessage(MSG_NO_PERIOD),
85 "89:31: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"),
86 "90: " + getCheckMessage(MSG_INCOMPLETE_TAG, " * should fail <"),
87 };
88
89 verifyWithInlineConfigParser(
90 getPath("InputJavadocStyleDefaultSettingsOne.java"), expected);
91 }
92
93 @Test
94 public void testJavadocStyleDefaultSettingsTwo()
95 throws Exception {
96 final String[] expected = {
97 "26:39: " + getCheckMessage(MSG_EXTRA_HTML, "</img>"),
98 "72:8: " + getCheckMessage(MSG_UNCLOSED_HTML, "<blockquote>"),
99 "77: " + getCheckMessage(MSG_NO_PERIOD),
100 "112:21: " + getCheckMessage(MSG_EXTRA_HTML, "</string>"),
101 };
102
103 verifyWithInlineConfigParser(
104 getPath("InputJavadocStyleDefaultSettingsTwo.java"), expected);
105 }
106
107 @Test
108 public void testJavadocStyleDefaultSettingsThree()
109 throws Exception {
110 final String[] expected = {
111 "109: " + getCheckMessage(MSG_NO_PERIOD),
112 };
113
114 verifyWithInlineConfigParser(
115 getPath("InputJavadocStyleDefaultSettingsThree.java"), expected);
116 }
117
118 @Test
119 public void testJavadocStyleDefaultSettingsFour()
120 throws Exception {
121 final String[] expected = {
122 "30:33: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>"),
123 "42: " + getCheckMessage(MSG_NO_PERIOD),
124 "49:11: " + getCheckMessage(MSG_UNCLOSED_HTML,
125 "<b>Note:<b> it's unterminated tag.</p>"),
126 "54: " + getCheckMessage(MSG_NO_PERIOD),
127 "59: " + getCheckMessage(MSG_NO_PERIOD),
128 "67: " + getCheckMessage(MSG_NO_PERIOD),
129 "80: " + getCheckMessage(MSG_NO_PERIOD),
130 "94: " + getCheckMessage(MSG_NO_PERIOD),
131 };
132
133 verifyWithInlineConfigParser(
134 getPath("InputJavadocStyleDefaultSettingsFour.java"), expected);
135 }
136
137 @Test
138 public void testJavadocStyleDefaultSettingsFive()
139 throws Exception {
140 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
141
142 verifyWithInlineConfigParser(
143 getPath("InputJavadocStyleDefaultSettingsFive.java"), expected);
144 }
145
146 @Test
147 public void testJavadocStyleFirstSentenceOne() throws Exception {
148 final String[] expected = {
149 "24: " + getCheckMessage(MSG_NO_PERIOD),
150 "50: " + getCheckMessage(MSG_NO_PERIOD),
151 "68: " + getCheckMessage(MSG_NO_PERIOD),
152 "74: " + getCheckMessage(MSG_NO_PERIOD),
153 "80: " + getCheckMessage(MSG_NO_PERIOD),
154 };
155
156 verifyWithInlineConfigParser(
157 getPath("InputJavadocStyleFirstSentenceOne.java"), expected);
158 }
159
160 @Test
161 public void testJavadocStyleFirstSentenceTwo() throws Exception {
162 final String[] expected = {
163 "67: " + getCheckMessage(MSG_NO_PERIOD),
164 "101: " + getCheckMessage(MSG_NO_PERIOD),
165 };
166
167 verifyWithInlineConfigParser(
168 getPath("InputJavadocStyleFirstSentenceTwo.java"), expected);
169 }
170
171 @Test
172 public void testJavadocStyleFirstSentenceThree() throws Exception {
173 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
174
175 verifyWithInlineConfigParser(
176 getPath("InputJavadocStyleFirstSentenceThree.java"), expected);
177 }
178
179 @Test
180 public void testJavadocStyleFirstSentenceFour() throws Exception {
181 final String[] expected = {
182 "40: " + getCheckMessage(MSG_NO_PERIOD),
183 "51: " + getCheckMessage(MSG_NO_PERIOD),
184 "56: " + getCheckMessage(MSG_NO_PERIOD),
185 "64: " + getCheckMessage(MSG_NO_PERIOD),
186 "77: " + getCheckMessage(MSG_NO_PERIOD),
187 "91: " + getCheckMessage(MSG_NO_PERIOD),
188 };
189
190 verifyWithInlineConfigParser(
191 getPath("InputJavadocStyleFirstSentenceFour.java"), expected);
192 }
193
194 @Test
195 public void testJavadocStyleFirstSentenceFormatOne() throws Exception {
196 final String[] expected = {
197 "24: " + getCheckMessage(MSG_NO_PERIOD),
198 "35: " + getCheckMessage(MSG_NO_PERIOD),
199 "41: " + getCheckMessage(MSG_NO_PERIOD),
200 "52: " + getCheckMessage(MSG_NO_PERIOD),
201 "70: " + getCheckMessage(MSG_NO_PERIOD),
202 "76: " + getCheckMessage(MSG_NO_PERIOD),
203 "82: " + getCheckMessage(MSG_NO_PERIOD),
204 };
205
206 verifyWithInlineConfigParser(
207 getPath("InputJavadocStyleFirstSentenceFormatOne.java"), expected);
208 }
209
210 @Test
211 public void testJavadocStyleFirstSentenceFormatTwo() throws Exception {
212 final String[] expected = {
213 "74: " + getCheckMessage(MSG_NO_PERIOD),
214 "108: " + getCheckMessage(MSG_NO_PERIOD),
215 };
216
217 verifyWithInlineConfigParser(
218 getPath("InputJavadocStyleFirstSentenceFormatTwo.java"), expected);
219 }
220
221 @Test
222 public void testJavadocStyleFirstSentenceFormatThree() throws Exception {
223 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
224
225 verifyWithInlineConfigParser(
226 getPath("InputJavadocStyleFirstSentenceFormatThree.java"), expected);
227 }
228
229 @Test
230 public void testJavadocStyleFirstSentenceFormatFour() throws Exception {
231 final String[] expected = {
232 "40: " + getCheckMessage(MSG_NO_PERIOD),
233 "51: " + getCheckMessage(MSG_NO_PERIOD),
234 "56: " + getCheckMessage(MSG_NO_PERIOD),
235 "64: " + getCheckMessage(MSG_NO_PERIOD),
236 "77: " + getCheckMessage(MSG_NO_PERIOD),
237 "91: " + getCheckMessage(MSG_NO_PERIOD),
238 };
239
240 verifyWithInlineConfigParser(
241 getPath("InputJavadocStyleFirstSentenceFormatFour.java"), expected);
242 }
243
244 @Test
245 public void testHtml1() throws Exception {
246 final String[] expected = {
247 "59:11: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
248 "62:7: " + getCheckMessage(MSG_EXTRA_HTML, "</td>"),
249 "63:49: " + getCheckMessage(MSG_EXTRA_HTML, "</style>"),
250 "64:19: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>dummy"),
251 "70:23: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
252 "76:31: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
253 "83:31: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"),
254 "84: " + getCheckMessage(MSG_INCOMPLETE_TAG, " * should fail <"),
255 "99:39: " + getCheckMessage(MSG_EXTRA_HTML, "</img>"),
256 };
257
258 verifyWithInlineConfigParser(
259 getPath("InputJavadocStyleHtml1.java"), expected);
260 }
261
262 @Test
263 public void testHtml2() throws Exception {
264 final String[] expected = {
265 "68:8: " + getCheckMessage(MSG_UNCLOSED_HTML, "<blockquote>"),
266 };
267
268 verifyWithInlineConfigParser(
269 getPath("InputJavadocStyleHtml2.java"), expected);
270 }
271
272 @Test
273 public void testHtml3() throws Exception {
274 final String[] expected = {
275 "103:21: " + getCheckMessage(MSG_EXTRA_HTML, "</string>"),
276 };
277
278 verifyWithInlineConfigParser(
279 getPath("InputJavadocStyleHtml3.java"), expected);
280 }
281
282 @Test
283 public void testHtml4() throws Exception {
284 final String[] expected = {
285 "29:33: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>"),
286 "47:11: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
287 };
288
289 verifyWithInlineConfigParser(
290 getPath("InputJavadocStyleHtml4.java"), expected);
291 }
292
293 @Test
294 public void testHtmlComment() throws Exception {
295 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
296
297 verifyWithInlineConfigParser(
298 getPath("InputJavadocStyleHtmlComment.java"), expected);
299 }
300
301 @Test
302 public void testOnInputWithNoJavadoc1() throws Exception {
303 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
304
305 verifyWithInlineConfigParser(
306 getPath("InputJavadocStyleNoJavadoc1.java"), expected);
307 }
308
309 @Test
310 public void testOnInputWithNoJavadoc2() throws Exception {
311 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
312
313 verifyWithInlineConfigParser(
314 getPath("InputJavadocStyleNoJavadoc2.java"), expected);
315 }
316
317 @Test
318 public void testScopePublic1()
319 throws Exception {
320 final String[] expected = {
321 "78: " + getCheckMessage(MSG_NO_PERIOD),
322 "79:31: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"),
323 "80: " + getCheckMessage(MSG_INCOMPLETE_TAG, " * should fail <"),
324 };
325
326 verifyWithInlineConfigParser(
327 getPath("InputJavadocStyleScopePublic1.java"), expected);
328 }
329
330 @Test
331 public void testScopePublic2()
332 throws Exception {
333 final String[] expected = {
334 "83: " + getCheckMessage(MSG_EMPTY),
335 "102: " + getCheckMessage(MSG_EMPTY),
336 "108: " + getCheckMessage(MSG_NO_PERIOD),
337 };
338
339 verifyWithInlineConfigParser(
340 getPath("InputJavadocStyleScopePublic2.java"), expected);
341 }
342
343 @Test
344 public void testScopePublic3()
345 throws Exception {
346 final String[] expected = {
347 "104:21: " + getCheckMessage(MSG_EXTRA_HTML, "</string>"),
348 };
349
350 verifyWithInlineConfigParser(
351 getPath("InputJavadocStyleScopePublic3.java"), expected);
352 }
353
354 @Test
355 public void testScopePublic4()
356 throws Exception {
357 final String[] expected = {
358 "51: " + getCheckMessage(MSG_NO_PERIOD),
359 "56: " + getCheckMessage(MSG_NO_PERIOD),
360 "89: " + getCheckMessage(MSG_NO_PERIOD),
361 };
362
363 verifyWithInlineConfigParser(
364 getPath("InputJavadocStyleScopePublic4.java"), expected);
365 }
366
367 @Test
368 public void testScopeProtected1()
369 throws Exception {
370 final String[] expected = {
371 "67: " + getCheckMessage(MSG_NO_PERIOD),
372 "68:23: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
373 "80: " + getCheckMessage(MSG_NO_PERIOD),
374 "81:31: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"),
375 "82: " + getCheckMessage(MSG_INCOMPLETE_TAG, " * should fail <"),
376 };
377
378 verifyWithInlineConfigParser(
379 getPath("InputJavadocStyleScopeProtected1.java"), expected);
380 }
381
382 @Test
383 public void testScopeProtected2()
384 throws Exception {
385 final String[] expected = {
386 "83: " + getCheckMessage(MSG_EMPTY),
387 "87: " + getCheckMessage(MSG_EMPTY),
388 "102: " + getCheckMessage(MSG_EMPTY),
389 "108: " + getCheckMessage(MSG_NO_PERIOD),
390 };
391
392 verifyWithInlineConfigParser(
393 getPath("InputJavadocStyleScopeProtected2.java"), expected);
394 }
395
396 @Test
397 public void testScopeProtected3()
398 throws Exception {
399 final String[] expected = {
400 "104:21: " + getCheckMessage(MSG_EXTRA_HTML, "</string>"),
401 };
402
403 verifyWithInlineConfigParser(
404 getPath("InputJavadocStyleScopeProtected3.java"), expected);
405 }
406
407 @Test
408 public void testScopeProtected4()
409 throws Exception {
410 final String[] expected = {
411 "51: " + getCheckMessage(MSG_NO_PERIOD),
412 "56: " + getCheckMessage(MSG_NO_PERIOD),
413 "89: " + getCheckMessage(MSG_NO_PERIOD),
414 };
415
416 verifyWithInlineConfigParser(
417 getPath("InputJavadocStyleScopeProtected4.java"), expected);
418 }
419
420 @Test
421 public void testScopePackage1()
422 throws Exception {
423 final String[] expected = {
424 "67: " + getCheckMessage(MSG_NO_PERIOD),
425 "68:24: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
426 "74: " + getCheckMessage(MSG_NO_PERIOD),
427 "75:32: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
428 "82: " + getCheckMessage(MSG_NO_PERIOD),
429 "83:32: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"),
430 "84: " + getCheckMessage(MSG_INCOMPLETE_TAG, " * should fail <"),
431 };
432
433 verifyWithInlineConfigParser(
434 getPath("InputJavadocStyleScopePackage1.java"), expected);
435 }
436
437 @Test
438 public void testScopePackage2()
439 throws Exception {
440 final String[] expected = {
441 "83: " + getCheckMessage(MSG_EMPTY),
442 "87: " + getCheckMessage(MSG_EMPTY),
443 "92: " + getCheckMessage(MSG_EMPTY),
444 "102: " + getCheckMessage(MSG_EMPTY),
445 "108: " + getCheckMessage(MSG_NO_PERIOD),
446 };
447
448 verifyWithInlineConfigParser(
449 getPath("InputJavadocStyleScopePackage2.java"), expected);
450 }
451
452 @Test
453 public void testScopePackage3()
454 throws Exception {
455 final String[] expected = {
456 "104:21: " + getCheckMessage(MSG_EXTRA_HTML, "</string>"),
457 };
458
459 verifyWithInlineConfigParser(
460 getPath("InputJavadocStyleScopePackage3.java"), expected);
461 }
462
463 @Test
464 public void testScopePackage4()
465 throws Exception {
466 final String[] expected = {
467 "51: " + getCheckMessage(MSG_NO_PERIOD),
468 "56: " + getCheckMessage(MSG_NO_PERIOD),
469 "64: " + getCheckMessage(MSG_NO_PERIOD),
470 "77: " + getCheckMessage(MSG_NO_PERIOD),
471 "91: " + getCheckMessage(MSG_NO_PERIOD),
472 };
473
474 verifyWithInlineConfigParser(
475 getPath("InputJavadocStyleScopePackage4.java"), expected);
476 }
477
478 @Test
479 public void testEmptyJavadoc1() throws Exception {
480 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
481
482 verifyWithInlineConfigParser(
483 getPath("InputJavadocStyleEmptyJavadoc1.java"), expected);
484 }
485
486 @Test
487 public void testEmptyJavadoc2() throws Exception {
488 final String[] expected = {
489 "75: " + getCheckMessage(MSG_EMPTY),
490 "79: " + getCheckMessage(MSG_EMPTY),
491 "84: " + getCheckMessage(MSG_EMPTY),
492 "90: " + getCheckMessage(MSG_EMPTY),
493 "95: " + getCheckMessage(MSG_EMPTY),
494 };
495
496 verifyWithInlineConfigParser(
497 getPath("InputJavadocStyleEmptyJavadoc2.java"), expected);
498 }
499
500 @Test
501 public void testEmptyJavadoc3() throws Exception {
502 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
503
504 verifyWithInlineConfigParser(
505 getPath("InputJavadocStyleEmptyJavadoc3.java"), expected);
506 }
507
508 @Test
509 public void testEmptyJavadoc4() throws Exception {
510 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
511
512 verifyWithInlineConfigParser(
513 getPath("InputJavadocStyleEmptyJavadoc4.java"), expected);
514 }
515
516 @Test
517 public void testExcludeScope1()
518 throws Exception {
519 final String[] expected = {
520 "24: " + getCheckMessage(MSG_NO_PERIOD),
521 "50: " + getCheckMessage(MSG_NO_PERIOD),
522 "62:11: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
523 "65:7: " + getCheckMessage(MSG_EXTRA_HTML, "</td>"),
524 "66:49: " + getCheckMessage(MSG_EXTRA_HTML, "</style>"),
525 "67:19: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>dummy"),
526 "78: " + getCheckMessage(MSG_NO_PERIOD),
527 "79:31: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
528 "100:39: " + getCheckMessage(MSG_EXTRA_HTML, "</img>"),
529 };
530
531 verifyWithInlineConfigParser(
532 getPath("InputJavadocStyleExcludeScope1.java"), expected);
533 }
534
535 @Test
536 public void testExcludeScope2()
537 throws Exception {
538 final String[] expected = {
539 "69:8: " + getCheckMessage(MSG_UNCLOSED_HTML, "<blockquote>"),
540 "75: " + getCheckMessage(MSG_NO_PERIOD),
541 };
542
543 verifyWithInlineConfigParser(
544 getPath("InputJavadocStyleExcludeScope2.java"), expected);
545 }
546
547 @Test
548 public void testExcludeScope3()
549 throws Exception {
550 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
551
552 verifyWithInlineConfigParser(
553 getPath("InputJavadocStyleExcludeScope3.java"), expected);
554 }
555
556 @Test
557 public void testExcludeScope4()
558 throws Exception {
559 final String[] expected = {
560 "30:33: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>"),
561 "42: " + getCheckMessage(MSG_NO_PERIOD),
562 "49:11: " + getCheckMessage(MSG_UNCLOSED_HTML,
563 "<b>Note:<b> it's unterminated tag.</p>"),
564 "65: " + getCheckMessage(MSG_NO_PERIOD),
565 "78: " + getCheckMessage(MSG_NO_PERIOD),
566 };
567
568 verifyWithInlineConfigParser(
569 getPath("InputJavadocStyleExcludeScope4.java"), expected);
570 }
571
572 @Test
573 public void packageInfoInheritDoc() throws Exception {
574 final String[] expected = {
575 "16: " + getCheckMessage(MSG_NO_PERIOD),
576 };
577
578 verifyWithInlineConfigParser(
579 getPath("pkginfo" + File.separator + "invalidinherit" + File.separator
580 + "package-info.java"),
581 expected);
582 }
583
584 @Test
585 public void packageInfoInvalid() throws Exception {
586 final String[] expected = {
587 "17: " + getCheckMessage(MSG_NO_PERIOD),
588 };
589
590 verifyWithInlineConfigParser(
591 getPath("pkginfo" + File.separator + "invalidformat" + File.separator
592 + "package-info.java"),
593 expected);
594 }
595
596 @Test
597 public void packageInfoAnnotation() throws Exception {
598 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
599
600 verifyWithInlineConfigParser(
601 getPath("pkginfo" + File.separator + "annotation" + File.separator
602 + "package-info.java"),
603 expected);
604 }
605
606 @Test
607 public void packageInfoMissing() throws Exception {
608 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
609
610 verifyWithInlineConfigParser(
611 getPath("bothfiles" + File.separator + "package-info.java"),
612 expected);
613 }
614
615 @Test
616 public void packageInfoMissingPeriod() throws Exception {
617 final String[] expected = {
618 "16: " + getCheckMessage(MSG_NO_PERIOD),
619 };
620
621 verifyWithInlineConfigParser(
622 getPath("missingperiod" + File.separator + "package-info.java"),
623 expected);
624 }
625
626 @Test
627 public void testNothing() throws Exception {
628 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
629
630 verifyWithInlineConfigParser(
631 getPath("InputJavadocStyleNothing.java"),
632 expected);
633 }
634
635 @Test
636 public void packageInfoValid() throws Exception {
637 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
638
639 verifyWithInlineConfigParser(
640 getPath("pkginfo" + File.separator + "valid"
641 + File.separator + "package-info.java"),
642 expected);
643 }
644
645 @Test
646 public void testRestrictedTokenSet1()
647 throws Exception {
648 final String[] expected = {
649 "74: " + getCheckMessage(MSG_NO_PERIOD),
650 };
651
652 verifyWithInlineConfigParser(
653 getPath("InputJavadocStyleRestrictedTokenSet1.java"), expected);
654 }
655
656 @Test
657 public void testRestrictedTokenSet2()
658 throws Exception {
659 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
660
661 verifyWithInlineConfigParser(
662 getPath("InputJavadocStyleRestrictedTokenSet2.java"), expected);
663 }
664
665 @Test
666 public void testRestrictedTokenSet3()
667 throws Exception {
668 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
669
670 verifyWithInlineConfigParser(
671 getPath("InputJavadocStyleRestrictedTokenSet3.java"), expected);
672 }
673
674 @Test
675 public void testRestrictedTokenSet4()
676 throws Exception {
677 final String[] expected = {
678 "53: " + getCheckMessage(MSG_NO_PERIOD),
679 "86: " + getCheckMessage(MSG_NO_PERIOD),
680 };
681
682 verifyWithInlineConfigParser(
683 getPath("InputJavadocStyleRestrictedTokenSet4.java"), expected);
684 }
685
686 @Test
687 public void testJavadocStyleRecordsAndCompactCtors() throws Exception {
688 final String[] expected = {
689 "24: " + getCheckMessage(MSG_NO_PERIOD),
690 "45: " + getCheckMessage(MSG_NO_PERIOD),
691 "58:16: " + getCheckMessage(MSG_UNCLOSED_HTML, "<b>"),
692 "61:12: " + getCheckMessage(MSG_EXTRA_HTML, "</td>"),
693 "62:54: " + getCheckMessage(MSG_EXTRA_HTML, "</style>"),
694 "64:24: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>dummy"),
695 "79: " + getCheckMessage(MSG_NO_PERIOD),
696 "80:36: " + getCheckMessage(MSG_EXTRA_HTML, "</code>"),
697 "81: " + getCheckMessage(MSG_INCOMPLETE_TAG, " * should fail <"),
698 "97:37: " + getCheckMessage(MSG_UNCLOSED_HTML, "<code>"),
699 "113: " + getCheckMessage(MSG_NO_PERIOD),
700 };
701
702 verifyWithInlineConfigParser(
703 getNonCompilablePath("InputJavadocStyleRecordsAndCompactCtors.java"),
704 expected);
705 }
706
707 @Test
708 public void testHtmlTagToString() {
709 final HtmlTag tag = new HtmlTag("id", 3, 5, true, false, "<a href=\"URL\"/>");
710 assertWithMessage("Invalid toString result")
711 .that(tag.toString())
712 .isEqualTo("HtmlTag[id='id', lineNo=3, position=5, text='<a href=\"URL\"/>', "
713 + "closedTag=true, incompleteTag=false]");
714 }
715
716 @Test
717 public void testNeverEndingXmlCommentInsideJavadoc() throws Exception {
718 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
719
720 verifyWithInlineConfigParser(
721 getPath("InputJavadocStyleNeverEndingXmlComment.java"), expected);
722 }
723
724 @Test
725 public void testInterfaceMemberScopeIsPublic()
726 throws Exception {
727 final String[] expected = {
728 "21: " + getCheckMessage(MSG_EMPTY),
729 "25: " + getCheckMessage(MSG_EMPTY),
730 };
731
732 verifyWithInlineConfigParser(
733 getPath("InputJavadocStyleInterfaceMemberScopeIsPublic.java"),
734 expected);
735 }
736
737 @Test
738 public void testEnumCtorScopeIsPrivate()
739 throws Exception {
740 final String[] expected = {
741 "21: " + getCheckMessage(MSG_EMPTY),
742 "25: " + getCheckMessage(MSG_EMPTY),
743 "34: " + getCheckMessage(MSG_EMPTY),
744 };
745
746 verifyWithInlineConfigParser(
747 getPath("InputJavadocStyleEnumCtorScopeIsPrivate.java"),
748 expected);
749 }
750
751 @Test
752 public void testLowerCasePropertyForTag() throws Exception {
753 final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
754
755 verifyWithInlineConfigParser(
756 getPath("InputJavadocStyleCheckOptionLowercaseProperty.java"), expected);
757 }
758
759 @Test
760 public void testJavadocTag() throws Exception {
761 final String[] expected = {
762 "11: " + getCheckMessage(MSG_NO_PERIOD),
763 "15: " + getCheckMessage(MSG_NO_PERIOD),
764 };
765
766 verifyWithInlineConfigParser(
767 getPath("InputJavadocStyleDefault4.java"),
768 expected);
769 }
770
771 @Test
772 public void testJavadocTag2() throws Exception {
773 final String[] expected = {
774 "16: " + getCheckMessage(MSG_NO_PERIOD),
775 "18:16: " + getCheckMessage(MSG_UNCLOSED_HTML,
776 "<AREA ALT=\"alt\" Coordination=\"100,0,200,50\" HREF=\"/href/\"> <"),
777 };
778
779 verifyWithInlineConfigParser(
780 getPath("InputJavadocStyleCheck1.java"),
781 expected);
782 }
783
784 @Test
785 public void testJavadocTag3() throws Exception {
786 final String[] expected = {
787 "21:4: " + getCheckMessage(MSG_EXTRA_HTML, "</body>"),
788 };
789
790 verifyWithInlineConfigParser(
791 getPath("InputJavadocStyleCheck2.java"),
792 expected);
793 }
794
795 @Test
796 public void testJavadocStyleCheck3() throws Exception {
797 final String[] expected = {
798 "11: " + getCheckMessage(MSG_NO_PERIOD),
799 };
800
801 verifyWithInlineConfigParser(
802 getPath("InputJavadocStyleCheck3.java"),
803 expected);
804 }
805
806 @Test
807 public void testJavadocStyleCheck4() throws Exception {
808 final String[] expected = {
809 "12: " + getCheckMessage(MSG_NO_PERIOD),
810 };
811
812 verifyWithInlineConfigParser(
813 getPath("InputJavadocStyleCheck5.java"),
814 expected);
815 }
816 }