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:13:20 UTC

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

    [ https://issues.apache.org/jira/browse/SCXML-189?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13876817#comment-13876817 ] 

Evan Reynolds commented on SCXML-189:
-------------------------------------

I attached the java file. I have unit tests but before converting them to something that makes sense for Apache Commons I wanted to see if this file was something you guys would be interested in including.

> 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
>         Attachments: ReplayScheduler.java
>
>
> 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)