01: package com.puppycrawl.tools.checkstyle.checks.imports;
02:
03: import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
04: import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
05:
06: public class AvoidStarImportTest extends BaseCheckTestCase {
07: public void testDefaultOperation() throws Exception {
08: final DefaultConfiguration checkConfig = createCheckConfig(AvoidStarImportCheck.class);
09: final String[] expected = {
10: "7: Using the '.*' form of import should be avoided - com.puppycrawl.tools.checkstyle.*.",
11: "9: Using the '.*' form of import should be avoided - java.io.*.",
12: "10: Using the '.*' form of import should be avoided - java.lang.*.", };
13:
14: verify(checkConfig, getPath("InputImport.java"), expected);
15: }
16:
17: public void testExcludes() throws Exception {
18: final DefaultConfiguration checkConfig = createCheckConfig(AvoidStarImportCheck.class);
19: checkConfig.addAttribute("excludes", "java.io,java.lang");
20: // allow the java.io/java.lang star imports
21: final String[] expected2 = new String[] { "7: Using the '.*' form of import should be avoided - com.puppycrawl.tools.checkstyle.*." };
22: verify(checkConfig, getPath("InputImport.java"), expected2);
23: }
24: }
|