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.blocks;
21
22 import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyCatchBlockCheck.MSG_KEY_CATCH_BLOCK_EMPTY;
23
24 import org.junit.jupiter.api.Test;
25
26 import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport;
27
28 public class EmptyCatchBlockCheckExamplesTest extends AbstractExamplesModuleTestSupport {
29 @Override
30 protected String getPackageLocation() {
31 return "com/puppycrawl/tools/checkstyle/checks/blocks/emptycatchblock";
32 }
33
34 @Test
35 public void testExample1() throws Exception {
36 final String[] expected = {
37 "16:41: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
38 "31:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
39 };
40
41 verifyWithInlineConfigParser(getPath("Example1.java"), expected);
42 }
43
44 @Test
45 public void testExample2() throws Exception {
46 final String[] expected = {
47 "33:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
48 };
49
50 verifyWithInlineConfigParser(getPath("Example2.java"), expected);
51 }
52
53 @Test
54 public void testExample3() throws Exception {
55 final String[] expected = {
56 "18:41: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
57 "25:39: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
58 "33:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
59 };
60
61 verifyWithInlineConfigParser(getPath("Example3.java"), expected);
62 }
63
64 @Test
65 public void testExample4() throws Exception {
66 final String[] expected = {
67 "51:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
68 };
69
70 verifyWithInlineConfigParser(getPath("Example4.java"), expected);
71 }
72
73 @Test
74 public void testExample5() throws Exception {
75 final String[] expected = {
76 "18:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY),
77 };
78
79 verifyWithInlineConfigParser(getPath("Example5.java"), expected);
80 }
81 }