KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > blocks > AvoidNestedBlocksCheckTest


1 package com.puppycrawl.tools.checkstyle.checks.blocks;
2
3 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
4 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
5
6 public class AvoidNestedBlocksCheckTest
7         extends BaseCheckTestCase
8 {
9     public void testStrictSettings()
10         throws Exception JavaDoc
11     {
12         final DefaultConfiguration checkConfig =
13             createCheckConfig(AvoidNestedBlocksCheck.class);
14         final String JavaDoc[] expected = {
15             "22:9: Avoid nested blocks.",
16             "44:17: Avoid nested blocks.",
17             "50:17: Avoid nested blocks.",
18             "58:17: Avoid nested blocks.",
19         };
20         verify(checkConfig, getPath("InputNestedBlocks.java"), expected);
21     }
22
23     public void testAllowSwitchInCase()
24         throws Exception JavaDoc
25     {
26         final DefaultConfiguration checkConfig =
27             createCheckConfig(AvoidNestedBlocksCheck.class);
28         checkConfig.addAttribute("allowInSwitchCase", Boolean.TRUE.toString());
29
30         final String JavaDoc[] expected = {
31             "22:9: Avoid nested blocks.",
32             "44:17: Avoid nested blocks.",
33             "58:17: Avoid nested blocks.",
34         };
35         verify(checkConfig, getPath("InputNestedBlocks.java"), expected);
36     }
37 }
38
Popular Tags