Boundary timer event unittest - what do i do wrong ?

449 views
Skip to first unread message

Jan Hölter

unread,
Nov 18, 2014, 10:32:18 AM11/18/14
to camunda-...@googlegroups.com
Hello everybody, i am facing a problem unittesting a boundary timer event and i am hoping for some hints about what i do wrong.

What do i want to achieve

I have a case where a process has to be aborted when a certain usertask is not finished within a period. When the usertask is finished in time, the process should go on.
This is how we modeled it:



I am developing the test first and the process test perfectly walks through all previous steps.
At this point i want to assert that the process is waiting at the user task. To assure this i configured the timer in a way it shouldn't be fired:



Ususally there should be a period like P10D that - if i understood correctly - would fire the event after 10 Days. From Day 1 - 10 the Process should be providing the Usertask in my expectation.
I also tried the period (in the Duration section)...that also didn't work.

What happens

Somehow the timer-event is fired and the process instance is not alive anymore when i try to assert that is waiting on the user task.
When i query the engine there is no active process instance.
I debugged that for a while now and have no clue why that happens.

One important information. We deactivated the job executor for our unittests to be able to handle asynchronous tasks or events.
Here is our Spring config for that:
@Bean
   
public ProcessEngineConfigurationImpl springProcessEngineConfiguration() {
       
StandaloneInMemProcessEngineConfiguration config = new StandaloneInMemProcessEngineConfiguration();
        config
.setJdbcUrl("jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000");
        config
.setJdbcDriver("org.h2.Driver");
        config
.setJdbcUsername("sa");
        config
.setJdbcPassword("");
       
        config
.setDatabaseSchemaUpdate("true");
        config
.setMailServerPort(5025);
       
       
// mache asynchrone Jobs synchron und damit testbar
        config
.setJobExecutorActivate(false);
       
       
return config;
   
}


Any idea what i do wrong ?
Thanks for helping.


Jan Hölter

unread,
Nov 18, 2014, 10:35:27 AM11/18/14
to camunda-...@googlegroups.com

Somehow my pictures got lost...
Here is the whole thing (process extract and timer config)

Ingo Richtsmeier

unread,
Nov 18, 2014, 8:16:25 PM11/18/14
to camunda-...@googlegroups.com
Hello Jan,

try this static block in your jUnit-test, it shows a lot more information on the console: (Maybe you can start without Mybatis logging)

  // enable more detailed logging
  static {
    LogUtil.readJavaUtilLoggingConfigFromClasspath(); // process engine
    LogFactory.useJdkLogging(); // MyBatis
  }

And have a look at these example how to handle the timer in a jUnit-Test:


Kind Regards, Ingo


Am Dienstag, 18. November 2014 23:32:18 UTC+8 schrieb Jan Hölter:
Hello everybody, i am facing a problem unittesting a boundary timer event and i am hoping for some hints about what i do wrong.

What do i want to achieve

I have a case where a process has to be aborted when a certain usertask is not finished within a period. When the usertask is finished in time, the process should go on.
This is how we modeled it:



I am developing the test first and the process test perfectly walks through all previous steps.
At this point i want to assert that the process is waiting at the user task. To assure this i configured the timer in a way it shouldn't be fired:

...

Sebastian Menski

unread,
Nov 19, 2014, 4:33:16 AM11/19/14
to camunda-...@googlegroups.com
Hi Jan,

could you provide a minimal unit test which demonstrates your problem? Maybe with our unit test template [1]?

Cheers,
Sebastian

Jan Hölter

unread,
Nov 19, 2014, 6:07:16 AM11/19/14
to camunda-...@googlegroups.com
Thank you Ingo and Sebastian,

turned out that it we actually were doing something wrong.
Your hints about logging and the examples helped a lot to determine the problem.

I figured out two things:
1. The reason the timer event was fired in the first place was because at that time my configuration of the timer was just wrong.
2. After i fixed that i still got "process instance ended" because we had a bug in our test api which caused the query to search for the instance a subprocess (which indeed was finished) instead of my actual process instance.

So thanks a lot again for guiding me by giving the right hints.



Am Dienstag, 18. November 2014 16:32:18 UTC+1 schrieb Jan Hölter:
Hello everybody, i am facing a problem unittesting a boundary timer event and i am hoping for some hints about what i do wrong.

What do i want to achieve

I have a case where a process has to be aborted when a certain usertask is not finished within a period. When the usertask is finished in time, the process should go on.
This is how we modeled it:



I am developing the test first and the process test perfectly walks through all previous steps.
At this point i want to assert that the process is waiting at the user task. To assure this i configured the timer in a way it shouldn't be fired:

...
Reply all
Reply to author
Forward
0 new messages