camunda bpmn testing without spring ?

1,875 views
Skip to first unread message

nds.t...@gmail.com

unread,
Aug 7, 2014, 8:15:59 AM8/7/14
to camunda-...@googlegroups.com
Hi,

I try to test my bpmn diagram, and i've find this example:
--
https://github.com/camunda/camunda-bpm-examples/blob/master/bpmn-model-api/generate-process-fluent-api/src/test/java/org/camunda/bpm/quickstart/CreateInvoiceProcessTest.java
--

but i can't instantiate ProcessEngineRule :

public ProcessEngineRule processEngine = new ProcessEngineRule();

this throw a message :
------------------------
org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
Infos: Loading XML bean definitions from class path resource [activiti.cfg.xml]
----------------------


full error trace:
----------------------
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [activiti.cfg.xml]; nested exception is java.io.FileNotFoundException: class path resource [activiti.cfg.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.camunda.bpm.engine.impl.cfg.BeansConfigurationHelper.parseProcessEngineConfiguration(BeansConfigurationHelper.java:35)
at org.camunda.bpm.engine.impl.cfg.BeansConfigurationHelper.parseProcessEngineConfigurationFromResource(BeansConfigurationHelper.java:48)
at org.camunda.bpm.engine.ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(ProcessEngineConfiguration.java:174)
at org.camunda.bpm.engine.ProcessEngineConfiguration.createProcessEngineConfigurationFromResource(ProcessEngineConfiguration.java:170)
at org.camunda.bpm.engine.test.ProcessEngineRule.initializeProcessEngine(ProcessEngineRule.java:112)
at org.camunda.bpm.engine.test.ProcessEngineRule.starting(ProcessEngineRule.java:99)
at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:51)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.io.FileNotFoundException: class path resource [activiti.cfg.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 23 more
-------------------------------

I don't use spring, just the standalone camunda version, so i don't have camunda.cfg.xml file in /ressources.

How to test my camunda bpmn diagram without spring ?

Sebastian Menski

unread,
Aug 7, 2014, 9:12:18 AM8/7/14
to camunda-...@googlegroups.com, nds.t...@gmail.com
Hi,

what do you mean with test the BPMN diagram? You don't need spring, the camunda bpm
platform uses spring to bootstrap. That's why it searches for a camunda.cfg.xml.

If you want to write unit tests for your process execution have a look at your

If you can describe your use case more I think we can help you better.

Cheers,
Sebastian

Tina

unread,
Oct 21, 2014, 4:11:56 PM10/21/14
to camunda-...@googlegroups.com, nds.t...@gmail.com
Hi Sebastian, 
I am having the same problem. My question is that why is it looking for activiti.cfg.xml? 

Oct 21, 2014 3:53:14 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [camunda.cfg.xml]
Oct 21, 2014 3:53:14 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [activiti.cfg.xml]

While it seems to work fine looking for camunda.cfg.xml, but activiti,cfg,xml????

I wrote a unit test for the example: Getting Started with camunda BPM and the Spring Framework
Unit test: 

package org.camunda.bpm.getstarted.loanapproval;

import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.runtimeService;

import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.test.ProcessEngineRule;
import org.junit.Rule;
import org.junit.Test;

public class UnitTest {

    @Rule
    public ProcessEngineRule processEngineRule = new ProcessEngineRule();

    @Test
    @Deployment(resources = {"loanApproval.bpmn"})
    public void testTestTest() {

        ProcessInstance processInstance = runtimeService().startProcessInstanceByKey("loanApproval");

        System.out.println(processInstance.getProcessDefinitionId());
    }
}


I even added the camunda.cfg.xml file from your example. And it keep failing because it fails to find the activiti.cfg,xml. 

Cheers, 
Tina

Christian Lipphardt

unread,
Oct 21, 2014, 5:11:53 PM10/21/14
to camunda-...@googlegroups.com, nds.t...@gmail.com
Hi Tina,

The junit rule is falling back to activiti.cfg.xml because it did not find camunda.cfg.xml in the classpath. It is a backward compatibility step when we forked form activiti to ease the migration from activiti to camunda bpm.
Anyway, you can also create the process engine programmatically without a camunda.cfg.xml.

protected ProcessEngine createProcessEngineProgramatically() {
  StandaloneInMemProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();
  processEngineConfiguration.setCustomPostBPMNParseListeners(Arrays.asList(new BpmnParseListener[]{new FoxFailedJobParseListener()}));
  return processEngineConfiguration.buildProcessEngine();
}

@Rule
public ProcessEngineRule rule = new ProcessEngineRule(createProcessEngineProgramatically());

Cheers,
Christian
Reply all
Reply to author
Forward
0 new messages