openwferu 0.9.10.653 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/README.txt +65 -33
  2. data/examples/README.txt +4 -0
  3. data/examples/flowtracing.rb +2 -0
  4. data/examples/homeworkreview.rb +2 -0
  5. data/examples/mano_tracker.rb +2 -0
  6. data/examples/openwferu.rb +3 -1
  7. data/examples/quotereporter.rb +2 -0
  8. data/examples/scheduler_cron_usage.rb +3 -1
  9. data/examples/scheduler_usage.rb +3 -1
  10. data/lib/openwfe/engine/engine.rb +15 -5
  11. data/lib/openwfe/expool/expressionpool.rb +30 -4
  12. data/lib/openwfe/expool/journal.rb +16 -18
  13. data/lib/openwfe/expool/journal_replay.rb +56 -8
  14. data/lib/openwfe/expool/wfidgen.rb +17 -8
  15. data/lib/openwfe/expressions/condition.rb +41 -26
  16. data/lib/openwfe/expressions/expressionmap.rb +7 -0
  17. data/lib/openwfe/expressions/fe_cancel.rb +1 -1
  18. data/lib/openwfe/expressions/fe_concurrence.rb +14 -5
  19. data/lib/openwfe/expressions/fe_cron.rb +3 -1
  20. data/lib/openwfe/expressions/fe_cursor.rb +1 -1
  21. data/lib/openwfe/expressions/fe_fqv.rb +58 -0
  22. data/lib/openwfe/expressions/fe_if.rb +1 -1
  23. data/lib/openwfe/expressions/fe_iterator.rb +5 -0
  24. data/lib/openwfe/expressions/fe_listen.rb +224 -0
  25. data/lib/openwfe/expressions/fe_misc.rb +32 -9
  26. data/lib/openwfe/expressions/fe_participant.rb +26 -6
  27. data/lib/openwfe/expressions/fe_sleep.rb +5 -7
  28. data/lib/openwfe/expressions/fe_timeout.rb +127 -0
  29. data/lib/openwfe/expressions/fe_when.rb +13 -1
  30. data/lib/openwfe/expressions/flowexpression.rb +4 -1
  31. data/lib/openwfe/expressions/time.rb +10 -27
  32. data/lib/openwfe/expressions/timeout.rb +23 -6
  33. data/lib/openwfe/flowexpressionid.rb +7 -6
  34. data/lib/openwfe/listeners/socketlisteners.rb +1 -1
  35. data/lib/openwfe/participants/enoparticipants.rb +103 -47
  36. data/lib/openwfe/participants/participant.rb +29 -3
  37. data/lib/openwfe/participants/participantmap.rb +10 -2
  38. data/lib/openwfe/participants/participants.rb +31 -19
  39. data/lib/openwfe/participants/socketparticipants.rb +3 -1
  40. data/lib/openwfe/rest/controlclient.rb +5 -18
  41. data/lib/openwfe/rest/oldrestservlet.rb +279 -0
  42. data/lib/openwfe/rest/restclient.rb +55 -25
  43. data/lib/openwfe/rest/worklistclient.rb +35 -44
  44. data/lib/openwfe/rest/xmlcodec.rb +79 -69
  45. data/lib/openwfe/rudefinitions.rb +15 -7
  46. data/lib/openwfe/storage/yamlextras.rb +3 -3
  47. data/lib/openwfe/util/observable.rb +64 -7
  48. data/lib/openwfe/util/scheduler.rb +107 -77
  49. data/lib/openwfe/util/workqueue.rb +5 -11
  50. data/lib/openwfe/utils.rb +3 -3
  51. data/lib/openwfe/version.rb +1 -2
  52. data/lib/openwfe/workitem.rb +3 -4
  53. data/lib/openwfe/worklist/oldrest.rb +244 -0
  54. data/lib/openwfe/worklist/storelocks.rb +288 -0
  55. data/lib/openwfe/worklist/storeparticipant.rb +4 -2
  56. data/lib/openwfe/worklist/worklist.rb +297 -0
  57. data/test/cron_test.rb +8 -9
  58. data/test/eno_test.rb +10 -13
  59. data/test/flowtestbase.rb +26 -17
  60. data/test/ft_15_iterator.rb +19 -0
  61. data/test/ft_23c_wait.rb +2 -2
  62. data/test/ft_2b_concurrence.rb +2 -2
  63. data/test/ft_30_socketlistener.rb +5 -1
  64. data/test/ft_32_journal.rb +1 -1
  65. data/test/ft_32c_journal.rb +102 -0
  66. data/test/ft_32d_journal.rb +85 -0
  67. data/test/ft_45_citerator.rb +25 -0
  68. data/test/ft_49_condition.rb +60 -2
  69. data/test/ft_4_misc.rb +15 -0
  70. data/test/ft_50_xml_attribute.rb +4 -4
  71. data/test/ft_53_null_noop_participant.rb +66 -0
  72. data/test/ft_54_listen.rb +223 -0
  73. data/test/ft_55_ptimeout.rb +64 -0
  74. data/test/ft_56_timeout.rb +55 -0
  75. data/test/ft_57_a.rb +109 -0
  76. data/test/ft_tests.rb +7 -0
  77. data/test/hparticipant_test.rb +3 -3
  78. data/test/obs_test.rb +115 -0
  79. data/test/orest_test.rb +224 -0
  80. data/test/pending.rb +24 -0
  81. data/test/rake_qtest.rb +5 -1
  82. data/test/rake_test.rb +4 -0
  83. data/test/scheduler_test.rb +31 -2
  84. data/test/sec_test.rb +7 -3
  85. data/test/slock_test.rb +82 -0
  86. metadata +19 -3
  87. data/test/ft_32b_journal.rb +0 -76
@@ -0,0 +1,288 @@
1
+ #
2
+ #--
3
+ # Copyright (c) 2007, John Mettraux, OpenWFE.org
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # . Redistributions of source code must retain the above copyright notice, this
10
+ # list of conditions and the following disclaimer.
11
+ #
12
+ # . Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ #
16
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
17
+ # used to endorse or promote products derived from this software without
18
+ # specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+ #++
32
+ #
33
+ #
34
+
35
+ #
36
+ # "made in Japan"
37
+ #
38
+ # John Mettraux at openwfe.org
39
+ #
40
+
41
+ require 'thread'
42
+ require 'openwfe/contextual'
43
+ require 'openwfe/util/otime'
44
+
45
+
46
+ module OpenWFE
47
+
48
+ #
49
+ # TODO #11162 : turn this class into a mixin
50
+ #
51
+
52
+
53
+ #
54
+ # A wrapper for a Store[Participant] that includes a lock system.
55
+ #
56
+ class StoreWithLocks
57
+ include Contextual
58
+
59
+ DEFAULT_LOCK_MAX_AGE = "1h"
60
+
61
+ attr_accessor :lock_max_age
62
+ attr_reader :store
63
+
64
+ #
65
+ # Builds a new store with a lock system wrapping a 'real_store'.
66
+ #
67
+ # This parameter 'real_store' may be a Class, like in
68
+ #
69
+ # store = StoreWithLocks.new(HashParticipant)
70
+ #
71
+ # You can retrieve the 'real store' with
72
+ #
73
+ # real_store = store.store
74
+ #
75
+ # By default, a lock is kept for one hour. You can change that
76
+ # value with, for example :
77
+ #
78
+ # store = StoreWithLocks.new(HashParticipant, :lock_max_age => "30m10s"
79
+ #
80
+ # (setting the lock maximum age to thirty minutes and 10 seconds).
81
+ #
82
+ def initialize (real_store, application_context=nil, params={})
83
+
84
+ @store = real_store
85
+ @store = @store.new if @store.kind_of?(Class)
86
+
87
+ self.application_context = application_context
88
+
89
+ @lock_max_age = params[:lock_max_age] || DEFAULT_LOCK_MAX_AGE
90
+ @lock_max_age = OpenWFE::parse_time_string @lock_max_age
91
+
92
+ @locks = {}
93
+ @lock_mutex = Mutex.new
94
+ end
95
+
96
+ #
97
+ # Sets the application context of this store lock and of the
98
+ # real store behind.
99
+ #
100
+ def application_context= (ac)
101
+
102
+ @application_context = ac
103
+
104
+ if @store.respond_to?(:application_context=) and \
105
+ not store.application_context
106
+
107
+ @store.application_context = @application_context
108
+ end
109
+ end
110
+
111
+ #
112
+ # Get a workitem, lock it and then return it. Ensures that no other
113
+ # 'locker' can lock it meanwhile.
114
+ #
115
+ def get_and_lock (locker, key)
116
+
117
+ @lock_mutex.synchronize do
118
+
119
+ object = @store[key]
120
+
121
+ return nil unless object
122
+
123
+ not_locked?(key)
124
+
125
+ @locks[key] = [ locker, Time.now.to_i ]
126
+ object
127
+ end
128
+ end
129
+
130
+ alias :lock :get_and_lock
131
+
132
+ #
133
+ # Gets a workitem without locking it.
134
+ #
135
+ def get (key)
136
+ @store[key]
137
+ end
138
+
139
+ #
140
+ # Removes a lock set on an item.
141
+ # If the item was locked by some other locker, will raise an exception.
142
+ # If the item was not locked, will simply exit silently.
143
+ #
144
+ def release (locker, key)
145
+
146
+ @lock_mutex.synchronize do
147
+ holding_lock? locker, key
148
+ @locks.delete key
149
+ end
150
+ end
151
+
152
+ #
153
+ # Returns the locker currently holding a given object
154
+ # (known by its key).
155
+ # Will return nil if the object is not locked (or doesn't exist).
156
+ #
157
+ def get_locker (key)
158
+
159
+ lock = get_lock key
160
+ return nil unless lock
161
+ lock[0]
162
+ end
163
+
164
+ #
165
+ # Saves the workitem and releases the lock on it.
166
+ #
167
+ def save (locker, workitem)
168
+
169
+ save_or_forward :save, locker, workitem
170
+ end
171
+
172
+ #
173
+ # Forwards the workitem (to the engine) and releases the lock on
174
+ # it (of course, it's not in the store anymore).
175
+ #
176
+ def forward (locker, workitem)
177
+
178
+ save_or_forward :forward, locker, workitem
179
+ end
180
+
181
+ alias :proceed :forward
182
+
183
+ #
184
+ # Directly forwards the list_workitems() call to the wrapped store.
185
+ #
186
+ def list_workitems (workflow_instance_id=nil)
187
+ @store.list_workitems(workflow_instance_id)
188
+ end
189
+
190
+ #
191
+ # Returns the count of workitems in the store.
192
+ #
193
+ def size
194
+ @store.size
195
+ end
196
+
197
+ #
198
+ # Just calls the consume method of the underlying store.
199
+ #
200
+ def consume (workitem)
201
+ @store.consume workitem
202
+ end
203
+
204
+ #
205
+ # Iterates over the workitems in the store.
206
+ #
207
+ # Doesn't care about any order for now.
208
+ #
209
+ def each (&block) # :yields: workitem, locked
210
+ return unless block
211
+ @store.each do |fei, workitem|
212
+ block.call workitem, locked?(fei)
213
+ end
214
+ end
215
+
216
+ protected
217
+
218
+ def save_or_forward (method, locker, workitem)
219
+
220
+ @lock_mutex.synchronize do
221
+ holding_lock? locker, workitem.fei
222
+ @locks.delete workitem.fei
223
+ @store.send method, workitem
224
+ end
225
+ end
226
+
227
+ #
228
+ # Returns the lock info (else nil) for the given key.
229
+ #
230
+ def get_lock (key)
231
+
232
+ lock = @locks[key]
233
+
234
+ return nil unless lock
235
+
236
+ l, lt = lock
237
+
238
+ if (Time.now.to_i - lt) > @lock_max_age
239
+ @locks.delete key
240
+ return nil
241
+ end
242
+
243
+ [ l, lt ]
244
+ end
245
+
246
+ #
247
+ # Returns true if the object is locked
248
+ #
249
+ def locked? (key)
250
+ @locks[key] != nil
251
+ end
252
+
253
+ #
254
+ # Will raise an exception if the object (designated via its key)
255
+ # is already locked.
256
+ #
257
+ def not_locked? (key)
258
+
259
+ raise "already locked" if get_lock key
260
+ end
261
+
262
+ #
263
+ # Will raise an exception if the locker is not holding a lock
264
+ # for the given key.
265
+ #
266
+ def holding_lock? (locker, key)
267
+
268
+ lock = get_lock key
269
+ raise "not locked" unless lock
270
+ l, lt = lock
271
+ raise "locked by someone else" if (l != locker)
272
+ # else, simply end
273
+ end
274
+
275
+ #--
276
+ # Sets the lock on a given key to 'now'.
277
+ #
278
+ #def touch_lock (key)
279
+ # lock = @locks[key]
280
+ # return false unless lock
281
+ # locker, lock_time = lock
282
+ # @locks[key] = [ locker, Time.now.to_i ]
283
+ # true
284
+ #end
285
+ #++
286
+ end
287
+ end
288
+
@@ -68,8 +68,10 @@ module OpenWFE
68
68
  include LocalParticipant
69
69
  include FeiMixin
70
70
 
71
- #def initialize ()
72
- #end
71
+ #
72
+ # optional field (only used by the old rest interface for now)
73
+ #
74
+ attr_accessor :store_name
73
75
 
74
76
  #
75
77
  # Called by the engine (the participant expression) when handing
@@ -0,0 +1,297 @@
1
+ #
2
+ #--
3
+ # Copyright (c) 2007, John Mettraux, OpenWFE.org
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # . Redistributions of source code must retain the above copyright notice, this
10
+ # list of conditions and the following disclaimer.
11
+ #
12
+ # . Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ #
16
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
17
+ # used to endorse or promote products derived from this software without
18
+ # specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+ #++
32
+ #
33
+
34
+ #
35
+ # "made in Japan"
36
+ #
37
+ # John Mettraux at openwfe.org
38
+ #
39
+
40
+ require 'openwfe/engine/engine'
41
+ require 'openwfe/participants/participant'
42
+
43
+
44
+ module OpenWFE
45
+
46
+ #
47
+ # An OpenWFEja-style worklist.
48
+ #
49
+ class Worklist
50
+ include LocalParticipant
51
+
52
+ attr_reader :stores
53
+
54
+ #
55
+ # Builds a new worklist.
56
+ #
57
+ # Parameters are :
58
+ #
59
+ # - :auth_system : something with an authenticate(user, pass) and an
60
+ # optional authorised?(user, store, action) methods.
61
+ # - :launchables : an array of URLs : launchables, in this basic
62
+ # implementation, all users share the same list
63
+ #
64
+ def initialize (application_context, params)
65
+
66
+ @application_context = application_context
67
+
68
+ as = params[:auth_system]
69
+
70
+ @auth_system = if as == nil
71
+ DefaultAuthSystem.new
72
+ elsif as.kind_of?(Hash)
73
+ DefaultAuthSystem.new(as)
74
+ else
75
+ as
76
+ end
77
+
78
+ @stores = []
79
+ end
80
+
81
+ def consume (workitem)
82
+
83
+ pname = workitem.participant_name
84
+
85
+ each_store do |regex, store_name, store|
86
+
87
+ next unless pname.match regex
88
+
89
+ store.consume workitem
90
+ break
91
+ end
92
+ end
93
+
94
+ #
95
+ # A simple call to the authentify method of the @auth_system
96
+ # passed a initialization time.
97
+ #
98
+ def authenticate (user, pass)
99
+ @auth_system.authenticate(user, pass)
100
+ end
101
+
102
+ #
103
+ # Returns a string like "rwd" or "rw" or even "".
104
+ #
105
+ # Read / Write / Delegate
106
+ #
107
+ def get_permissions (user, store_name)
108
+ s = ""
109
+ [ :read, :write, :delegate ].each do |action|
110
+ s << action.to_s[0, 1] \
111
+ if @auth_system.authorized?(user, store_name, action)
112
+ end
113
+ s
114
+ end
115
+
116
+ #
117
+ # For now, just a shortcut for
118
+ #
119
+ # @stores << [ regex, store_name, store]
120
+ #
121
+ def add_store (regex, store_name, store)
122
+
123
+ @stores << [ regex, store_name, store]
124
+
125
+ store.application_context = @application_context \
126
+ if store.respond_to?(:application_context=)
127
+ end
128
+
129
+ #
130
+ # Well, this implementation just returns workitems
131
+ #
132
+ def get_headers (user, store_name, limit)
133
+
134
+ authorized?(user, store_name, :read)
135
+
136
+ l = []
137
+
138
+ get_store(store_name).each do |workitem, locked|
139
+ break if limit and l.size >= limit
140
+ l << [ workitem, locked ]
141
+ end
142
+
143
+ l
144
+ end
145
+
146
+ def get (user, store_name, fei)
147
+ authorized?(user, store_name, :read)
148
+ get_store(store_name).get(fei)
149
+ end
150
+ def get_and_lock (user, store_name, fei)
151
+ authorized?(user, store_name, :write)
152
+ get_store(store_name).get_and_lock(user, fei)
153
+ end
154
+
155
+ def release (user, store_name, wi_or_fei)
156
+
157
+ authorized?(user, store_name, :write)
158
+
159
+ fei = wi_or_fei
160
+ fei = fei.fei if fei.respond_to?(:fei)
161
+
162
+ get_store(store_name).release(user, fei)
163
+ end
164
+
165
+ def save (user, store_name, workitem)
166
+ authorized?(user, store_name, :write)
167
+ get_store(store_name).save(user, workitem)
168
+ end
169
+ def forward (user, store_name, workitem)
170
+ authorized?(user, store_name, :write)
171
+ get_store(store_name).forward(user, workitem)
172
+ end
173
+ def list_workitems (user, store_name, workflow_instance_id=nil)
174
+ authorized?(user, store_name, :read)
175
+ get_store(store_name).list_workitems(workflow_instance_id)
176
+ end
177
+
178
+ def delegate (user, from_store_name, to_store_name)
179
+ authorized?(user, from_store_name, :write)
180
+ authorized?(user, to_store_name, :write)
181
+ # TODO : continue me
182
+ end
183
+
184
+ #
185
+ # Iterates over each of the stores in this worklist.
186
+ #
187
+ def each_store (&block) # :yields: regex, store_name, store
188
+
189
+ return unless block
190
+
191
+ @stores.each do |v|
192
+ regex, store_name, store = v
193
+ block.call regex, store_name, store
194
+ end
195
+ end
196
+
197
+ #
198
+ # Returns the first store whose regex matches the given
199
+ # store_name.
200
+ #
201
+ def lookup_store (store_name)
202
+ each_store do |regex, name, store|
203
+ return store if regex.match store_name
204
+ end
205
+ nil
206
+ end
207
+
208
+ #
209
+ # Returns the store instance with the given name.
210
+ #
211
+ def get_store (store_name)
212
+ each_store do |regex, s_name, store|
213
+ return store if s_name == store_name
214
+ end
215
+ nil
216
+ end
217
+
218
+ #
219
+ # Not really the job of a worklist, but it was in OpenWFEja, so
220
+ # here it is...
221
+ #
222
+ def launch_flow (engine_name, launch_item)
223
+
224
+ e = lookup_engine engine_name
225
+
226
+ raise "couldn't find engine named '#{engine_name}'" unless e
227
+
228
+ if e.is_a? OpenWFE::Engine
229
+
230
+ e.launch launch_item
231
+
232
+ elsif e.is_a? OpenWFE::Participant
233
+
234
+ e.consume launch_item
235
+
236
+ else
237
+ raise \
238
+ "cannot launch a flow via something of "+
239
+ "class #{e.class.name}"
240
+ end
241
+ end
242
+
243
+ protected
244
+
245
+ #
246
+ # This method is called when a launch_flow request is coming,
247
+ # it will lookup in the participant map to find the way (the
248
+ # Participant implementation) to deliver the launch_item to the
249
+ # engine.
250
+ #
251
+ # If there is no engine with that name, the default (local) engine
252
+ # is returned (and will thus be used to launch the flow).
253
+ #
254
+ def lookup_engine (engine_name)
255
+ e = get_participant_map.lookup_participant engine_name
256
+ return e if e
257
+ get_engine
258
+ end
259
+
260
+ def authorized? (user, store_name, action)
261
+
262
+ return true unless @auth_system.respond_to?(:authorized?)
263
+
264
+ unless @auth_system.authorized?(user, store_name, action)
265
+ raise \
266
+ "'#{user}' is not authorized " +
267
+ "to '#{action}' on store '#{store_name}'"
268
+ end
269
+
270
+ true
271
+ end
272
+ end
273
+
274
+ class DefaultAuthSystem
275
+
276
+ def initialize (hash=nil)
277
+ @hash = hash
278
+ end
279
+
280
+ def authenticate (user, pass)
281
+ return true unless @hash
282
+ pass == @hash[user]
283
+ end
284
+
285
+ def authorized? (user, store_name, action)
286
+ return true unless @hash
287
+ @hash[user] != nil
288
+ end
289
+ end
290
+
291
+ #--
292
+ # persistence...
293
+ # is handled by the StoreParticipant implementations themselves
294
+ #++
295
+
296
+ end
297
+
data/test/cron_test.rb CHANGED
@@ -25,25 +25,24 @@ class CronTest < Test::Unit::TestCase
25
25
  #end
26
26
 
27
27
  def test_cron_0
28
+
28
29
  $var = 0
29
30
 
30
- scheduler = OpenWFE::Scheduler.new()
31
+ scheduler = OpenWFE::Scheduler.new
31
32
  scheduler.start
32
33
 
33
- sid = scheduler.schedule('* * * * *', nil, CounterSchedulable.new, nil)
34
+ sid = scheduler.schedule(
35
+ '* * * * *',
36
+ :schedulable => CounterSchedulable.new)
34
37
 
35
- assert \
36
- sid,
37
- "scheduler did not return a job id"
38
+ assert sid, "scheduler did not return a job id"
38
39
 
39
- sleep(120)
40
+ sleep 120
40
41
  scheduler.stop
41
42
 
42
43
  #puts ">#{$var}<"
43
44
 
44
- assert \
45
- ($var == 2),
46
- "cron_0 failed, $var is #{$var}"
45
+ assert_equal $var, 2, "$var should be at 2, it's at #{$var}"
47
46
  end
48
47
 
49
48
  protected
data/test/eno_test.rb CHANGED
@@ -30,11 +30,7 @@ class EnoTest < Test::Unit::TestCase
30
30
  #
31
31
 
32
32
  class TestDefinition0 < ProcessDefinition
33
- def make
34
- process_definition :name => "eno", :revision => "0" do
35
- email_notification_participant
36
- end
37
- end
33
+ email_notification_participant
38
34
  end
39
35
 
40
36
  def test_eno
@@ -43,18 +39,17 @@ class EnoTest < Test::Unit::TestCase
43
39
 
44
40
  engine = Engine.new
45
41
 
46
- eno = EmailNotificationParticipant.new(
47
- "mail.google.com",
48
- 25,
49
- "eno@outoftheblue.co.jp") do | fexp, part, wi |
42
+ eno = MailParticipant.new(
43
+ :smtp_server => "mail.google.com"
44
+ :from_address => "eno@outoftheblue.co.jp"
45
+ ) do
50
46
 
51
47
  s = ""
52
-
53
48
  s << "Subject: test 0\n\n"
54
49
 
55
- s << "konnichiwa.\n\n"
50
+ s << "konnichiwa. #{Time.now.to_s}\n\n"
56
51
 
57
- return s
52
+ s
58
53
  end
59
54
 
60
55
  engine.register_participant("email_notification_participant", eno)
@@ -63,7 +58,9 @@ class EnoTest < Test::Unit::TestCase
63
58
 
64
59
  li.email_target = ENV["TARGET"]
65
60
 
66
- engine.launch(li)
61
+ fei = engine.launch(li)
62
+
63
+ engine.wait_for fei
67
64
  end
68
65
  end
69
66