Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/puppycrawl/tools/checkstyle/checks/FileLengthCheckTest.java


1   package com.puppycrawl.tools.checkstyle.checks;
2   
3   import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4   import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5   import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
6   
7   public class FileLengthCheckTest
8       extends BaseCheckTestCase
9   {
10      private void runIt(String aMax, String[] aExpected) throws Exception
11      {
12          final DefaultConfiguration checkConfig =
13              createCheckConfig(FileLengthCheck.class);
14          checkConfig.addAttribute("max", aMax);
15          verify(checkConfig, getPath("InputSimple.java"), aExpected);
16      }
17  
18      public void testAlarm() throws Exception
19      {
20          final String[] expected = {
21              "1: File length is 198 lines (max allowed is 20)."
22          };
23          runIt("20", expected);
24      }
25  
26      public void testOK() throws Exception
27      {
28          final String[] expected = {
29          };
30          runIt("2000", expected);
31      }
32  
33      public void testArgs() throws Exception
34      {
35          final DefaultConfiguration checkConfig =
36              createCheckConfig(FileLengthCheck.class);
37          try {
38              checkConfig.addAttribute("max", "abc");
39              createChecker(checkConfig);
40              fail("Should indicate illegal args");
41          }
42          catch (CheckstyleException ex)
43          {
44              // Expected Exception because of illegal argument for "max"
45          }
46      }
47  
48  
49  }