KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.puppycrawl.tools.checkstyle.checks.design;
2
3 import java.io.File JavaDoc;
4
5 import com.puppycrawl.tools.checkstyle.BaseCheckTestCase;
6 import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
7
8 public class HideUtilityClassConstructorCheckTest
9     extends BaseCheckTestCase
10 {
11     /** only static methods and no constructor - default ctor is visible */
12     public void testUtilClass() throws Exception JavaDoc
13     {
14         final DefaultConfiguration checkConfig =
15             createCheckConfig(HideUtilityClassConstructorCheck.class);
16         final String JavaDoc[] expected = {
17             "11:1: Utility classes should not have a public or default constructor.",
18         };
19         verify(checkConfig, getPath("InputArrayTypeStyle.java"), expected);
20     }
21
22     /** nonstatic methods - always OK */
23     public void testNonUtilClass() throws Exception JavaDoc
24     {
25         final DefaultConfiguration checkConfig =
26             createCheckConfig(HideUtilityClassConstructorCheck.class);
27         final String JavaDoc[] expected = {
28         };
29         verify(checkConfig, getPath("InputDesignForExtension.java"), expected);
30     }
31
32     public void testDerivedNonUtilClass() throws Exception JavaDoc
33     {
34         final DefaultConfiguration checkConfig =
35             createCheckConfig(HideUtilityClassConstructorCheck.class);
36         final String JavaDoc[] expected = {
37         };
38         verify(checkConfig, getPath("design" + File.separator + "InputNonUtilityClass.java"), expected);
39     }
40
41 }
42
Popular Tags