Add global Process Application Event Listener to camunda-engine-unittest

In my appllication I use Global Process Application Event Listener and observe a problem when using them with Call Activities (when writing process variables via the listeners during process deletion). I would like to try to reproduce the problem in a simpler environment to be able to submit a qualified bug report if necessary.

I now wonder how to extend the camunda-engine-unittest test project so that it makes use of Process Application Event Listener. Is there a simple way to “register” these listeners. I did not found a simple way yet.

Hey Franz,

as an example you can see the ProcessApplicationEventListenerTest#testShouldInvokeExecutionListenerOnStartAndEndOfProcessInstance test.

I changed the camunda-engine-unittest regarding to this test case and it worked for me.
Change the SimpleTestCase into this:

public class SimpleTestCase {

  public ProcessEngineRule rule = new ProcessEngineRule();

  public void shouldExecuteProcess() {
    // set up
    BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("startToEnd").startEvent().endEvent().done();
    Deployment deployment = rule.getRepositoryService()
      .addModelInstance("test.bpmn20.xml", modelInstance)

    final AtomicInteger processDefinitionEventCount = new AtomicInteger();
    EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
      public ExecutionListener getExecutionListener() {
        // this process application returns an execution listener
        return new ExecutionListener() {
          public void notify(DelegateExecution execution) throws Exception {
            if (((CoreExecution) execution).getEventSource() instanceof ProcessDefinitionEntity)

    // register app so that it receives events
        .registerProcessApplication(deployment.getId(), processApplication.getReference());

    // Start process instance.

    // Start and end of the process
    assertEquals(2, processDefinitionEventCount.get());

And replace the engine plugins in the camunda.cfg.xml with this plugin:

    <property name="processEnginePlugins">
        <bean class="org.camunda.bpm.application.impl.event.ProcessApplicationEventListenerPlugin" />

Hope it helps.

Best regards,

Hi Chris,

that works, thanks. Would of course be nice if this would be made somehow easier in the camunda-engine-unittest project but afterall it is already possible. Thanks again!

Kind regards,