cancel
Showing results for 
Search instead for 
Did you mean: 

Best practices for unit testing of TimerCatchingEvent

naag
Champ in-the-making
Champ in-the-making
Hi all,

I'm wondering what is the best approach to unit test a process with a TimerCatchingEvent. Let's say this event is scheduled to be a few days in the future, then I certainly don't want to Thread.sleep(veryBigNumber)…. 🙂 For some background: our tests run with Arquillian inside a JBoss AS 7.1 container, so full JavaEE is available.

One option would be to just test a slightly different version of the business process, where the timer is set to just 1 second or something. Then we can sleep a while and check if the work is done or not. But this would mean that we need to keep two versions of the process around (potential for errors here).

The other thing I had on mind was to modify the job inside the DB manually, so the job executor will pick it up earlier. However I'm not sure how to do this properly… I imagine finding the execution from ACT_RU_EXECUTION, then going to ACT_RU_JOB and modify it directly via SQL. Or could I hijack some (internal) Activiti API for that?

What are your thoughts? How are you doing this in your tests? 🙂

Regards
Peter
2 REPLIES 2

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
DON'T CHANGE THE PROCESS…!!! Use the management service to explicity execute the jobs…

naag
Champ in-the-making
Champ in-the-making
Perfect! I didn't know that the management service would force the execution Smiley Surprisedops:

Thanks a lot! 🙂