[Batchserver-cvs] batchserver/test/org/jmonks/batch/framework/controller/pool VerifyAllConfigProps
Brought to you by:
suresh_pragada
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batch/framework/controller/pool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28283 Added Files: VerifyAllConfigPropsJobLoader.java VerifyAllConfigPropsJobPool.java VerifyAllConfigPropsJobProcessor.java VerifyAllConfigPropsPoolJobControllerTest.java VerifyReturnCodeJobLoader.java VerifyReturnCodeJobProcessor.java VerifyReturnCodePoolJobControllerTest.java Removed Files: CollectionJobPoolTest.java Log Message: no message --- NEW FILE: VerifyReturnCodeJobProcessor.java --- /* * VerifyAllConfigPropsJobLoader.java * * Created on September 18, 2006, 5:39 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.controller.pool; import junit.framework.Assert; import org.apache.log4j.Logger; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; /** * * @author Suresh Pragada */ public class VerifyReturnCodeJobProcessor extends AbstractPoolJobProcessor { private static Logger logger=Logger.getLogger(VerifyReturnCodeJobProcessor.class); public VerifyReturnCodeJobProcessor() { } public void cleanup() { } public void initialize(JobContext jobContext) { Assert.assertNotNull(jobContext); } public ErrorCode process(Object jobData) { Assert.assertNotNull(jobData); Integer value=(Integer)jobData; logger.error("Received the data to verify the return code process : " + jobData.toString()); String threadName=Thread.currentThread().getName(); if(threadName.endsWith("3")) return ErrorCode.createErrorCode(102, "This is my error code."); else return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; } } --- NEW FILE: VerifyAllConfigPropsJobProcessor.java --- /* * VerifyAllConfigPropsJobLoader.java * * Created on September 18, 2006, 5:39 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.controller.pool; import java.util.Map; import junit.framework.Assert; import org.apache.log4j.Logger; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; import org.jmonks.batch.framework.config.PoolJobControllerConfig; /** * * @author Suresh Pragada */ public class VerifyAllConfigPropsJobProcessor extends AbstractPoolJobProcessor { private static Logger logger=Logger.getLogger(VerifyAllConfigPropsJobProcessor.class); public VerifyAllConfigPropsJobProcessor() { } public void cleanup() { } public void initialize(JobContext jobContext) { Assert.assertNotNull(jobContext); /** * Validate invoke configuration */ Map invokeConfigMap=jobContext.getJobInvokeConfig(); Assert.assertNotNull(invokeConfigMap); String invokeConfigValue1=(String)invokeConfigMap.get("invoke-config-key1"); Assert.assertNotNull(invokeConfigValue1); Assert.assertEquals("invoke-config-value1",invokeConfigValue1); /** * Validate loader configuration */ Map processorConfigMap=((PoolJobControllerConfig)jobContext.getJobConfig().getJobControllerConfig()).getPoolJobProcessorConfigProperties(); Assert.assertNotNull(processorConfigMap); String processorConfigValue1=(String)processorConfigMap.get("processor-config-key1"); Assert.assertNotNull(processorConfigValue1); Assert.assertEquals("processor-config-value1",processorConfigValue1); String processorConfigValue2=(String)processorConfigMap.get("processor-config-key2"); Assert.assertNotNull(processorConfigValue2); Assert.assertEquals("processor-config-value2",processorConfigValue2); /** * Validate controller configuration */ Map controllerConfigMap=jobContext.getJobConfig().getJobControllerConfig().getJobControllerConfigProperties(); Assert.assertNotNull(controllerConfigMap); String controllerConfigValue1=(String)controllerConfigMap.get("controller-config-key1"); Assert.assertNotNull(controllerConfigValue1); Assert.assertEquals("controller-config-value1",controllerConfigValue1); /** * Validate for the modification of config maps. */ try { invokeConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the invoke config map."); } catch(UnsupportedOperationException exception){} try { processorConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the processor config map."); } catch(UnsupportedOperationException exception){} try { controllerConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the controller config map."); } catch(UnsupportedOperationException exception){} } public ErrorCode process(Object jobData) { Assert.assertNotNull(jobData); Integer value=(Integer)jobData; logger.error("Received the data to process : " + jobData.toString()); return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; } } --- CollectionJobPoolTest.java DELETED --- --- NEW FILE: VerifyReturnCodePoolJobControllerTest.java --- /* * VerifyAllConfigPropsPoolJobControllerTest.java * JUnit based test * * Created on September 17, 2006, 9:36 AM */ package org.jmonks.batch.framework.controller.pool; import java.util.HashMap; import java.util.Map; import junit.framework.*; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.Main; /** * * @author Suresh Pragada */ public class VerifyReturnCodePoolJobControllerTest extends TestCase { public VerifyReturnCodePoolJobControllerTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(new VerifyReturnCodePoolJobControllerTest("testVerifyReturnCode")); return suite; } public void testVerifyReturnCode() { Map configMap=new HashMap(); configMap.put("job-name", "verify_return_code_pool_job_controller"); ErrorCode exitCode=Main.process(configMap); assertNotNull(exitCode); assertEquals(102, exitCode.getCode()); } } --- NEW FILE: VerifyAllConfigPropsJobLoader.java --- /* * VerifyAllConfigPropsJobLoader.java * * Created on September 18, 2006, 5:39 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.controller.pool; import java.util.Map; import junit.framework.Assert; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; import org.jmonks.batch.framework.config.PoolJobControllerConfig; /** * * @author Suresh Pragada */ public class VerifyAllConfigPropsJobLoader extends AbstractPoolJobLoader { /** Creates a new instance of VerifyAllConfigPropsJobLoader */ public VerifyAllConfigPropsJobLoader() { } public long getTotalJobDataCount() { return 100; } public ErrorCode loadPool(JobContext jobContext) { Assert.assertNotNull(jobContext); /** * Validate invoke configuration */ Map invokeConfigMap=jobContext.getJobInvokeConfig(); Assert.assertNotNull(invokeConfigMap); String invokeConfigValue1=(String)invokeConfigMap.get("invoke-config-key1"); Assert.assertNotNull(invokeConfigValue1); Assert.assertEquals("invoke-config-value1",invokeConfigValue1); /** * Validate loader configuration */ Map loaderConfigMap=((PoolJobControllerConfig)jobContext.getJobConfig().getJobControllerConfig()).getPoolJobLoaderConfigProperties(); Assert.assertNotNull(loaderConfigMap); String loaderConfigValue1=(String)loaderConfigMap.get("loader-config-key1"); Assert.assertNotNull(loaderConfigValue1); Assert.assertEquals("loader-config-value1",loaderConfigValue1); String loaderConfigValue2=(String)loaderConfigMap.get("loader-config-key2"); Assert.assertNotNull(loaderConfigValue2); Assert.assertEquals("loader-config-value2",loaderConfigValue2); /** * Validate controller configuration */ Map controllerConfigMap=jobContext.getJobConfig().getJobControllerConfig().getJobControllerConfigProperties(); Assert.assertNotNull(controllerConfigMap); String controllerConfigValue1=(String)controllerConfigMap.get("controller-config-key1"); Assert.assertNotNull(controllerConfigValue1); Assert.assertEquals("controller-config-value1",controllerConfigValue1); /** * Validate for the modification of config maps. */ try { invokeConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the invoke config map."); } catch(UnsupportedOperationException exception){} try { loaderConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the loader config map."); } catch(UnsupportedOperationException exception){} try { controllerConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the controller config map."); } catch(UnsupportedOperationException exception){} for(int i=0;i<10;i++) loadJobData(new Integer(i)); loadJobData(null); return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; } } --- NEW FILE: VerifyAllConfigPropsPoolJobControllerTest.java --- /* * VerifyAllConfigPropsPoolJobControllerTest.java * JUnit based test * * Created on September 17, 2006, 9:36 AM */ package org.jmonks.batch.framework.controller.pool; import java.util.HashMap; import java.util.Map; import junit.framework.*; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; import org.jmonks.batch.framework.Main; import org.jmonks.batch.framework.config.BasicJobControllerConfig; /** * * @author Suresh Pragada */ public class VerifyAllConfigPropsPoolJobControllerTest extends TestCase { public VerifyAllConfigPropsPoolJobControllerTest(String testName) { super(testName); } protected void setUp() throws Exception { } protected void tearDown() throws Exception { } public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(new VerifyAllConfigPropsPoolJobControllerTest("testVerifyAllConfigProps")); return suite; } public void testVerifyAllConfigProps() { Map configMap=new HashMap(); configMap.put("job-name", "verify_config_props_pool_job_controller"); configMap.put("invoke-config-key1", "invoke-config-value1"); ErrorCode exitCode=Main.process(configMap); assertNotNull(exitCode); assertEquals(ErrorCode.JOB_COMPLETED_SUCCESSFULLY.getCode(), exitCode.getCode()); } } --- NEW FILE: VerifyReturnCodeJobLoader.java --- /* * VerifyAllConfigPropsJobLoader.java * * Created on September 18, 2006, 5:39 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.controller.pool; import junit.framework.Assert; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; /** * * @author Suresh Pragada */ public class VerifyReturnCodeJobLoader extends AbstractPoolJobLoader { public VerifyReturnCodeJobLoader() { } public long getTotalJobDataCount() { return 100; } public ErrorCode loadPool(JobContext jobContext) { Assert.assertNotNull(jobContext); for(int i=0;i<25;i++) loadJobData(new Integer(i)); loadJobData(null); return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; } } --- NEW FILE: VerifyAllConfigPropsJobPool.java --- /* * VerifyAllConfigPropsJobLoader.java * * Created on September 18, 2006, 5:39 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batch.framework.controller.pool; import java.util.Map; import junit.framework.Assert; import org.jmonks.batch.framework.JobContext; import org.jmonks.batch.framework.config.PoolJobControllerConfig; /** * * @author Suresh Pragada */ public class VerifyAllConfigPropsJobPool extends CollectionJobPool { public VerifyAllConfigPropsJobPool() { } public void initialize(JobContext jobContext) { Assert.assertNotNull(jobContext); /** * Validate invoke configuration */ Map invokeConfigMap=jobContext.getJobInvokeConfig(); Assert.assertNotNull(invokeConfigMap); String invokeConfigValue1=(String)invokeConfigMap.get("invoke-config-key1"); Assert.assertNotNull(invokeConfigValue1); Assert.assertEquals("invoke-config-value1",invokeConfigValue1); /** * Validate loader configuration */ Map poolConfigMap=((PoolJobControllerConfig)jobContext.getJobConfig().getJobControllerConfig()).getPoolConfigProperties(); Assert.assertNotNull(poolConfigMap); String poolConfigValue1=(String)poolConfigMap.get("pool-config-key1"); Assert.assertNotNull(poolConfigValue1); Assert.assertEquals("pool-config-value1",poolConfigValue1); String poolConfigValue2=(String)poolConfigMap.get("pool-config-key2"); Assert.assertNotNull(poolConfigValue2); Assert.assertEquals("pool-config-value2",poolConfigValue2); /** * Validate controller configuration */ Map controllerConfigMap=jobContext.getJobConfig().getJobControllerConfig().getJobControllerConfigProperties(); Assert.assertNotNull(controllerConfigMap); String controllerConfigValue1=(String)controllerConfigMap.get("controller-config-key1"); Assert.assertNotNull(controllerConfigValue1); Assert.assertEquals("controller-config-value1",controllerConfigValue1); /** * Validate for the modification of config maps. */ try { invokeConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the invoke config map."); } catch(UnsupportedOperationException exception){} try { poolConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the pool config map."); } catch(UnsupportedOperationException exception){} try { controllerConfigMap.put("trying-to-change", "can-I"); Assert.fail("Would be able to the change the controller config map."); } catch(UnsupportedOperationException exception){} super.initialize(jobContext); } } |