rufus-scheduler 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/test/cron_test.rb CHANGED
@@ -17,118 +17,118 @@ require 'openwfe/util/scheduler'
17
17
  #
18
18
  class CronTest < Test::Unit::TestCase
19
19
 
20
- #def setup
21
- #end
20
+ #def setup
21
+ #end
22
22
 
23
- #def teardown
24
- #end
23
+ #def teardown
24
+ #end
25
25
 
26
- def test_0
26
+ def test_0
27
27
 
28
- $var = 0
28
+ $var = 0
29
29
 
30
- scheduler = OpenWFE::Scheduler.new
31
- scheduler.start
30
+ scheduler = OpenWFE::Scheduler.new
31
+ scheduler.start
32
32
 
33
- sid = scheduler.schedule(
34
- '* * * * *',
35
- :schedulable => CounterSchedulable.new)
33
+ sid = scheduler.schedule(
34
+ '* * * * *',
35
+ :schedulable => CounterSchedulable.new)
36
36
 
37
- assert sid, "scheduler did not return a job id"
37
+ assert sid, "scheduler did not return a job id"
38
38
 
39
- sleep 120
40
- scheduler.stop
39
+ sleep 120
40
+ scheduler.stop
41
41
 
42
- #puts ">#{$var}<"
42
+ #puts ">#{$var}<"
43
43
 
44
- assert_equal 2, $var
45
- end
44
+ assert_equal 2, $var
45
+ end
46
+
47
+ def test_1
48
+
49
+ scheduler = OpenWFE::Scheduler.new
50
+ scheduler.start
46
51
 
47
- def test_1
48
-
49
- scheduler = OpenWFE::Scheduler.new
50
- scheduler.start
51
-
52
- sec = nil
53
- has_gone_wrong = false
54
- counter = 0
55
-
56
- scheduler.schedule "* * * * * *" do
57
- t = Time.new
58
- if (t.sec == sec)
59
- has_gone_wrong = true
60
- # print "x"
61
- #else
62
- # print "."
63
- end
64
- #STDOUT.flush
65
- sec = t.sec
66
- counter = counter + 1
67
- end
68
-
69
- sleep 10
70
- scheduler.stop
71
-
72
- #assert_equal 10, counter
73
- assert [ 9, 10 ].include?(counter), "not 9 or 10 but #{counter}"
74
- assert (not has_gone_wrong)
52
+ sec = nil
53
+ has_gone_wrong = false
54
+ counter = 0
55
+
56
+ scheduler.schedule "* * * * * *" do
57
+ t = Time.new
58
+ if (t.sec == sec)
59
+ has_gone_wrong = true
60
+ # print "x"
61
+ #else
62
+ # print "."
63
+ end
64
+ #STDOUT.flush
65
+ sec = t.sec
66
+ counter = counter + 1
75
67
  end
76
68
 
77
- def test_2
69
+ sleep 10
70
+ scheduler.stop
78
71
 
79
- scheduler = OpenWFE::Scheduler.new
80
- scheduler.start
72
+ #assert_equal 10, counter
73
+ assert [ 9, 10 ].include?(counter), "not 9 or 10 but #{counter}"
74
+ assert (not has_gone_wrong)
75
+ end
81
76
 
82
- counter = 0
77
+ def test_2
83
78
 
84
- scheduler.schedule "7 * * * * *" do
85
- counter += 1
86
- end
79
+ scheduler = OpenWFE::Scheduler.new
80
+ scheduler.start
87
81
 
88
- sleep 61
89
- scheduler.stop
82
+ counter = 0
90
83
 
91
- assert_equal 1, counter
92
- # baby just one ... time
84
+ scheduler.schedule "7 * * * * *" do
85
+ counter += 1
93
86
  end
94
87
 
95
- #
96
- # testing cron unschedule
97
- #
98
- def test_3
88
+ sleep 61
89
+ scheduler.stop
99
90
 
100
- scheduler = OpenWFE::Scheduler.new
101
- scheduler.start
91
+ assert_equal 1, counter
92
+ # baby just one ... time
93
+ end
102
94
 
103
- counter = 0
95
+ #
96
+ # testing cron unschedule
97
+ #
98
+ def test_3
104
99
 
105
- job_id = scheduler.schedule "* * * * *" do
106
- counter += 1
107
- end
100
+ scheduler = OpenWFE::Scheduler.new
101
+ scheduler.start
108
102
 
109
- sleep 0.300
103
+ counter = 0
110
104
 
111
- #puts "job_id : #{job_id}"
105
+ job_id = scheduler.schedule "* * * * *" do
106
+ counter += 1
107
+ end
112
108
 
113
- assert_equal 1, scheduler.cron_job_count
109
+ sleep 0.300
114
110
 
115
- scheduler.unschedule job_id
111
+ #puts "job_id : #{job_id}"
116
112
 
117
- sleep 0.300
113
+ assert_equal 1, scheduler.cron_job_count
118
114
 
119
- assert_equal 0, scheduler.cron_job_count
115
+ scheduler.unschedule job_id
120
116
 
121
- scheduler.stop
122
- end
117
+ sleep 0.300
118
+
119
+ assert_equal 0, scheduler.cron_job_count
123
120
 
124
- protected
121
+ scheduler.stop
122
+ end
125
123
 
126
- class CounterSchedulable
127
- include OpenWFE::Schedulable
124
+ protected
128
125
 
129
- def trigger (params)
130
- $var = $var + 1
131
- end
132
- end
126
+ class CounterSchedulable
127
+ include OpenWFE::Schedulable
128
+
129
+ def trigger (params)
130
+ $var = $var + 1
131
+ end
132
+ end
133
133
 
134
134
  end
@@ -18,38 +18,44 @@ require 'rufus/scheduler'
18
18
  #
19
19
  class CronLineTest < Test::Unit::TestCase
20
20
 
21
- #def setup
22
- #end
21
+ #def setup
22
+ #end
23
23
 
24
- #def teardown
25
- #end
24
+ #def teardown
25
+ #end
26
26
 
27
- def test_0
27
+ def test_0
28
28
 
29
- dotest "* * * * *", [ [0], nil, nil, nil, nil, nil ]
30
- dotest "10-12 * * * *", [ [0], [10, 11, 12], nil, nil, nil, nil ]
31
- dotest "* * * * sun,mon", [ [0], nil, nil, nil, nil, [7, 1] ]
32
- dotest "* * * * mon-wed", [ [0], nil, nil, nil, nil, [1, 2, 3] ]
29
+ dotest "* * * * *", [ [0], nil, nil, nil, nil, nil ]
30
+ dotest "10-12 * * * *", [ [0], [10, 11, 12], nil, nil, nil, nil ]
31
+ dotest "* * * * sun,mon", [ [0], nil, nil, nil, nil, [0, 1] ]
32
+ dotest "* * * * mon-wed", [ [0], nil, nil, nil, nil, [1, 2, 3] ]
33
+ dotest "* * * * 7", [ [0], nil, nil, nil, nil, [0] ]
34
+ dotest "* * * * 0", [ [0], nil, nil, nil, nil, [0] ]
35
+ dotest "* * * * 0,1", [ [0], nil, nil, nil, nil, [0,1] ]
36
+ dotest "* * * * 7,1", [ [0], nil, nil, nil, nil, [0,1] ]
37
+ dotest "* * * * 7,0", [ [0], nil, nil, nil, nil, [0] ]
38
+ dotest "* * * * sun,2-4", [ [0], nil, nil, nil, nil, [0, 2, 3, 4] ]
33
39
 
34
- #dotest "* * * * sun,mon-tue", [ [0], nil, nil, nil, nil, [7, 1, 2] ]
35
- #dotest "* * * * 7-1", [ [0], nil, nil, nil, nil, [7, 1, 2] ]
36
- end
40
+ dotest "* * * * sun,mon-tue", [ [0], nil, nil, nil, nil, [0, 1, 2] ]
41
+ #dotest "* * * * 7-1", [ [0], nil, nil, nil, nil, [0, 1, 2] ]
42
+ end
37
43
 
38
- def test_1
44
+ def test_1
39
45
 
40
- dotest "* * * * * *", [ nil, nil, nil, nil, nil, nil ]
41
- dotest "1 * * * * *", [ [1], nil, nil, nil, nil, nil ]
42
- dotest "7 10-12 * * * *", [ [7], [10, 11, 12], nil, nil, nil, nil ]
43
- dotest "1-5 * * * * *", [ [1,2,3,4,5], nil, nil, nil, nil, nil ]
44
- end
46
+ dotest "* * * * * *", [ nil, nil, nil, nil, nil, nil ]
47
+ dotest "1 * * * * *", [ [1], nil, nil, nil, nil, nil ]
48
+ dotest "7 10-12 * * * *", [ [7], [10, 11, 12], nil, nil, nil, nil ]
49
+ dotest "1-5 * * * * *", [ [1,2,3,4,5], nil, nil, nil, nil, nil ]
50
+ end
45
51
 
46
- protected
52
+ protected
47
53
 
48
- def dotest (line, array)
54
+ def dotest (line, array)
49
55
 
50
- cl = Rufus::CronLine.new(line)
56
+ cl = Rufus::CronLine.new(line)
51
57
 
52
- assert_equal array, cl.to_array
53
- end
58
+ assert_equal array, cl.to_array
59
+ end
54
60
 
55
61
  end
data/test/dev.rb ADDED
@@ -0,0 +1,28 @@
1
+
2
+ #require 'rubygems'
3
+ require 'rufus/scheduler'
4
+
5
+ s = Rufus::Scheduler.new
6
+ s.precision = 1.250
7
+ #s.precision = 0.250
8
+ #s.precision = 30
9
+ s.start
10
+
11
+ def compute_dev (s, t0, t1)
12
+
13
+ return 0.0 unless t0
14
+ s.precision - (t1 - t0)
15
+ end
16
+
17
+ tprev = nil
18
+ tcurr = nil
19
+
20
+ #s.schedule "* * * * * *" do
21
+ s.schedule "* * * * *" do
22
+ tprev = tcurr
23
+ tcurr = Time.new
24
+ puts "#{tcurr.to_s} #{tcurr.to_f} (#{compute_dev(s, tprev, tcurr)})"
25
+ end
26
+
27
+ s.join
28
+
@@ -15,347 +15,347 @@ require 'openwfe/util/scheduler'
15
15
  # testing otime and the scheduler
16
16
  #
17
17
 
18
- class SchedulerTest < Test::Unit::TestCase
18
+ class Scheduler0Test < Test::Unit::TestCase
19
19
 
20
- #def setup
21
- #end
20
+ #def setup
21
+ #end
22
22
 
23
- #def teardown
24
- #end
23
+ #def teardown
24
+ #end
25
+
26
+ def test_scheduler_0
27
+
28
+ #Thread.abort_on_exception = true
29
+
30
+ $var = nil
31
+
32
+ scheduler = OpenWFE::Scheduler.new
33
+ scheduler.sstart
25
34
 
26
- def test_scheduler_0
35
+ sid = scheduler.schedule_in('2s', :schedulable => TestSchedulable.new)
27
36
 
28
- #Thread.abort_on_exception = true
37
+ assert \
38
+ sid,
39
+ "scheduler_0 did not return a job id"
29
40
 
30
- $var = nil
41
+ assert \
42
+ (not $var),
43
+ "scheduler_0 is blocking but should not"
31
44
 
32
- scheduler = OpenWFE::Scheduler.new
33
- scheduler.sstart
45
+ sleep 2.5
34
46
 
35
- sid = scheduler.schedule_in('2s', :schedulable => TestSchedulable.new)
47
+ assert_equal 0, scheduler.cron_job_count
48
+ assert_equal 0, scheduler.every_job_count
49
+ assert_equal 0, scheduler.at_job_count
50
+ assert_equal 0, scheduler.pending_job_count
36
51
 
37
- assert \
38
- sid,
39
- "scheduler_0 did not return a job id"
52
+ scheduler.sstop
40
53
 
41
- assert \
42
- (not $var),
43
- "scheduler_0 is blocking but should not"
54
+ #puts ">#{$var}<"
44
55
 
45
- sleep 2.5
56
+ assert_equal "ok", $var
57
+ end
46
58
 
47
- assert_equal 0, scheduler.cron_job_count
48
- assert_equal 0, scheduler.every_job_count
49
- assert_equal 0, scheduler.at_job_count
50
- assert_equal 0, scheduler.pending_job_count
59
+ def test_scheduler_1
51
60
 
52
- scheduler.sstop
61
+ $var = nil
53
62
 
54
- #puts ">#{$var}<"
63
+ scheduler = OpenWFE::Scheduler.new
64
+ scheduler.sstart
55
65
 
56
- assert_equal "ok", $var
66
+ sid = scheduler.schedule_in('1s') do
67
+ $var = "ok..1"
57
68
  end
58
69
 
59
- def test_scheduler_1
70
+ assert \
71
+ sid,
72
+ "scheduler_1 did not return a job id"
60
73
 
61
- $var = nil
74
+ assert \
75
+ (not $var),
76
+ "scheduler_1 is blocking but should not"
62
77
 
63
- scheduler = OpenWFE::Scheduler.new
64
- scheduler.sstart
78
+ sleep 2
79
+ scheduler.sstop
65
80
 
66
- sid = scheduler.schedule_in('1s') do
67
- $var = "ok..1"
68
- end
81
+ #puts ">#{$var}<"
69
82
 
70
- assert \
71
- sid,
72
- "scheduler_1 did not return a job id"
83
+ assert "ok..1", $var
84
+ end
73
85
 
74
- assert \
75
- (not $var),
76
- "scheduler_1 is blocking but should not"
86
+ #
87
+ # test idea by ara.t.howard on the ruby-talk ml
88
+ #
89
+ def test_scheduler_2
77
90
 
78
- sleep 2
79
- scheduler.sstop
91
+ text = ""
80
92
 
81
- #puts ">#{$var}<"
93
+ scheduler = OpenWFE::Scheduler.new()
94
+ scheduler.sstart
82
95
 
83
- assert "ok..1", $var
96
+ scheduler.schedule_in("1s") do
97
+ text << "one"
98
+ sleep(2)
99
+ end
100
+ scheduler.schedule_in("1s") do
101
+ text << "two"
84
102
  end
85
103
 
86
- #
87
- # test idea by ara.t.howard on the ruby-talk ml
88
- #
89
- def test_scheduler_2
90
-
91
- text = ""
104
+ sleep(2)
92
105
 
93
- scheduler = OpenWFE::Scheduler.new()
94
- scheduler.sstart
106
+ scheduler.sstop
95
107
 
96
- scheduler.schedule_in("1s") do
97
- text << "one"
98
- sleep(2)
99
- end
100
- scheduler.schedule_in("1s") do
101
- text << "two"
102
- end
108
+ #puts text
103
109
 
104
- sleep(2)
110
+ assert_equal text, "onetwo"
111
+ end
105
112
 
106
- scheduler.sstop
113
+ #
114
+ # Testing schedule_every()
115
+ #
116
+ def test_scheduler_4
107
117
 
108
- #puts text
118
+ Thread.abort_on_exception = true
109
119
 
110
- assert_equal text, "onetwo"
111
- end
120
+ scheduler = OpenWFE::Scheduler.new()
121
+ scheduler.sstart
112
122
 
113
123
  #
114
- # Testing schedule_every()
115
- #
116
- def test_scheduler_4
124
+ # phase 0
117
125
 
118
- Thread.abort_on_exception = true
126
+ count = 0
119
127
 
120
- scheduler = OpenWFE::Scheduler.new()
121
- scheduler.sstart
128
+ job_id = scheduler.schedule_every("1s") do
129
+ count += 1
130
+ end
122
131
 
123
- #
124
- # phase 0
132
+ #puts "0 job_id : " + job_id.to_s
125
133
 
126
- count = 0
134
+ sleep 3.5
127
135
 
128
- job_id = scheduler.schedule_every("1s") do
129
- count += 1
130
- end
136
+ assert_equal 3, count
131
137
 
132
- #puts "0 job_id : " + job_id.to_s
138
+ job = scheduler.get_job job_id
133
139
 
134
- sleep 3.5
140
+ assert_equal "1s", job.schedule_info
135
141
 
136
- assert_equal 3, count
142
+ assert_job_count scheduler, 0, 0, 1
137
143
 
138
- job = scheduler.get_job job_id
144
+ #
145
+ # phase 1
139
146
 
140
- assert_equal "1s", job.schedule_info
147
+ es = EverySchedulable.new
141
148
 
142
- assert_job_count scheduler, 0, 0, 1
149
+ job_id = scheduler.schedule_every "500", es
143
150
 
144
- #
145
- # phase 1
151
+ #puts "1 job_id : " + job_id.to_s
152
+
153
+ #sleep(3.4) # was a bit soonish for JRuby...
154
+ sleep 3.5
146
155
 
147
- es = EverySchedulable.new
156
+ #assert_job_count scheduler, 0, 0, 2
157
+ assert_equal 6, es.count
148
158
 
149
- job_id = scheduler.schedule_every "500", es
159
+ scheduler.unschedule job_id
150
160
 
151
- #puts "1 job_id : " + job_id.to_s
152
-
153
- #sleep(3.4) # was a bit soonish for JRuby...
154
- sleep 3.5
161
+ sleep 1
155
162
 
156
- #assert_job_count scheduler, 0, 0, 2
157
- assert_equal 6, es.count
163
+ assert_equal 6, es.count
158
164
 
159
- scheduler.unschedule job_id
165
+ # done
160
166
 
161
- sleep 1
167
+ scheduler.sstop
168
+ end
162
169
 
163
- assert_equal 6, es.count
170
+ #
171
+ # testing to see if the scheduler immediately executes schedule_in(t)
172
+ # requests where t < scheduler.frequency.
173
+ # (100ms < 250ms)
174
+ #
175
+ def test_scheduler_5
164
176
 
165
- # done
177
+ scheduler = OpenWFE::Scheduler.new
178
+ scheduler.sstart
166
179
 
167
- scheduler.sstop
180
+ touched = false
181
+
182
+ scheduler.schedule_in "100" do
183
+ touched = true
168
184
  end
169
185
 
170
- #
171
- # testing to see if the scheduler immediately executes schedule_in(t)
172
- # requests where t < scheduler.frequency.
173
- # (100ms < 250ms)
174
- #
175
- def test_scheduler_5
186
+ assert touched
176
187
 
177
- scheduler = OpenWFE::Scheduler.new
178
- scheduler.sstart
188
+ scheduler.sstop
189
+ end
179
190
 
180
- touched = false
191
+ #
192
+ # Testing to see if a second job with the same id discards the first one.
193
+ #
194
+ def test_scheduler_6
181
195
 
182
- scheduler.schedule_in "100" do
183
- touched = true
184
- end
196
+ scheduler = OpenWFE::Scheduler.new
197
+ scheduler.start
185
198
 
186
- assert touched
199
+ #class << scheduler
200
+ # attr_reader :pending_jobs
201
+ #end
187
202
 
188
- scheduler.sstop
189
- end
203
+ value = nil
190
204
 
191
- #
192
- # Testing to see if a second job with the same id discards the first one.
193
- #
194
- def test_scheduler_6
205
+ scheduler.schedule_in "3s", :job_id => "job" do
206
+ value = 0
207
+ end
208
+ scheduler.schedule_in "2s", :job_id => "job" do
209
+ value = 1
210
+ end
195
211
 
196
- scheduler = OpenWFE::Scheduler.new
197
- scheduler.start
212
+ sleep 0.5
198
213
 
199
- #class << scheduler
200
- # attr_reader :pending_jobs
201
- #end
214
+ #puts scheduler.pending_jobs.collect { |j| j.job_id }.inspect
215
+ assert_job_count scheduler, 0, 1, 0
202
216
 
203
- value = nil
217
+ assert_nil value
204
218
 
205
- scheduler.schedule_in "3s", :job_id => "job" do
206
- value = 0
207
- end
208
- scheduler.schedule_in "2s", :job_id => "job" do
209
- value = 1
210
- end
219
+ sleep 2.0
211
220
 
212
- sleep 0.5
221
+ #puts scheduler.pending_jobs.collect { |j| j.job_id }.inspect
222
+ assert_job_count scheduler, 0, 0, 0
213
223
 
214
- #puts scheduler.pending_jobs.collect { |j| j.job_id }.inspect
215
- assert_job_count scheduler, 0, 1, 0
224
+ assert_equal 1, value
216
225
 
217
- assert_nil value
226
+ sleep 4
218
227
 
219
- sleep 2.0
228
+ assert_equal 1, value
220
229
 
221
- #puts scheduler.pending_jobs.collect { |j| j.job_id }.inspect
222
- assert_job_count scheduler, 0, 0, 0
230
+ scheduler.stop
231
+ end
223
232
 
224
- assert_equal 1, value
233
+ #
234
+ # Testing custom precision.
235
+ #
236
+ def test_scheduler_7
225
237
 
226
- sleep 4
238
+ scheduler = Rufus::Scheduler.new(:scheduler_precision => 0.100)
227
239
 
228
- assert_equal 1, value
240
+ assert_equal 0.100, scheduler.precision
241
+ end
229
242
 
230
- scheduler.stop
231
- end
243
+ #
244
+ # Making sure that a job scheduled in the past is executed immediately
245
+ # and not scheduled.
246
+ #
247
+ # This test also makes sure that schedule_at() understands the
248
+ # time.to_s format.
249
+ #
250
+ def test_8
232
251
 
233
- #
234
- # Testing custom precision.
235
- #
236
- def test_scheduler_7
252
+ scheduler = Rufus::Scheduler.new
253
+ scheduler.start
237
254
 
238
- scheduler = Rufus::Scheduler.new(:scheduler_precision => 0.100)
255
+ var = false
239
256
 
240
- assert_equal 0.100, scheduler.precision
257
+ job_id = scheduler.schedule_at Time.now.to_s do
258
+ var = true
241
259
  end
242
260
 
243
- #
244
- # Making sure that a job scheduled in the past is executed immediately
245
- # and not scheduled.
246
- #
247
- # This test also makes sure that schedule_at() understands the
248
- # time.to_s format.
249
- #
250
- def test_8
261
+ assert_equal var, true
262
+ assert_nil job_id
263
+ end
251
264
 
252
- scheduler = Rufus::Scheduler.new
253
- scheduler.start
265
+ #
266
+ # Scheduling in the past, with :discard_past set to true.
267
+ #
268
+ def test_8b
254
269
 
255
- var = false
270
+ scheduler = OpenWFE::Scheduler.new
271
+ scheduler.start
256
272
 
257
- job_id = scheduler.schedule_at Time.now.to_s do
258
- var = true
259
- end
273
+ var = nil
260
274
 
261
- assert_equal var, true
262
- assert_nil job_id
275
+ job_id = scheduler.schedule_at(Time.now.to_s, :discard_past => true) do
276
+ var = "something"
263
277
  end
264
278
 
265
- #
266
- # Scheduling in the past, with :discard_past set to true.
267
- #
268
- def test_8b
279
+ assert_nil var
280
+ assert_nil job_id
269
281
 
270
- scheduler = OpenWFE::Scheduler.new
271
- scheduler.start
282
+ scheduler.stop
283
+ end
272
284
 
273
- var = nil
285
+ #
286
+ # Testing restarting the scheduler.
287
+ #
288
+ def test_9
274
289
 
275
- job_id = scheduler.schedule_at(Time.now.to_s, :discard_past => true) do
276
- var = "something"
277
- end
290
+ scheduler = OpenWFE::Scheduler.new
291
+ scheduler.start
278
292
 
279
- assert_nil var
280
- assert_nil job_id
293
+ value = nil
281
294
 
282
- scheduler.stop
295
+ scheduler.schedule_in "2s" do
296
+ value = 0
283
297
  end
284
298
 
285
- #
286
- # Testing restarting the scheduler.
287
- #
288
- def test_9
289
-
290
- scheduler = OpenWFE::Scheduler.new
291
- scheduler.start
299
+ assert_nil value
292
300
 
293
- value = nil
301
+ scheduler.stop
294
302
 
295
- scheduler.schedule_in "2s" do
296
- value = 0
297
- end
303
+ sleep 0.5
298
304
 
299
- assert_nil value
305
+ scheduler.start
300
306
 
301
- scheduler.stop
307
+ assert_nil value
302
308
 
303
- sleep 0.5
309
+ sleep 2
304
310
 
305
- scheduler.start
311
+ assert_equal value, 0
306
312
 
307
- assert_nil value
313
+ scheduler.stop
314
+ end
308
315
 
309
- sleep 2
316
+ def test_10
310
317
 
311
- assert_equal value, 0
312
-
313
- scheduler.stop
318
+ e = nil
319
+ begin
320
+ OpenWFE::Scheduler.new.precision = 10
321
+ rescue Exception => e
314
322
  end
315
323
 
316
- def test_10
317
-
318
- e = nil
319
- begin
320
- OpenWFE::Scheduler.new.precision = 10
321
- rescue Exception => e
322
- end
324
+ assert_not_nil e, "exception not caught"
325
+ end
323
326
 
324
- assert_not_nil e, "exception not caught"
325
- end
326
-
327
- protected
327
+ protected
328
328
 
329
- class TestSchedulable
330
- include OpenWFE::Schedulable
329
+ class TestSchedulable
330
+ include OpenWFE::Schedulable
331
331
 
332
- def trigger (params)
333
- $var = "ok"
334
- end
335
- end
332
+ def trigger (params)
333
+ $var = "ok"
334
+ end
335
+ end
336
336
 
337
- class EverySchedulable
338
- include OpenWFE::Schedulable
337
+ class EverySchedulable
338
+ include OpenWFE::Schedulable
339
339
 
340
- attr_accessor :job_id, :count
340
+ attr_accessor :job_id, :count
341
341
 
342
- def initialize
343
- @job_id = -1
344
- @count = 0
345
- end
342
+ def initialize
343
+ @job_id = -1
344
+ @count = 0
345
+ end
346
346
 
347
- def trigger (params)
348
- #puts "toto"
349
- @count += 1
350
- end
351
- end
347
+ def trigger (params)
348
+ #puts "toto"
349
+ @count += 1
350
+ end
351
+ end
352
352
 
353
- def assert_job_count (scheduler, cron, at, every)
353
+ def assert_job_count (scheduler, cron, at, every)
354
354
 
355
- assert_equal cron, scheduler.cron_job_count
356
- assert_equal at, scheduler.at_job_count
357
- assert_equal every, scheduler.every_job_count
358
- assert_equal at + every, scheduler.pending_job_count
359
- end
355
+ assert_equal cron, scheduler.cron_job_count
356
+ assert_equal at, scheduler.at_job_count
357
+ assert_equal every, scheduler.every_job_count
358
+ assert_equal at + every, scheduler.pending_job_count
359
+ end
360
360
 
361
361
  end