You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Evan Reynolds (JIRA)" <ji...@apache.org> on 2014/01/20 21:09:19 UTC

[jira] [Created] (SCXML-189) Event Replay Scheduler

Evan Reynolds created SCXML-189:
-----------------------------------

             Summary: Event Replay Scheduler
                 Key: SCXML-189
                 URL: https://issues.apache.org/jira/browse/SCXML-189
             Project: Commons SCXML
          Issue Type: New Feature
            Reporter: Evan Reynolds
            Priority: Minor


It can be very hard to unit test state machines that have timers. It can also be hard to replay events in a timely fashion - you hit the timer, and unless you're willing to wait, you can't test.

This is a timer class that I used that acts as a normal event dispatcher. But instead of firing events on a normal schedule, it makes a call available to register the current time. If you call that with new time values, it will fire off any events that have been started that need to be fired off.

So to use this to replay events, simply register the time the event happened, then fire the event. All timers will then take care of themselves. To use it to unit test events, you can go into a state with a timer, call the register time method to move the clock up until the timer should fire, and watch to see what happens.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)