KickJava   Java API By Example, From Geeks To Geeks.

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


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