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