AnsweredAssumed Answered

ActivitiRule Unittests fail

Question asked by billdoor on Aug 11, 2014
Latest reply on Aug 19, 2014 by jbarrez
Hello,

I have two testcases, modeled after the Template presented in this Forum. Each single one of them Succeeds, while executing both of them at the same time fails the second one, because "…processInstance updated in concurrent Transaction".

As both of them work fine, it seems the actions taken by ActivitiRule or the @Rule and @Depolyment annotations are not 100% isolated for each Testcase, which kind of contradicts the concept of Unittests i guess?

What am i missing?
Regards + my code and configuration:

Tests (Two times the exact same class with altering Name):

public classProcessTest1 {

   @Rule
   public ActivitiRule engine = new ActivitiRule();

   @Test
   @Deployment (resources={"bpmn/processOne.bpmn20.xml"})
   public void startProcessCopy() throws Exception {
       
      RuntimeService runtimeService = engine.getRuntimeService();

      ProcessInstance instance = runtimeService.startProcessInstanceByKey("processOne");
      
      assertNotNull(instance.getId());
      List<Task> taskList = engine.getTaskService().createTaskQuery().processInstanceId(instance.getId()).taskAssignee("kermit").list();
      assertTrue(taskList.size()==1);
      Map<String, String> params = new HashMap<String, String>();
      params.put("numberOne", "900");
      params.put("numberTwo", "700");
      engine.getFormService().submitTaskFormData(taskList.get(0).getId(), params);
   }
}



activiti.cfg.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

   <bean id="processEngineConfiguration"
      class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"
      >

      <property name="jdbcUrl" value="jdbc:h2:mem:activitiTesting;DB_CLOSE_DELAY=10;FILE_LOCK=FS" />
      <property name="jdbcDriver" value="org.h2.Driver" />
      <property name="jdbcUsername" value="sa" />
      <property name="jdbcPassword" value="" />
      <property name="databaseSchemaUpdate" value="drop-create" />
      <property name="jobExecutorActivate" value="true" />
   </bean>

</beans>


Outcomes