test/scheduler_0_test.rb in rufus-scheduler-1.0.6 vs test/scheduler_0_test.rb in rufus-scheduler-1.0.7
- old
+ new
@@ -1,8 +1,8 @@
#
-# Testing OpenWFE
+# Testing Rufus
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#
@@ -27,12 +27,11 @@
#Thread.abort_on_exception = true
$var = nil
- scheduler = OpenWFE::Scheduler.new
- scheduler.sstart
+ scheduler = Rufus::Scheduler.start_new
sid = scheduler.schedule_in('2s', :schedulable => TestSchedulable.new)
assert \
sid,
@@ -58,12 +57,12 @@
def test_scheduler_1
$var = nil
- scheduler = OpenWFE::Scheduler.new
- scheduler.sstart
+ scheduler = Rufus::Scheduler.new
+ scheduler.start
sid = scheduler.schedule_in('1s') do
$var = "ok..1"
end
@@ -88,12 +87,12 @@
#
def test_scheduler_2
text = ""
- scheduler = OpenWFE::Scheduler.new()
- scheduler.sstart
+ scheduler = Rufus::Scheduler.new()
+ scheduler.start
scheduler.schedule_in("1s") do
text << "one"
sleep(2)
end
@@ -115,12 +114,11 @@
#
def test_scheduler_4
Thread.abort_on_exception = true
- scheduler = OpenWFE::Scheduler.new()
- scheduler.sstart
+ scheduler = Rufus::Scheduler.start_new
#
# phase 0
count = 0
@@ -147,11 +145,11 @@
es = EverySchedulable.new
job_id = scheduler.schedule_every "500", es
#puts "1 job_id : " + job_id.to_s
-
+
#sleep(3.4) # was a bit soonish for JRuby...
sleep 3.5
#assert_job_count scheduler, 0, 0, 2
assert_equal 6, es.count
@@ -172,12 +170,12 @@
# requests where t < scheduler.frequency.
# (100ms < 250ms)
#
def test_scheduler_5
- scheduler = OpenWFE::Scheduler.new
- scheduler.sstart
+ scheduler = Rufus::Scheduler.new
+ scheduler.start
touched = false
scheduler.schedule_in "100" do
touched = true
@@ -191,11 +189,11 @@
#
# Testing to see if a second job with the same id discards the first one.
#
def test_scheduler_6
- scheduler = OpenWFE::Scheduler.new
+ scheduler = Rufus::Scheduler.new
scheduler.start
#class << scheduler
# attr_reader :pending_jobs
#end
@@ -265,11 +263,11 @@
#
# Scheduling in the past, with :discard_past set to true.
#
def test_8b
- scheduler = OpenWFE::Scheduler.new
+ scheduler = Rufus::Scheduler.new
scheduler.start
var = nil
job_id = scheduler.schedule_at(Time.now.to_s, :discard_past => true) do
@@ -285,11 +283,11 @@
#
# Testing restarting the scheduler.
#
def test_9
- scheduler = OpenWFE::Scheduler.new
+ scheduler = Rufus::Scheduler.new
scheduler.start
value = nil
scheduler.schedule_in "2s" do
@@ -315,28 +313,28 @@
def test_10
e = nil
begin
- OpenWFE::Scheduler.new.precision = 10
+ Rufus::Scheduler.new.precision = 10
rescue Exception => e
end
assert_not_nil e, "exception not caught"
end
protected
class TestSchedulable
- include OpenWFE::Schedulable
+ include Rufus::Schedulable
def trigger (params)
$var = "ok"
end
end
class EverySchedulable
- include OpenWFE::Schedulable
+ include Rufus::Schedulable
attr_accessor :job_id, :count
def initialize
@job_id = -1