Beanflow: Multiple execution of beanflow steps ----------------------------------------------
Key: SM-504 URL: https://issues.apache.org/activemq/browse/SM-504 Project: ServiceMix Issue Type: Bug Affects Versions: incubation Environment: Windows2K, running ServiceMix under JBoss4.0.3SP1 Reporter: Andreas Held Consider the following simple Beanflow example: public class TestWorkflow extends Workflow<String> { private static Logger log = Logger.getLogger(TestWorkflow.class.getName()); public static int count = 0; public TestWorkflow() { super("startStep"); } public String startStep() { count += 1; log.info("Workflow: Validation"); // next step return "persistenceStep"; } public String persistenceStep() { count += 1; log.info("Workflow: Persistence"); // next step return "transferStep"; } public String transferStep() { count += 1; log.info("Workflow: Transfer"); // next step return "stop"; } } If I write a JUnit test case with assertEquals(workflow.count, 3); then this will fail, as count has a value of 5. Looking at the log shows the following output: 08:19:26,335 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About to execute step: startStep 08:19:26,351 INFO [ch.bbp.igt.comm.ServiceMix.TestWorkflow.startStep()] FileActWorkflow: Validation 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About to execute step: persistenceStep 08:19:26,351 INFO [ch.bbp.igt.comm.ServiceMix.TestWorkflow.persistenceStep()] FileActWorkflow: Persistence 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About to execute step: persistenceStep 08:19:26,351 INFO [ch.bbp.igt.comm.ServiceMix.TestWorkflow.persistenceStep()] FileActWorkflow: Persistence 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About to execute step: transferStep 08:19:26,351 INFO [ch.bbp.igt.comm.ServiceMix.TestWorkflow.transferStep()] FileActWorkflow: Transfer 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About to execute step: transferStep 08:19:26,351 INFO [ch.bbp.igt.comm.ServiceMix.TestWorkflow.transferStep()] FileActWorkflow: Transfer 08:19:26,351 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About to execute step: stop 08:19:26,367 DEBUG [org.apache.servicemix.beanflow.Workflow.run()] About to execute step: stop This means, all steps but the start step are executed twice! This corresponds to count being 5 in the end! JUnit Testcase : public class WorkflowTest extends TestCase { public WorkflowTest(String s) { super(s); } protected void setUp() { } protected void tearDown() { } public void testTest() throws Exception { TestWorkflow workflow = new TestWorkflow(); workflow.start(); Thread.sleep(2000); assertEquals(3, workflow.count); } public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest(new WorkflowTest("testTest")); return suite; } } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira