01: package com.puppycrawl.tools.checkstyle;
02:
03: import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
04: import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck;
05:
06: import junit.framework.TestCase;
07:
08: /**
09: * 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: private PackageObjectFactory mFactory = new PackageObjectFactory();
16:
17: public void setUp() {
18: mFactory = new PackageObjectFactory();
19: }
20:
21: public void testMakeObjectFromName() throws CheckstyleException {
22: final Checker checker = (Checker) mFactory
23: .createModule("com.puppycrawl.tools.checkstyle.Checker");
24: assertNotNull(checker);
25: }
26:
27: public void testMakeCheckFromName() throws CheckstyleException {
28: final ConstantNameCheck check = (ConstantNameCheck) mFactory
29: .createModule("com.puppycrawl.tools.checkstyle.checks.naming.ConstantName");
30: assertNotNull(check);
31: }
32:
33: public void testMakeObectFromList() throws CheckstyleException {
34: mFactory.addPackage("com.");
35: final Checker checker = (Checker) mFactory
36: .createModule("puppycrawl.tools.checkstyle.Checker");
37: assertNotNull(checker);
38: }
39:
40: public void testMakeObectNoClass() {
41: try {
42: mFactory.createModule("NoClass");
43: fail("Instantiated non-existant class");
44: } catch (CheckstyleException ex) {
45: assertEquals("CheckstyleException.message",
46: "Unable to instantiate NoClass", ex.getMessage());
47: }
48: }
49: }
|