KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.File JavaDoc;
7
8 public class IllegalThrowsCheckTest extends BaseCheckTestCase
9 {
10     public void testDefault() throws Exception JavaDoc
11     {
12         DefaultConfiguration checkConfig = createCheckConfig(IllegalThrowsCheck.class);
13
14         String JavaDoc[] expected = {
15             "9:51: Throwing 'RuntimeException' is not allowed.",
16             "14:45: Throwing 'java.lang.RuntimeException' is not allowed.",
17             "14:73: Throwing 'java.lang.Error' is not allowed.",
18         };
19
20         verify(checkConfig, getPath("coding" + File.separator + "InputIllegalThrowsCheck.java"), expected);
21     }
22
23     public void testIllegalClassNames() throws Exception JavaDoc
24     {
25         DefaultConfiguration checkConfig = createCheckConfig(IllegalThrowsCheck.class);
26         checkConfig.addAttribute("illegalClassNames",
27                                  "java.lang.Error, java.lang.Exception, NullPointerException");
28
29         String JavaDoc[] expected = {
30             "5:33: Throwing 'NullPointerException' is not allowed.",
31             "14:73: Throwing 'java.lang.Error' is not allowed.",
32         };
33
34         verify(checkConfig, getPath("coding" + File.separator + "InputIllegalThrowsCheck.java"), expected);
35     }
36 }
37
Popular Tags