diff --git a/src/tests/com/puppycrawl/tools/checkstyle/AllTests.java b/src/tests/com/puppycrawl/tools/checkstyle/AllTests.java index f4b00d647..be6a53463 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/AllTests.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/AllTests.java @@ -108,6 +108,7 @@ public class AllTests { suite.addTest(new TestSuite(OtherLeftCurlyCheckTest.class)); suite.addTest(new TestSuite(PackageHtmlCheckTest.class)); suite.addTest(new TestSuite(PackageNameCheckTest.class)); + suite.addTest(new TestSuite(PackageObjectFactoryTest.class)); suite.addTest(new TestSuite(ParameterNameCheckTest.class)); suite.addTest(new TestSuite(ParameterNumberCheckTest.class)); suite.addTest(new TestSuite(ParenPadCheckTest.class)); diff --git a/src/tests/com/puppycrawl/tools/checkstyle/PackageObjectFactoryTest.java b/src/tests/com/puppycrawl/tools/checkstyle/PackageObjectFactoryTest.java new file mode 100644 index 000000000..6822c2265 --- /dev/null +++ b/src/tests/com/puppycrawl/tools/checkstyle/PackageObjectFactoryTest.java @@ -0,0 +1,52 @@ +package com.puppycrawl.tools.checkstyle; + +import com.puppycrawl.tools.checkstyle.api.CheckstyleException; + +import junit.framework.TestCase; + +/** + * Enter a description of class PackageObjectFactoryTest.java. + * @author Rick Giles + * @version 8-Dec-2002 + */ +public class PackageObjectFactoryTest extends TestCase +{ + + public void testMakeObectFromName() + throws CheckstyleException + { + PackageObjectFactory factory = + (PackageObjectFactory) PackageObjectFactory.makeObject( + new String [] {}, + this.getClass().getClassLoader(), + "com.puppycrawl.tools.checkstyle.PackageObjectFactory"); + } + + public void testMakeObectFromList() + throws CheckstyleException + { + PackageObjectFactory factory = + (PackageObjectFactory) PackageObjectFactory.makeObject( + new String [] {"com."}, + this.getClass().getClassLoader(), + "puppycrawl.tools.checkstyle.PackageObjectFactory"); + } + + public void testMakeObectNoClass() + throws CheckstyleException + { + try { + PackageObjectFactory factory = + (PackageObjectFactory) PackageObjectFactory.makeObject( + new String [] {}, + this.getClass().getClassLoader(), + "NoClass"); + fail("Instantiated non-existant class"); + } + catch (CheckstyleException ex) { + assertEquals("CheckstyleException.message", + "Unable to instantiate NoClass", + ex.getMessage()); + } + } +} \ No newline at end of file