KickJava   Java API By Example, From Geeks To Geeks.

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


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 public class NestedTryDepthCheckTest extends BaseCheckTestCase
7 {
8     public void testDefault() throws Exception JavaDoc
9     {
10         final DefaultConfiguration checkConfig =
11             createCheckConfig(NestedTryDepthCheck.class);
12
13         final String JavaDoc[] expected = {
14             "20:17: Nested try depth is 2 (max allowed is 1).",
15             "31:17: Nested try depth is 2 (max allowed is 1).",
16             "32:21: Nested try depth is 3 (max allowed is 1).",
17         };
18
19         verify(checkConfig, getPath("coding/InputNestedTryDepth.java"), expected);
20     }
21
22     public void testCustomNestingDepth() throws Exception JavaDoc
23     {
24         final DefaultConfiguration checkConfig =
25             createCheckConfig(NestedTryDepthCheck.class);
26         checkConfig.addAttribute("max", "2");
27
28         final String JavaDoc[] expected = {
29             "32:21: Nested try depth is 3 (max allowed is 2).",
30         };
31
32         verify(checkConfig, getPath("coding/InputNestedTryDepth.java"), expected);
33     }
34 }
35
Popular Tags