KickJava   Java API By Example, From Geeks To Geeks.

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


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 IllegalTokenTextCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testCaseSensitive()
10         throws Exception JavaDoc
11     {
12         final DefaultConfiguration checkConfig =
13             createCheckConfig(IllegalTokenTextCheck.class);
14         checkConfig.addAttribute("tokens", "STRING_LITERAL");
15         checkConfig.addAttribute("format", "a href");
16         final String JavaDoc[] expected = {
17             "24:28: Token text matches the illegal pattern 'a href'.",
18         };
19         verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
20     }
21     
22     public void testCaseInSensitive()
23         throws Exception JavaDoc
24     {
25         final DefaultConfiguration checkConfig =
26             createCheckConfig(IllegalTokenTextCheck.class);
27         checkConfig.addAttribute("tokens", "STRING_LITERAL");
28         checkConfig.addAttribute("format", "a href");
29         checkConfig.addAttribute("ignoreCase", "true");
30         final String JavaDoc[] expected = {
31             "24:28: Token text matches the illegal pattern 'a href'.",
32             "25:32: Token text matches the illegal pattern 'a href'.",
33         };
34         verify(checkConfig, getPath("InputIllegalTokens.java"), expected);
35     }
36 }
37
38
Popular Tags