Sha256: 5adfbc3110cd858d70a0e1c152b4e9c6fb64175fab36cbd67179d0983d200ae6
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
# # Testing OpenWFE # # John Mettraux at openwfe.org # # Sun Oct 29 16:18:25 JST 2006 # require 'test/unit' #require 'openwfe/otime' require 'openwfe/util/scheduler' # # testing otime and the scheduler # class SchedulerTest < Test::Unit::TestCase #def setup #end #def teardown #end def test_scheduler_0 $var = nil scheduler = OpenWFE::Scheduler.new() scheduler.sstart sid = scheduler.schedule_in('2s', TestSchedulable.new, nil) assert \ sid, "scheduler_0 did not return a job id" assert \ (not $var), "scheduler_0 is blocking but should not" sleep(2.5) scheduler.sstop #puts ">#{$var}<" assert \ ($var == "ok"), "scheduler_0 didn't work" end def test_scheduler_1 $var = nil scheduler = OpenWFE::Scheduler.new() scheduler.sstart sid = scheduler.schedule_in('1s') do $var = "ok..1" end assert \ sid, "scheduler_1 did not return a job id" assert \ (not $var), "scheduler_1 is blocking but should not" sleep(2) scheduler.sstop #puts ">#{$var}<" assert \ ($var == "ok..1"), "scheduler_1 didn't work" end # # test idea by ara.t.howard on the ruby-talk ml # def test_scheduler_2 text = "" scheduler = OpenWFE::Scheduler.new() scheduler.sstart scheduler.schedule_in("1s") do text << "one" sleep(2) end scheduler.schedule_in("1s") do text << "two" end sleep(2) scheduler.sstop #puts text assert text == "onetwo" end protected class TestSchedulable include OpenWFE::Schedulable def trigger (params) $var = "ok" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openwferu-0.9.5 | test/scheduler_test.rb |