Thread: [Batchserver-cvs] batchserver/test/org/jmonks/batch/framework/controller/basic VerifyAllConfigProp
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-09-19 00:09:16
|
Update of /cvsroot/batchserver/batchserver/test/org/jmonks/batch/framework/controller/basic In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29037 Added Files: VerifyAllConfigPropsBasicJobControllerTest.java VerifyAllConfigPropsProcessor.java VerifyReturnCodeBasicJobControllerTest.java VerifyReturnCodeProcessor.java Removed Files: BasicJobControllerTest.java TestBasicJobProcessor.java Log Message: no message --- BasicJobControllerTest.java DELETED --- --- NEW FILE: VerifyAllConfigPropsBasicJobControllerTest.java --- /* * VerifyAllConfigPropsBasicJobControllerTest.java * JUnit based test * * Created on September 17, 2006, 9:36 AM */ package org.jmonks.batch.framework.controller.basic; 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 VerifyAllConfigPropsBasicJobControllerTest extends TestCase { public VerifyAllConfigPropsBasicJobControllerTest(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 VerifyAllConfigPropsBasicJobControllerTest("testVerifyAllConfigProps")); return suite; } public void testVerifyAllConfigProps() { Map configMap=new HashMap(); configMap.put("job-name", "verify_config_props_basic_job_processor"); 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: VerifyAllConfigPropsProcessor.java --- /* * VerifyAllConfigPropsProcessor.java * * Created on September 17, 2006, 9:29 AM * * 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.basic; 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.BasicJobControllerConfig; /** * * @author Suresh Pragada */ public class VerifyAllConfigPropsProcessor extends BasicJobProcessor { /** * Creates a new instance of VerifyAllConfigPropsProcessor */ public VerifyAllConfigPropsProcessor() { } public long getProcessedRecordsCount() { return 0; } public Object getProcessorState() { return "No jobs are being processed."; } public long getTotalRecordsCount() { return 10; } public ErrorCode process(JobContext 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 processor configuration */ Map processorConfigMap=((BasicJobControllerConfig)jobContext.getJobConfig().getJobControllerConfig()).getBasicJobProcessorConfigProperties(); 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){} return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; } } --- TestBasicJobProcessor.java DELETED --- --- NEW FILE: VerifyReturnCodeBasicJobControllerTest.java --- /* * VerifyAllConfigPropsProcessorTest.java * JUnit based test * * Created on September 17, 2006, 9:36 AM */ package org.jmonks.batch.framework.controller.basic; 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 VerifyReturnCodeBasicJobControllerTest extends TestCase { public VerifyReturnCodeBasicJobControllerTest(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 VerifyReturnCodeBasicJobControllerTest("testVerifyReturnCode")); return suite; } public void testVerifyReturnCode() { Map configMap=new HashMap(); configMap.put("job-name", "verify_return_code_basic_job_processor"); ErrorCode exitCode=Main.process(configMap); assertNotNull(exitCode); assertEquals(102, exitCode.getCode()); } } --- NEW FILE: VerifyReturnCodeProcessor.java --- /* * VerifyReturnCodeProcessor.java * * Created on September 17, 2006, 12:15 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.basic; import org.jmonks.batch.framework.ErrorCode; import org.jmonks.batch.framework.JobContext; /** * * @author Suresh Pragada */ public class VerifyReturnCodeProcessor extends BasicJobProcessor { /** Creates a new instance of VerifyReturnCodeProcessor */ public VerifyReturnCodeProcessor() { } public long getProcessedRecordsCount() { return 0; } public Object getProcessorState() { return "What am I doing?"; } public long getTotalRecordsCount() { return 10; } public ErrorCode process(JobContext jobContext) { String threadName=Thread.currentThread().getName(); if(threadName.endsWith("1")) return ErrorCode.JOB_COMPLETED_SUCCESSFULLY; else if(threadName.endsWith("2")) throw new RuntimeException("Just wanted to check."); else if(threadName.endsWith("3")) return ErrorCode.createErrorCode(101, "This is my error message"); else return ErrorCode.createErrorCode(102, "This is my error message"); } } |