KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > coding > FinalLocalVariableCheckTest


1 package com.puppycrawl.tools.checkstyle.checks.coding;
2
3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5
6 public class FinalLocalVariableCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testDefault() throws Exception JavaDoc
10     {
11         final DefaultConfiguration checkConfig =
12             createCheckConfig(FinalLocalVariableCheck.class);
13         
14         final String JavaDoc[] expected = {
15             "9:13: Variable 'i' should be declared final.",
16             "9:16: Variable 'j' should be declared final.",
17             "10:18: Variable 'runnable' should be declared final.",
18             "20:13: Variable 'i' should be declared final.",
19             "24:13: Variable 'z' should be declared final.",
20             "26:16: Variable 'obj' should be declared final.",
21             "30:16: Variable 'x' should be declared final.",
22             "36:18: Variable 'runnable' should be declared final.",
23             "40:21: Variable 'q' should be declared final.",
24             "56:13: Variable 'i' should be declared final.",
25             "60:13: Variable 'z' should be declared final.",
26             "62:16: Variable 'obj' should be declared final.",
27             "66:16: Variable 'x' should be declared final.",
28             "74:21: Variable 'w' should be declared final.",
29             "75:26: Variable 'runnable' should be declared final.",
30             "88:18: Variable 'i' should be declared final.",
31             "96:17: Variable 'weird' should be declared final.",
32             "97:17: Variable 'j' should be declared final.",
33             "98:17: Variable 'k' should be declared final.",
34         };
35         verify(checkConfig, getPath("coding/InputFinalLocalVariable.java"), expected);
36     }
37
38     public void testParameter() throws Exception JavaDoc
39     {
40         final DefaultConfiguration checkConfig =
41             createCheckConfig(FinalLocalVariableCheck.class);
42         checkConfig.addAttribute("tokens", "PARAMETER_DEF");
43         
44         final String JavaDoc[] expected = {
45             "45:28: Variable 'aArg' should be declared final.",
46             "149:36: Variable '_o' should be declared final.",
47             "154:37: Variable '_o1' should be declared final.",
48         };
49         verify(checkConfig, getPath("coding/InputFinalLocalVariable.java"), expected);
50     }
51 }
52
Popular Tags