1 Reply Latest reply on Apr 27, 2011 3:33 PM by Amin MC

    JUnit test and process instance variables

    Amin MC Newbie

      Hi

       

      I have encountered an interesting scenario of my test failing when I run it but passing when I debug the test.  Basically I have the following code

       

      WorkflowProcessInstance instance = (WorkflowProcessInstance)session.getProcessInstance(processInstanceId);

      DataObject dataObject = instance.getVariable(variableName);

       

      session.signalEvent(..);

       

      WorkflowProcessInstance instance = (WorkflowProcessInstance)session.getProcessInstance(processInstanceId);

      DataObject reloaded = instance.getVariable(variableName);

       

      if (dataObject is not same as reloaded) {

           doSomething();

      }

       

       

      What I notice is that when i run the test reloaded hasn't been updated when i expect it to be as defined in my flow.  However when I debug and wait a second or two reload gets updated and the condition is evaluated.  My test basically starts the flow and then performs the signal. 

       

      I was wondering if anyone has experienced this issue?  When running the code outside of a test it works as expected but not within a test.

       

      Any help would be appreciated. 

       

      Cheers

        • 1. JUnit test and process instance variables
          Amin MC Newbie

          I think I've figured out why this is happening.  I call signal and then code returns and if i debug i give the engine a chance to update the variable whereas when i run it the engine may not have had a chance to update.

           

          Is there a way to find out if a variable has been updated after a signal?  I have a usecase where I need to know if the workflow engine has modified a variable or not when i execute a signal.