[Batchserver-cvs] batchserver/test/org/jmonks/batchserver/framework RepositoryTest.java,NONE,1.1 Fra
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-14 23:08:56
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22170 Modified Files: FrameworkTestSuite.java LoggingManagerTest.java Added Files: RepositoryTest.java Log Message: no message Index: FrameworkTestSuite.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/FrameworkTestSuite.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FrameworkTestSuite.java 13 Mar 2006 14:27:15 -0000 1.3 --- FrameworkTestSuite.java 14 Mar 2006 23:08:49 -0000 1.4 *************** *** 48,51 **** --- 48,52 ---- { TestSuite mainSuite = new TestSuite(); + mainSuite.addTest(LoggingManagerTest.suite()); mainSuite.addTest(FrameworkUtilTest.suite()); *************** *** 59,63 **** mainSuite.addTest(BasicJobControllerConfigTest.suite()); mainSuite.addTest(PoolJobControllerConfigTest.suite()); ! return mainSuite; --- 60,64 ---- mainSuite.addTest(BasicJobControllerConfigTest.suite()); mainSuite.addTest(PoolJobControllerConfigTest.suite()); ! mainSuite.addTest(RepositoryTest.suite()); return mainSuite; --- NEW FILE: RepositoryTest.java --- /* * RepositoryTest.java * JUnit based test * * Created on March 14, 2006, 3:54 PM */ package org.jmonks.batchserver.framework; import junit.framework.*; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Map; import org.apache.log4j.Logger; import org.jmonks.batchserver.framework.config.*; import org.jmonks.batchserver.framework.controller.JobController; /** * * @author w951h8m */ public class RepositoryTest extends TestCase { public RepositoryTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(RepositoryTest.class); return suite; } /** * Test to make sure repository cannot be instantiated. */ public void testInstantiation() { try { Repository repository=(Repository)Repository.class.newInstance(); fail("Repository should not be instantiated."); } catch(InstantiationException ex) { /** * This is expected as Repository cannot be instantiated. */ } catch(IllegalAccessException ex) { /** * This is expected as the constructor of Repository is protected. */ } } /** * Test to make sure this is not returning null. */ public void testGetRepository() { FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); assertNotNull(frameworkConfig); FrameworkConfig.RepositoryConfig repositoryConfig=frameworkConfig.getRepositoryConfig(); assertNotNull(repositoryConfig); Repository repository=Repository.getRepository(repositoryConfig); assertNotNull(repository); } } Index: LoggingManagerTest.java =================================================================== RCS file: /cvsroot/batchserver/batchserver/test/org/jmonks/batchserver/framework/LoggingManagerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LoggingManagerTest.java 13 Mar 2006 14:31:15 -0000 1.1 --- LoggingManagerTest.java 14 Mar 2006 23:08:50 -0000 1.2 *************** *** 9,21 **** import junit.framework.*; ! import java.io.File; ! import java.io.IOException; ! import java.text.SimpleDateFormat; ! import java.util.Calendar; ! import java.util.logging.FileHandler; ! import java.util.logging.Handler; ! import java.util.logging.Level; ! import java.util.logging.LogManager; ! import java.util.logging.Logger; import org.jmonks.batchserver.framework.config.*; --- 9,13 ---- import junit.framework.*; ! import org.apache.log4j.Logger; import org.jmonks.batchserver.framework.config.*; *************** *** 26,30 **** public class LoggingManagerTest extends TestCase { ! public LoggingManagerTest(String testName) { --- 18,22 ---- public class LoggingManagerTest extends TestCase { ! private FrameworkConfig frameworkConfig=null; public LoggingManagerTest(String testName) { *************** *** 34,37 **** --- 26,30 ---- protected void setUp() throws Exception { + frameworkConfig=FrameworkConfig.getInstance(); } *************** *** 42,114 **** public static Test suite() { ! TestSuite suite = new TestSuite(LoggingManagerTest.class); ! //TestSuite suite=new TestSuite(); ! //suite.addTest(new LoggingManagerTest("testChangeLoggingLevel")); return suite; } /** - * Test of getInstance method, of class org.jmonks.batchserver.framework.LoggingManager. - */ - public void testGetInstance() - { - LoggingManager loggingManager=LoggingManager.getInstance(); - assertNotNull(loggingManager); - } - - /** * Test of initializeJobLogging method, of class org.jmonks.batchserver.framework.LoggingManager. */ public void testInitializeJobLogging() { ! LoggingManager loggingManager=LoggingManager.getInstance(); ! assertNotNull(loggingManager); ! loggingManager.initializeFrameworkLogging(); ! ! Logger logger1=Logger.getLogger("org.jmonks.batchserver.framework"); ! assertNotNull(logger1); ! logger1.warning("This is the warning message"); ! logger1.config("This is the config message"); ! logger1.config("This is the severe message"); ! ! FrameworkConfig frameworkConfig=FrameworkConfig.getInstance(); ! assertNotNull(frameworkConfig); ! FrameworkConfig.LoggingConfig loggingConfig=frameworkConfig.getLoggingConfig(); assertNotNull(loggingConfig); ! loggingManager.initializeJobLogging("process_file_abc", loggingConfig); ! ! Logger logger2=Logger.getLogger("org.jmonks.batchserver.framework"); ! assertNotNull(logger2); ! logger2.warning("This is the warning message"); ! logger2.config("This is the config message"); ! logger2.config("This is the severe message"); ! } - /** - * Test to make sure logging level being modifieid. - */ - public void testChangeLoggingLevel() - { - LoggingManager loggingManager=LoggingManager.getInstance(); - loggingManager.initializeFrameworkLogging(); - - Logger logger=Logger.getLogger(LoggingManagerTest.class.getName()); - logger.severe("This is the severed messaged"); - } /** * Test of initializeLogging method, of class org.jmonks.batchserver.framework.LoggingManager. */ ! public void testInitializeLogging() { ! LoggingManager loggingManager=LoggingManager.getInstance(); ! assertNotNull(loggingManager); ! loggingManager.initializeFrameworkLogging(); ! Logger logger1=Logger.getLogger("org.jmonks"); ! assertNotNull(logger1); ! Logger logger2=Logger.getLogger("org.jmonks.batchserver.framework.config"); ! assertNotNull(logger2); } --- 35,85 ---- public static Test suite() { ! //TestSuite suite = new TestSuite(LoggingManagerTest.class); ! TestSuite suite=new TestSuite(); ! suite.addTest(new LoggingManagerTest("testInitializeFrameworkLogging")); ! suite.addTest(new LoggingManagerTest("testInitializeJobLogging")); return suite; } /** * Test of initializeJobLogging method, of class org.jmonks.batchserver.framework.LoggingManager. */ public void testInitializeJobLogging() { ! assertNotNull(frameworkConfig); ! FrameworkConfig.FrameworkLoggingConfig loggingConfig=frameworkConfig.getFrameworkLoggingConfig(); assertNotNull(loggingConfig); ! FrameworkConfig.JobConfigFactoryConfig configFactoryConfig=frameworkConfig.getJobConfigFactoryConfig(); ! assertNotNull(configFactoryConfig); ! JobConfigFactory factory=JobConfigFactory.getJobConfigFactory(configFactoryConfig); ! assertNotNull(factory); ! JobConfig jobConfig=factory.getJobConfig("process_file_xyz"); ! assertNotNull(jobConfig); ! JobLoggingConfig jobLoggingConfig=jobConfig.getJobLoggingConfig(); ! assertNotNull(jobLoggingConfig); ! LoggingManager.initializeJobLogging("process_file_xyz", loggingConfig,jobLoggingConfig); + Logger logger=Logger.getLogger(LoggingManagerTest.class); + logger.debug("This is debug message after job initialization"); + logger.info("This is info message after job initialization"); + logger.warn("This is warn message after job initialization"); + logger.error("This is error message after job initialization"); } /** * Test of initializeLogging method, of class org.jmonks.batchserver.framework.LoggingManager. */ ! public void testInitializeFrameworkLogging() { ! assertNotNull(frameworkConfig); ! FrameworkConfig.FrameworkLoggingConfig loggingConfig=frameworkConfig.getFrameworkLoggingConfig(); ! assertNotNull(loggingConfig); ! LoggingManager.initializeFrameworkLogging(loggingConfig); ! Logger logger=Logger.getLogger(LoggingManagerTest.class); ! logger.debug("This is debug message"); ! logger.info("This is info message"); ! logger.warn("This is warn message"); ! logger.error("This is error message"); } |