KickJava   Java API By Example, From Geeks To Geeks.

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


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 OneMethodPrivateFieldCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testDefault() throws Exception JavaDoc
10     {
11         final DefaultConfiguration checkConfig =
12             createCheckConfig(OneMethodPrivateFieldCheck.class);
13         final String JavaDoc[] expected = {
14             "6:24: Field 'SFIELD0' is used in only one method.",
15             "7:24: Field 'SFIELD1' is used in only one method.",
16             "8:24: Field 'SFIELD2' is used in only one method.",
17             "9:24: Field 'SFIELD3' is used in only one method.",
18             "11:17: Field 'mField0' is used in only one method.",
19             "12:17: Field 'mField1' is used in only one method.",
20             "13:17: Field 'mField2' is used in only one method.",
21             "47:17: Field 'mField0' is used in only one method.",
22             "48:17: Field 'mField1' is used in only one method.",
23             "49:17: Field 'mField2' is used in only one method.",
24             "105:19: Field 'mField' is used in only one method.",
25         };
26         verify(checkConfig, getPath("usage/InputOneMethodPrivateField.java"), expected);
27     }
28     
29     public void testIgnoreFormat() throws Exception JavaDoc
30         {
31             final DefaultConfiguration checkConfig =
32                 createCheckConfig(OneMethodPrivateFieldCheck.class);
33             checkConfig.addAttribute("ignoreFormat", "2$");
34             final String JavaDoc[] expected = {
35                 "6:24: Field 'SFIELD0' is used in only one method.",
36                 "7:24: Field 'SFIELD1' is used in only one method.",
37                 "9:24: Field 'SFIELD3' is used in only one method.",
38                 "11:17: Field 'mField0' is used in only one method.",
39                 "12:17: Field 'mField1' is used in only one method.",
40                 "47:17: Field 'mField0' is used in only one method.",
41                 "48:17: Field 'mField1' is used in only one method.",
42                 "105:19: Field 'mField' is used in only one method.",
43              };
44             verify(checkConfig, getPath("usage/InputOneMethodPrivateField.java"), expected);
45         }
46 }
47
Popular Tags