KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > design > ThrowsCountCheckTest


1 package com.puppycrawl.tools.checkstyle.checks.design;
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 ThrowsCountCheckTest extends BaseCheckTestCase {
9     public void testDefault() throws Exception JavaDoc {
10         DefaultConfiguration checkConfig = createCheckConfig(ThrowsCountCheck.class);
11
12         String JavaDoc[] expected = {
13             "14:20: Throws count is 2 (max allowed is 1).",
14             "18:20: Throws count is 2 (max allowed is 1).",
15             "22:20: Throws count is 3 (max allowed is 1).",
16         };
17
18         verify(checkConfig, getPath("design" + File.separator + "InputThrowsCount.java"), expected);
19     }
20
21     public void testMax() throws Exception JavaDoc {
22         DefaultConfiguration checkConfig = createCheckConfig(ThrowsCountCheck.class);
23         checkConfig.addAttribute("max", "2");
24
25         String JavaDoc[] expected = {
26             "22:20: Throws count is 3 (max allowed is 2).",
27         };
28
29         verify(checkConfig, getPath("design" + File.separator + "InputThrowsCount.java"), expected);
30     }
31 }
32
Popular Tags