Thread: [Batchserver-cvs] batchserver/test/org/jmonks/batchserver/framework/config ConfigurationExceptionTes
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-07 03:42:28
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19304 Added Files: ConfigurationExceptionTest.java FrameworkConfigTest.java Log Message: no message --- NEW FILE: FrameworkConfigTest.java --- /* * FrameworkConfigTest.java * JUnit based test * * Created on March 5, 2006, 4:24 PM */ package org.jmonks.batchserver.framework.config; import junit.framework.*; import java.util.Map; import org.w3c.dom.Element; /** * Test cases to test the FrameworkConfig class. * * @author Suresh Pragada */ public class FrameworkConfigTest extends TestCase { public FrameworkConfigTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(FrameworkConfigTest.class); return suite; } /** * Test that FrameworkConfig cannot be instantiated. */ public void testInstantiation() { try { FrameworkConfig frameworkConfig=(FrameworkConfig)FrameworkConfig.class.newInstance(); fail("FrameworkConfig should not be instantiated."); } catch(InstantiationException ex) { /** * This is expected as FrameworkConfig cannot be instantiated. */ } catch(IllegalAccessException ex) { /** * This is expected as the constructor of FrameworkConfig is private. */ } } /** * Test that make sure getInstance never returns null object. */ public void testGetInstance() { FrameworkConfig config=FrameworkConfig.getInstance(); assertNotNull(config); System.out.println(config); } /** * Test that job-config-factory-config is configured properly in the framework-config.xml file * and it doestn return null factory class name and properties map. */ public void testGetJobConfigFactoryConfig() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.JobConfigFactoryConfig factoryConfig=frameworkConfig.getJobConfigFactoryConfig(); assertNotNull(factoryConfig); assertNotNull(factoryConfig.getJobConfigFactoryClassName()); assertNotNull(factoryConfig.getJobConfigFactoryProperties()); System.out.println(factoryConfig); } /** * Test that logging-config is configured properly in the framework-config.xml file and * make sure it defines all the required properties. */ public void testGetLoggingConfig() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.LoggingConfig loggingConfig=frameworkConfig.getLoggingConfig(); assertNotNull(loggingConfig); assertNotNull(loggingConfig.getLoggingDirecotry()); assertNotNull(loggingConfig.getFrameworkLogLevel()); assertNotNull(loggingConfig.getBasePackageName()); System.out.println(loggingConfig); } /** * Test that mgmt-mntr-config is properly configured and make sure it doesnt return null for * manager class name and properties. */ public void testGetMgmtMntrConfig() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.MgmtMntrConfig mmConfig=frameworkConfig.getMgmtMntrConfig(); assertNotNull(mmConfig); assertNotNull(mmConfig.getMgmtMntrClassName()); assertNotNull(mmConfig.getMgmtMntrProperties()); System.out.println(mmConfig); } /** * Test that repository-config is properly configured and make sure it doesnt return null * for the repository class name and properties. */ public void testGetRepositoryConfig() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.RepositoryConfig repConfig=frameworkConfig.getRepositoryConfig(); assertNotNull(repConfig); assertNotNull(repConfig.getRepositoryClassName()); assertNotNull(repConfig.getRepositoryConfigProperties()); System.out.println(repConfig); } } --- NEW FILE: ConfigurationExceptionTest.java --- /* * ConfigurationExceptionTest.java * JUnit based test * * Created on March 5, 2006, 5:14 PM */ package org.jmonks.batchserver.framework.config; import junit.framework.*; import org.jmonks.batchserver.framework.common.ErrorCode; /** * Test all the cases of Configuration Exception. * @author Suresh Pragada */ public class ConfigurationExceptionTest extends TestCase { public ConfigurationExceptionTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(ConfigurationExceptionTest.class); return suite; } /** * Test that exception is not return null for the error code. */ public void testGetErrorCode() { ConfigurationException exception=new ConfigurationException(ErrorCode.FRAMEWORK_CONFIG_FILE_NOT_FOUND); ErrorCode code=exception.getErrorCode(); assertNotNull(code); } /** * Test that exception cannot be instantiated until unless the error code has been passed. */ public void testInstantiation() { try { ConfigurationException exception=(ConfigurationException)ConfigurationException.class.newInstance(); fail("ConfigurationException should not be instantiated."); } catch(InstantiationException ex) { /** * This is expected as ConfigurationException cannot be instantiated. */ } catch(IllegalAccessException ex) { /** * This is expected as the constructor of ConfigurationException is private. */ } } } |