Hi
The point is not the accuracy. it passes the mentioned accuracy.
I don't start a new instance each second. See the main test method:
// make sure the time2 in TaskRepeatAware is null
TaskRepeatAware.time2 = null;
// record time
time0 = System.currentTimeMillis();
// prepare process. Just once, no repeating. I promise
prepareProcess("diagrams/timer/TimerCatcher.bpmn20.xml", "TimerCatcher");
System.out.println("Started. Time = " + System.currentTimeMillis());
// wait enough for the timer start catcher
Thread.sleep(2000);
// it never reaches here. because the timer event is called two times and exception is thrown
// if successful make sure the timer has been fired in acceptable time range
long timeDiff = TaskRepeatAware.time2 - time0;
System.out.println("TimeDiff = " + timeDiff);
assertTrue("Time does not comply", (timeDiff > 1000)
&& (timeDiff < 1050));
where am I creating a new instance each second ?
another proof, just put some system.out.print(System.currentTimeMillis()) in TaskRepeatAware.execute and delete the rest, increase the sleep in above code to say 10 seconds and rerun the test. you will see that the execute method is called just two times, not one each second, one just at the start of the process and the other one seconds later. the first call is the culprit.
neither <timeDuration>PT1S</timeDuration> does not include "R/" for reoccurance.
– saeid