KickJava   Java API By Example, From Geeks To Geeks.

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


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 UnusedLocalVariableCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testDefault() throws Exception JavaDoc
10     {
11         final DefaultConfiguration checkConfig =
12             createCheckConfig(UnusedLocalVariableCheck.class);
13         final String JavaDoc[] expected = {
14             "13:13: Unused local variable 'mUnreadPrimitive'.",
15             "24:16: Unused local variable 'unreadObject'.",
16             "36:15: Unused local variable 'unreadArray'.",
17             "45:13: Unused local variable 'java'.",
18         };
19         verify(checkConfig, getPath("usage/InputUnusedLocal.java"), expected);
20     }
21     
22     public void testIgnoreFormat() throws Exception JavaDoc
23         {
24             final DefaultConfiguration checkConfig =
25                 createCheckConfig(UnusedLocalVariableCheck.class);
26             checkConfig.addAttribute("ignoreFormat", "Array$");
27             final String JavaDoc[] expected = {
28                 "13:13: Unused local variable 'mUnreadPrimitive'.",
29                 "24:16: Unused local variable 'unreadObject'.",
30                 "45:13: Unused local variable 'java'.",
31             };
32             verify(checkConfig, getPath("usage/InputUnusedLocal.java"), expected);
33         }
34 }
35
Popular Tags