KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > RequiredRegexpCheckTest


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 RequiredRegexpCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testExistingInDoc()
10             throws Exception JavaDoc
11     {
12         final String JavaDoc required = "Test case file";
13         final DefaultConfiguration checkConfig =
14             createCheckConfig(RequiredRegexpCheck.class);
15         checkConfig.addAttribute("format", required);
16         final String JavaDoc[] expected = {
17         };
18         verify(checkConfig, getPath("InputSemantic.java"), expected);
19     }
20
21     public void testExistingInCode()
22             throws Exception JavaDoc
23     {
24         final String JavaDoc required = "package";
25         final DefaultConfiguration checkConfig =
26             createCheckConfig(RequiredRegexpCheck.class);
27         checkConfig.addAttribute("format", required);
28         final String JavaDoc[] expected = {
29         };
30         verify(checkConfig, getPath("InputSemantic.java"), expected);
31     }
32
33     public void testMissing()
34             throws Exception JavaDoc
35     {
36         final String JavaDoc required = "This text is not in the file";
37         final DefaultConfiguration checkConfig =
38             createCheckConfig(RequiredRegexpCheck.class);
39         checkConfig.addAttribute("format", required);
40         final String JavaDoc[] expected = {
41             "0: Required pattern '" + required + "' missing in file."
42         };
43         verify(checkConfig, getPath("InputSemantic.java"), expected);
44     }
45 }
46
Popular Tags