KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > PackageObjectFactoryTest


1 package com.puppycrawl.tools.checkstyle;
2
3 import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
4 import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck;
5
6 import junit.framework.TestCase;
7
8 /**
9  * Enter a description of class PackageObjectFactoryTest.java.
10  * @author Rick Giles
11  * @version 8-Dec-2002
12  */

13 public class PackageObjectFactoryTest extends TestCase
14 {
15
16     private PackageObjectFactory mFactory = new PackageObjectFactory();
17
18     public void setUp()
19     {
20         mFactory = new PackageObjectFactory();
21     }
22
23     public void testMakeObjectFromName()
24         throws CheckstyleException
25     {
26         final Checker checker =
27             (Checker) mFactory.createModule(
28                         "com.puppycrawl.tools.checkstyle.Checker");
29         assertNotNull(checker);
30     }
31
32     public void testMakeCheckFromName()
33         throws CheckstyleException
34     {
35         final ConstantNameCheck check =
36                 (ConstantNameCheck) mFactory.createModule(
37                         "com.puppycrawl.tools.checkstyle.checks.naming.ConstantName");
38         assertNotNull(check);
39     }
40     
41     public void testMakeObectFromList()
42         throws CheckstyleException
43     {
44         mFactory.addPackage("com.");
45         final Checker checker =
46                 (Checker) mFactory.createModule(
47                         "puppycrawl.tools.checkstyle.Checker");
48         assertNotNull(checker);
49     }
50     
51     public void testMakeObectNoClass()
52         throws CheckstyleException
53     {
54         try {
55             mFactory.createModule("NoClass");
56             fail("Instantiated non-existant class");
57         }
58         catch (CheckstyleException ex) {
59             assertEquals("CheckstyleException.message",
60                 "Unable to instantiate NoClass",
61                 ex.getMessage());
62         }
63     }
64 }
65
Popular Tags