KickJava   Java API By Example, From Geeks To Geeks.

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


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