AnsweredAssumed Answered

Best practices for unit testing of TimerCatchingEvent

Question asked by naag on Aug 7, 2012
Latest reply on Aug 7, 2012 by naag
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? :-)