Source code: com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java
1 package com.puppycrawl.tools.checkstyle.checks;
2
3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5
6 public class FinalParametersCheckTest extends BaseCheckTestCase
7 {
8 public void testDefaultTokens()
9 throws Exception
10 {
11 final DefaultConfiguration checkConfig =
12 createCheckConfig(FinalParametersCheck.class);
13 final String[] expected = {
14 "22:26: Parameter s should be final.",
15 "32:26: Parameter s should be final.",
16 "42:17: Parameter s should be final.",
17 "52:17: Parameter s should be final.",
18 "67:38: Parameter e should be final."
19 };
20 verify(checkConfig, getPath("InputFinalParameters.java"), expected);
21 }
22
23 public void testCtorToken()
24 throws Exception
25 {
26 final DefaultConfiguration checkConfig =
27 createCheckConfig(FinalParametersCheck.class);
28 checkConfig.addAttribute("tokens", "CTOR_DEF");
29 final String[] expected = {
30 "22:26: Parameter s should be final.",
31 "32:26: Parameter s should be final.",
32 };
33 verify(checkConfig, getPath("InputFinalParameters.java"), expected);
34 }
35
36 public void testMethodToken()
37 throws Exception
38 {
39 final DefaultConfiguration checkConfig =
40 createCheckConfig(FinalParametersCheck.class);
41 checkConfig.addAttribute("tokens", "METHOD_DEF");
42 final String[] expected = {
43 "42:17: Parameter s should be final.",
44 "52:17: Parameter s should be final.",
45 "67:38: Parameter e should be final."
46 };
47 verify(checkConfig, getPath("InputFinalParameters.java"), expected);
48 }
49
50 }