Unit Test - How to configure multiple sub processes waiting for results

214 views
Skip to first unread message

Sarath K S

unread,
Sep 16, 2015, 2:18:19 AM9/16/15
to camunda-...@googlegroups.com
Hi All,

We have a case here where we need to spawn multiple sub processes and then wait for getting messages from all of them. This was working fine until the sub processes started notifying the main process at the same time. 

We tried to solve this by spawning multiple sub process (one each for every sub process) that would wait to hear back from each of the sub process. This is working fine. But we have an issue when running this from the Camunda Unit Tests. We have attached Unit Tests that reproduces this issue.

We believe this is because the Junit Framework runs single threaded. We also noticed that running with async property enabled also has the same issue. Is there some way to get this running in the Unit Tests? 

Thanks & Regards,
Sarath
camunda-engine-unittest.tar.gz

thorben....@camunda.com

unread,
Sep 23, 2015, 4:30:03 AM9/23/15
to camunda BPM users
Hi Sarath,

It is a known limitation that queries do not return entities that were previously created in the same transaction. Since your entire process runs in one transaction, the result event subscription is not returned in the "Send Result" task. I suggest you add an asynchronous continuation before EnvTest.StartSessionResult to enforce a transaction boundary.

Cheers,
Thorben

Sarath K S

unread,
Sep 25, 2015, 5:03:37 AM9/25/15
to camunda BPM users
Hi Thorben,

If we enable the asynchronous continuation before, the unit test completes. But still we are not able to see the results in the console. I think even the ResultProcessCreator.java and ResultReceived.java is not getting called in the test.

Thanks & Regards,
Sarath

thorben....@camunda.com

unread,
Sep 25, 2015, 5:09:31 AM9/25/15
to camunda BPM users
Hi Sarath,

Did you add code that executes the asynchronous continuation job to the test cases? In a unit test environment, the job executor is deactivated to avoid parallel, uncontrolled execution. You can use the ManagementService to query for the asynchronous continuation job (#createJobQuery) and execute it (#executeJob).

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