KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > usage > UnusedParameterCheckTest


1 package com.puppycrawl.tools.checkstyle.checks.usage;
2
3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5
6 public class UnusedParameterCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testDefault() throws Exception JavaDoc
10     {
11         final DefaultConfiguration checkConfig =
12             createCheckConfig(UnusedParameterCheck.class);
13         final String JavaDoc[] expected = {
14             "8:57: Unused parameter 'aUnreadPrimitive'.",
15             "16:16: Unused parameter 'aUnreadObject'.",
16             "29:66: Unused parameter 'aUnreadArray'.",
17         };
18         verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
19     }
20     
21     public void testException() throws Exception JavaDoc
22     {
23         final DefaultConfiguration checkConfig =
24             createCheckConfig(UnusedParameterCheck.class);
25         checkConfig.addAttribute("ignoreCatch", Boolean.FALSE.toString());
26         final String JavaDoc[] expected = {
27             "8:57: Unused parameter 'aUnreadPrimitive'.",
28             "16:16: Unused parameter 'aUnreadObject'.",
29             "25:26: Unused parameter 'unreadException'.",
30             "29:66: Unused parameter 'aUnreadArray'.",
31         };
32         verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
33     }
34     
35     public void testIgnoreFormat() throws Exception JavaDoc
36     {
37         final DefaultConfiguration checkConfig =
38             createCheckConfig(UnusedParameterCheck.class);
39         checkConfig.addAttribute("ignoreFormat", "Array$");
40         final String JavaDoc[] expected = {
41             "8:57: Unused parameter 'aUnreadPrimitive'.",
42             "16:16: Unused parameter 'aUnreadObject'.",
43         };
44         verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
45     }
46
47     public void testIgnoreNonLocal() throws Exception JavaDoc
48     {
49         final DefaultConfiguration checkConfig =
50             createCheckConfig(UnusedParameterCheck.class);
51         checkConfig.addAttribute("ignoreNonLocal", "true");
52         final String JavaDoc[] expected = {
53             "8:57: Unused parameter 'aUnreadPrimitive'.",
54             "29:66: Unused parameter 'aUnreadArray'.",
55         };
56         verify(checkConfig, getPath("usage/InputUnusedParameter.java"), expected);
57     }
58 }
59
Popular Tags