Just getting more confused. If I increase the "sleep", the "list" increases, too:
public void testTimerStart() throws Exception {
KnowledgeBase kbase = createKnowledgeBase("BPMN2-TimerStart.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
final List list = new ArrayList();
ksession.addEventListener(new DefaultProcessEventListener() {
public void afterProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance().getId());
}
});
Thread.sleep(250);
assertEquals(0, list.size());
for (int i = 0; i < 5; i++) {
ksession.fireAllRules();
Thread.sleep(500);
}
// the longer the time is the more process instances are in "list"
Thread.sleep(3500);
assertEquals(5, list.size());
}
junit.framework.AssertionFailedError: expected:<5> but was:<9>