KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > imports > AvoidStarImportTest


1 package com.puppycrawl.tools.checkstyle.checks.imports;
2
3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5
6 public class AvoidStarImportTest
7     extends BaseCheckTestCase
8 {
9     public void testDefaultOperation()
10         throws Exception JavaDoc
11     {
12         final DefaultConfiguration checkConfig =
13             createCheckConfig(AvoidStarImportCheck.class);
14         final String JavaDoc[] expected = {
15             "7: Using the '.*' form of import should be avoided - com.puppycrawl.tools.checkstyle.*.",
16             "9: Using the '.*' form of import should be avoided - java.io.*.",
17             "10: Using the '.*' form of import should be avoided - java.lang.*.",
18         };
19
20         verify(checkConfig, getPath("InputImport.java"), expected);
21     }
22
23     public void testExcludes()
24         throws Exception JavaDoc
25     {
26         final DefaultConfiguration checkConfig =
27             createCheckConfig(AvoidStarImportCheck.class);
28         checkConfig.addAttribute("excludes", "java.io,java.lang");
29         // allow the java.io/java.lang star imports
30
final String JavaDoc[] expected2 = new String JavaDoc[] {
31             "7: Using the '.*' form of import should be avoided - com.puppycrawl.tools.checkstyle.*."
32         };
33         verify(checkConfig, getPath("InputImport.java"), expected2);
34     }
35 }
36
Popular Tags