View Javadoc
1   package com.github.sevntu.checkstyle.checks.coding;
2   
3   import com.github.sevntu.checkstyle.BaseCheckTestSupport;
4   import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5   import org.junit.Test;
6   
7   public class InputAvoidModifiersForTypesCheck2 extends BaseCheckTestSupport
8   {
9   	@Test
10      public void testSimple()
11          throws Exception
12      {
13          final DefaultConfiguration checkConfig =
14              createCheckConfig(LineLengthCheck.class);
15          checkConfig.addAttribute("max", "80");
16          checkConfig.addAttribute("ignorePattern",  "^.*is OK.*regexp.*$");
17          final String[] expected = {
18              "18: Line is longer than 80 characters.",
19              "145: Line is longer than 80 characters.",
20          };
21          verify(checkConfig, getPath("InputSimple.java"), expected);
22      }
23  
24      @Test
25      public void testSimpleIgnore()
26          throws Exception
27      {
28          final DefaultConfiguration checkConfig =
29              createCheckConfig(LineLengthCheck.class);
30          checkConfig.addAttribute("max", "40");
31          checkConfig.addAttribute("ignorePattern",  "^.*is OK.*regexp.*$");
32          final String[] expected = {
33              "1: Line is longer than 40 characters.",
34              "5: Line is longer than 40 characters.",
35              "6: Line is longer than 40 characters.",
36              "18: Line is longer than 40 characters.",
37              "101: Line is longer than 40 characters.",
38              "125: Line is longer than 40 characters.",
39              "128: Line is longer than 40 characters.",
40              "132: Line is longer than 40 characters.",
41              "145: Line is longer than 40 characters.",
42              "146: Line is longer than 40 characters.",
43              "148: Line is longer than 40 characters.",
44              "151: Line is longer than 40 characters.",
45              "152: Line is longer than 40 characters.",
46              "192: Line is longer than 40 characters.",
47              "200: Line is longer than 40 characters.",
48              "207: Line is longer than 40 characters.",
49          };
50          checkConfig.addAttribute("ignoreClass", "true");
51          checkConfig.addAttribute("ignoreConstructor", "true");
52          checkConfig.addAttribute("ignoreField", "true");
53          checkConfig.addAttribute("ignoreMethod", "true");
54          //System.setProperty("testinputs.dir", "/home/romani/Practice/New_workspace/sevntu.checkstyle/src/testinputs/com/puppycrawl/tools/checkstyle/sizes");
55          verify(checkConfig, getPath("InputSimple.java"), expected);
56      }
57      
58      class LineLengthCheck {
59          
60      }
61      
62  }