KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > sizes > ExecutableStatementCountCheckTest


1 package com.puppycrawl.tools.checkstyle.checks.sizes;
2
3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5
6 public class ExecutableStatementCountCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testMaxZero() throws Exception JavaDoc
10     {
11         final DefaultConfiguration checkConfig =
12             createCheckConfig(ExecutableStatementCountCheck.class);
13
14         checkConfig.addAttribute("max", "0");
15
16         final String JavaDoc[] expected = {
17             "4:5: Executable statement count is 3 (max allowed is 0).",
18             "7:17: Executable statement count is 1 (max allowed is 0).",
19             "17:5: Executable statement count is 2 (max allowed is 0).",
20             "27:5: Executable statement count is 1 (max allowed is 0).",
21             "34:5: Executable statement count is 3 (max allowed is 0).",
22             "48:5: Executable statement count is 2 (max allowed is 0).",
23             "58:5: Executable statement count is 2 (max allowed is 0).",
24             "67:5: Executable statement count is 2 (max allowed is 0).",
25             "76:5: Executable statement count is 2 (max allowed is 0).",
26             "79:13: Executable statement count is 1 (max allowed is 0).",
27         };
28
29         verify(checkConfig, getPath("ComplexityCheckTestInput.java"), expected);
30     }
31     
32     public void testMethodDef() throws Exception JavaDoc
33     {
34         final DefaultConfiguration checkConfig =
35             createCheckConfig(ExecutableStatementCountCheck.class);
36
37         checkConfig.addAttribute("max", "0");
38         checkConfig.addAttribute("tokens", "METHOD_DEF");
39
40         final String JavaDoc[] expected = {
41             "4:5: Executable statement count is 3 (max allowed is 0).",
42             "7:17: Executable statement count is 1 (max allowed is 0).",
43             "17:5: Executable statement count is 2 (max allowed is 0).",
44             "27:5: Executable statement count is 1 (max allowed is 0).",
45             "34:5: Executable statement count is 3 (max allowed is 0).",
46             "79:13: Executable statement count is 1 (max allowed is 0).",
47         };
48
49         verify(checkConfig, getPath("ComplexityCheckTestInput.java"), expected);
50     }
51     
52     public void testCtorDef() throws Exception JavaDoc
53     {
54         final DefaultConfiguration checkConfig =
55             createCheckConfig(ExecutableStatementCountCheck.class);
56
57         checkConfig.addAttribute("max", "0");
58         checkConfig.addAttribute("tokens", "CTOR_DEF");
59
60         final String JavaDoc[] expected = {
61             "48:5: Executable statement count is 2 (max allowed is 0).",
62             "76:5: Executable statement count is 2 (max allowed is 0).",
63         };
64
65         verify(checkConfig, getPath("ComplexityCheckTestInput.java"), expected);
66     }
67     
68     public void testStaticInit() throws Exception JavaDoc
69     {
70         final DefaultConfiguration checkConfig =
71             createCheckConfig(ExecutableStatementCountCheck.class);
72
73         checkConfig.addAttribute("max", "0");
74         checkConfig.addAttribute("tokens", "STATIC_INIT");
75
76         final String JavaDoc[] expected = {
77             "58:5: Executable statement count is 2 (max allowed is 0).",
78         };
79
80         verify(checkConfig, getPath("ComplexityCheckTestInput.java"), expected);
81     }
82     
83     public void testInstanceInit() throws Exception JavaDoc
84     {
85         final DefaultConfiguration checkConfig =
86             createCheckConfig(ExecutableStatementCountCheck.class);
87
88         checkConfig.addAttribute("max", "0");
89         checkConfig.addAttribute("tokens", "INSTANCE_INIT");
90
91         final String JavaDoc[] expected = {
92             "67:5: Executable statement count is 2 (max allowed is 0).",
93         };
94
95         verify(checkConfig, getPath("ComplexityCheckTestInput.java"), expected);
96     }
97 }
Popular Tags