Uploaded image for project: 'ServiceMix'
  1. ServiceMix
  2. SM-504

Beanflow: Multiple execution of beanflow steps

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • incubation
    • 3.0
    • beanflow
    • None
    • Windows2K, running ServiceMix under JBoss4.0.3SP1

    Description

      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; }

      }

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            hld@bbp.ch Andreas Held
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: