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 IllegalImportCheckTest extends BaseCheckTestCase {
07: public void testWithSupplied() throws Exception {
08: final DefaultConfiguration checkConfig = createCheckConfig(IllegalImportCheck.class);
09: checkConfig.addAttribute("illegalPkgs", "java.io");
10: final String[] expected = {
11: "9:1: Import from illegal package - java.io.*.",
12: "23:1: Import from illegal package - java.io.File.listRoots.",
13: "27:1: Import from illegal package - java.io.File.createTempFile.", };
14: verify(checkConfig, getPath("InputImport.java"), expected);
15: }
16:
17: public void testWithDefault() throws Exception {
18: final DefaultConfiguration checkConfig = createCheckConfig(IllegalImportCheck.class);
19: final String[] expected = {
20: "15:1: Import from illegal package - sun.net.ftpclient.FtpClient.",
21: "28:1: Import from illegal package - sun.net.ftpclient.FtpClient.*.", };
22: verify(checkConfig, getPath("InputImport.java"), expected);
23: }
24: }
|