test/scheduler_test.rb in openwferu-0.9.11 vs test/scheduler_test.rb in openwferu-0.9.12
- old
+ new
@@ -6,11 +6,10 @@
#
# Sun Oct 29 16:18:25 JST 2006
#
require 'test/unit'
-#require 'openwfe/otime'
require 'openwfe/util/scheduler'
#
# testing otime and the scheduler
#
@@ -25,11 +24,11 @@
def test_scheduler_0
$var = nil
- scheduler = OpenWFE::Scheduler.new()
+ scheduler = OpenWFE::Scheduler.new
scheduler.sstart
sid = scheduler.schedule_in('2s', :schedulable => TestSchedulable.new)
assert \
@@ -38,25 +37,23 @@
assert \
(not $var),
"scheduler_0 is blocking but should not"
- sleep(2.5)
+ sleep 2.5
scheduler.sstop
#puts ">#{$var}<"
- assert \
- ($var == "ok"),
- "scheduler_0 didn't work"
+ assert_equal "ok", $var
end
def test_scheduler_1
$var = nil
- scheduler = OpenWFE::Scheduler.new()
+ scheduler = OpenWFE::Scheduler.new
scheduler.sstart
sid = scheduler.schedule_in('1s') do
$var = "ok..1"
end
@@ -67,18 +64,16 @@
assert \
(not $var),
"scheduler_1 is blocking but should not"
- sleep(2)
+ sleep 2
scheduler.sstop
#puts ">#{$var}<"
- assert \
- ($var == "ok..1"),
- "scheduler_1 didn't work"
+ assert "ok..1", $var
end
#
# test idea by ara.t.howard on the ruby-talk ml
#
@@ -101,11 +96,11 @@
scheduler.sstop
#puts text
- assert text == "onetwo"
+ assert_equal text, "onetwo"
end
#
# test Scheduler::is_cron_string(s)
@@ -145,11 +140,11 @@
es = EverySchedulable.new
job_id = scheduler.schedule_every("500", es)
#job_id = scheduler.schedule_every("500", :schedulable => es)
- sleep(3.2)
+ sleep(3.4)
assert_equal es.count, 6
scheduler.unschedule(job_id)
@@ -167,11 +162,11 @@
# requests where t < scheduler.frequency.
# (100ms < 250ms)
#
def test_scheduler_5
- scheduler = OpenWFE::Scheduler.new()
+ scheduler = OpenWFE::Scheduler.new
scheduler.sstart
touched = false
scheduler.schedule_in "100" do
@@ -186,10 +181,10 @@
#
# Testing to see if a second job with the same id discards the first one.
#
def test_scheduler_6
- scheduler = OpenWFE::Scheduler.new()
+ scheduler = OpenWFE::Scheduler.new
scheduler.start
value = nil
scheduler.schedule_in "3s", :job_id => "job" do