KickJava   Java API By Example, From Geeks To Geeks.

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


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 EmptyBlockCheckTest
7     extends BaseCheckTestCase
8 {
9     public void testDefault()
10         throws Exception JavaDoc
11     {
12         final DefaultConfiguration checkConfig =
13             createCheckConfig(EmptyBlockCheck.class);
14         final String JavaDoc[] expected = {
15             "52:65: Must have at least one statement.",
16             "54:41: Must have at least one statement.",
17             "71:38: Must have at least one statement.",
18             "72:52: Must have at least one statement.",
19             "73:45: Must have at least one statement.",
20             "75:13: Must have at least one statement.",
21             "77:17: Must have at least one statement.",
22             "79:13: Must have at least one statement.",
23             "82:17: Must have at least one statement.",
24             "178:5: Must have at least one statement.",
25         };
26         verify(checkConfig, getPath("InputSemantic.java"), expected);
27     }
28
29     public void testText()
30         throws Exception JavaDoc
31     {
32         final DefaultConfiguration checkConfig =
33             createCheckConfig(EmptyBlockCheck.class);
34         checkConfig.addAttribute("option", BlockOption.TEXT.toString());
35         final String JavaDoc[] expected = {
36             "52:65: Empty catch block.",
37             "72:52: Empty catch block.",
38             "73:45: Empty catch block.",
39             "75:13: Empty try block.",
40             "77:17: Empty finally block.",
41             "178:5: Empty INSTANCE_INIT block.",
42         };
43         verify(checkConfig, getPath("InputSemantic.java"), expected);
44     }
45
46     public void testStatement()
47         throws Exception JavaDoc
48     {
49         final DefaultConfiguration checkConfig =
50             createCheckConfig(EmptyBlockCheck.class);
51         checkConfig.addAttribute("option", BlockOption.STMT.toString());
52         final String JavaDoc[] expected = {
53             "52:65: Must have at least one statement.",
54             "54:41: Must have at least one statement.",
55             "71:38: Must have at least one statement.",
56             "72:52: Must have at least one statement.",
57             "73:45: Must have at least one statement.",
58             "75:13: Must have at least one statement.",
59             "77:17: Must have at least one statement.",
60             "79:13: Must have at least one statement.",
61             "82:17: Must have at least one statement.",
62             "178:5: Must have at least one statement.",
63         };
64         verify(checkConfig, getPath("InputSemantic.java"), expected);
65     }
66 }
67
Popular Tags