openwferu 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/examples/about_state.rb +81 -0
  2. data/examples/engine_template.rb +7 -0
  3. data/lib/openwfe/contextual.rb +2 -2
  4. data/lib/openwfe/def.rb +2 -3
  5. data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
  6. data/lib/openwfe/engine/engine.rb +202 -251
  7. data/lib/openwfe/engine/process_status.rb +359 -0
  8. data/lib/openwfe/expool/errorjournal.rb +6 -6
  9. data/lib/openwfe/expool/expressionpool.rb +161 -239
  10. data/lib/openwfe/expool/expstorage.rb +185 -55
  11. data/lib/openwfe/expool/journal.rb +1 -2
  12. data/lib/openwfe/expool/parser.rb +233 -0
  13. data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
  14. data/lib/openwfe/expool/wfidgen.rb +25 -7
  15. data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
  16. data/lib/openwfe/expressions/condition.rb +49 -12
  17. data/lib/openwfe/expressions/environment.rb +45 -15
  18. data/lib/openwfe/expressions/expressionmap.rb +39 -19
  19. data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
  20. data/lib/openwfe/expressions/fe_cron.rb +19 -18
  21. data/lib/openwfe/expressions/fe_cursor.rb +69 -28
  22. data/lib/openwfe/expressions/fe_define.rb +4 -1
  23. data/lib/openwfe/expressions/fe_do.rb +1 -3
  24. data/lib/openwfe/expressions/fe_equals.rb +131 -20
  25. data/lib/openwfe/expressions/fe_fqv.rb +27 -3
  26. data/lib/openwfe/expressions/fe_iterator.rb +14 -7
  27. data/lib/openwfe/expressions/fe_listen.rb +7 -2
  28. data/lib/openwfe/expressions/fe_misc.rb +187 -20
  29. data/lib/openwfe/expressions/fe_participant.rb +8 -7
  30. data/lib/openwfe/expressions/fe_reserve.rb +105 -33
  31. data/lib/openwfe/expressions/fe_save.rb +55 -5
  32. data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
  33. data/lib/openwfe/expressions/fe_sleep.rb +25 -15
  34. data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
  35. data/lib/openwfe/expressions/fe_wait.rb +3 -2
  36. data/lib/openwfe/expressions/fe_when.rb +7 -15
  37. data/lib/openwfe/expressions/flowexpression.rb +90 -49
  38. data/lib/openwfe/expressions/merge.rb +7 -1
  39. data/lib/openwfe/expressions/raw.rb +261 -63
  40. data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
  41. data/lib/openwfe/expressions/time.rb +36 -12
  42. data/lib/openwfe/expressions/timeout.rb +9 -7
  43. data/lib/openwfe/expressions/value.rb +126 -0
  44. data/lib/openwfe/flowexpressionid.rb +52 -22
  45. data/lib/openwfe/listeners/listeners.rb +3 -3
  46. data/lib/openwfe/listeners/socketlisteners.rb +8 -5
  47. data/lib/openwfe/logging.rb +6 -3
  48. data/lib/openwfe/omixins.rb +8 -6
  49. data/lib/openwfe/orest/xmlcodec.rb +16 -12
  50. data/lib/openwfe/participants.rb +38 -0
  51. data/lib/openwfe/participants/participant.rb +1 -1
  52. data/lib/openwfe/participants/participantmap.rb +24 -10
  53. data/lib/openwfe/participants/participants.rb +4 -3
  54. data/lib/openwfe/participants/soapparticipants.rb +1 -1
  55. data/lib/openwfe/participants/socketparticipants.rb +1 -1
  56. data/lib/openwfe/rudefinitions.rb +7 -5
  57. data/lib/openwfe/storage/yamlcustom.rb +10 -10
  58. data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
  59. data/lib/openwfe/tools/flowtracer.rb +6 -5
  60. data/lib/openwfe/util/dollar.rb +42 -85
  61. data/lib/openwfe/util/ometa.rb +1 -3
  62. data/lib/openwfe/util/workqueue.rb +1 -1
  63. data/lib/openwfe/utils.rb +33 -11
  64. data/lib/openwfe/version.rb +2 -2
  65. data/lib/openwfe/workitem.rb +76 -14
  66. data/lib/openwfe/worklist/storelocks.rb +9 -4
  67. data/lib/openwfe/worklist/storeparticipant.rb +1 -1
  68. data/test/back_0916_test.rb +101 -0
  69. data/test/bm/ft_26_load.rb +1 -1
  70. data/test/bm/ft_26b_load.rb +1 -1
  71. data/test/bm/ft_26c_load.rb +3 -2
  72. data/test/bm/ft_26d_load.rb +97 -0
  73. data/test/bm/ft_recu.rb +71 -0
  74. data/test/concurrence_test.rb +1 -1
  75. data/test/condition_test.rb +152 -0
  76. data/test/description_test.rb +12 -7
  77. data/test/eno_test.rb +1 -1
  78. data/test/expool_20031219_0916.tgz +0 -0
  79. data/test/fe_lookup_att_test.rb +1 -1
  80. data/test/fei_test.rb +16 -0
  81. data/test/file_persistence_test.rb +8 -12
  82. data/test/filep_cancel_test.rb +116 -0
  83. data/test/flowtestbase.rb +47 -25
  84. data/test/ft_0.rb +1 -1
  85. data/test/ft_10_loop.rb +29 -14
  86. data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
  87. data/test/ft_11_ppd.rb +6 -17
  88. data/test/ft_11b_ppd.rb +1 -4
  89. data/test/ft_12_blockparticipant.rb +1 -1
  90. data/test/ft_13_eno.rb +1 -1
  91. data/test/ft_15_iterator.rb +1 -1
  92. data/test/ft_15b_iterator.rb +1 -1
  93. data/test/ft_17_condition.rb +6 -6
  94. data/test/ft_18_pname.rb +1 -1
  95. data/test/ft_20_cron.rb +1 -1
  96. data/test/ft_21_cron.rb +6 -4
  97. data/test/ft_22_history.rb +1 -1
  98. data/test/ft_23_when.rb +1 -1
  99. data/test/ft_23b_when.rb +18 -6
  100. data/test/ft_23c_wait.rb +8 -6
  101. data/test/ft_25_cancel.rb +7 -5
  102. data/test/ft_27_getflowpos.rb +22 -17
  103. data/test/ft_28_fileparticipant.rb +1 -2
  104. data/test/ft_2_concurrence.rb +1 -1
  105. data/test/ft_2b_concurrence.rb +25 -20
  106. data/test/ft_30_socketlistener.rb +0 -3
  107. data/test/ft_34_cancelwfid.rb +9 -9
  108. data/test/ft_35_localdefs.rb +0 -1
  109. data/test/ft_36_subprocids.rb +6 -6
  110. data/test/ft_38_tag.rb +3 -2
  111. data/test/ft_38b_tag.rb +229 -0
  112. data/test/ft_39_reserve.rb +3 -18
  113. data/test/ft_39b_reserve.rb +34 -5
  114. data/test/ft_3b_lookup_vf.rb +83 -0
  115. data/test/ft_40_defined.rb +2 -11
  116. data/test/ft_42_environments.rb +4 -6
  117. data/test/ft_44b_restore.rb +88 -22
  118. data/test/ft_45_citerator.rb +57 -11
  119. data/test/ft_49_condition.rb +4 -2
  120. data/test/ft_4_misc.rb +24 -3
  121. data/test/ft_50_xml_attribute.rb +17 -20
  122. data/test/ft_54_listen.rb +1 -1
  123. data/test/ft_54b_listen.rb +2 -2
  124. data/test/ft_56_timeout.rb +8 -1
  125. data/test/ft_57_a.rb +10 -10
  126. data/test/ft_59_ps.rb +49 -16
  127. data/test/ft_60_ecancel.rb +52 -10
  128. data/test/ft_63_pause.rb +8 -8
  129. data/test/ft_65_stringlaunch.rb +4 -6
  130. data/test/ft_67_schedlaunch.rb +4 -4
  131. data/test/ft_69_cancelmissing.rb +4 -2
  132. data/test/ft_70_lookupvar.rb +2 -2
  133. data/test/ft_72_lookup_processes.rb +2 -2
  134. data/test/ft_73_cancel_sub.rb +8 -8
  135. data/test/ft_77_segments.rb +38 -0
  136. data/test/ft_78_eval.rb +154 -0
  137. data/test/ft_79_tticket.rb +185 -0
  138. data/test/ft_80_spname.rb +95 -0
  139. data/test/ft_81_exp.rb +64 -0
  140. data/test/ft_82_trecu.rb +48 -0
  141. data/test/ft_83_badpause.rb +62 -0
  142. data/test/ft_84_updateexp.rb +125 -0
  143. data/test/ft_9b_cursor.rb +105 -0
  144. data/test/ft_tests.rb +14 -1
  145. data/test/hash_test.rb +7 -7
  146. data/test/hparticipant_test.rb +4 -4
  147. data/test/lookup_vf_test.rb +94 -0
  148. data/test/misc_test.rb +5 -3
  149. data/test/orest_test.rb +4 -3
  150. data/test/param_test.rb +12 -16
  151. data/test/participant_test.rb +36 -0
  152. data/test/pending.rb +10 -10
  153. data/test/rake_ltest.rb +1 -10
  154. data/test/rake_qtest.rb +7 -6
  155. data/test/raw_prog_test.rb +89 -121
  156. data/test/restart_cron_test.rb +84 -36
  157. data/test/restart_paused_test.rb +100 -0
  158. data/test/restart_sleep_test.rb +1 -1
  159. data/test/restart_tests.rb +1 -0
  160. data/test/restart_when_test.rb +33 -22
  161. data/test/ruby_procdef_test.rb +19 -18
  162. data/test/sec_test.rb +74 -35
  163. data/test/storage_test.rb +44 -0
  164. data/test/test.rb +3 -0
  165. data/test/timeout_test.rb +7 -18
  166. data/test/wfid_test.rb +2 -1
  167. data/test/wi_test.rb +29 -18
  168. metadata +121 -57
  169. data/lib/openwfe/expressions/raw_xml.rb +0 -176
  170. data/lib/openwfe/expressions/simplerep.rb +0 -266
  171. data/lib/openwfe/util/kotoba.rb +0 -236
  172. data/lib/openwfe/util/lru.rb +0 -171
  173. data/lib/openwfe/util/otime.rb +0 -246
  174. data/lib/openwfe/util/safe.rb +0 -160
  175. data/lib/openwfe/util/scheduler.rb +0 -1158
  176. data/test/cron_test.rb +0 -113
  177. data/test/cronline_test.rb +0 -60
  178. data/test/dollar_test.rb +0 -90
  179. data/test/kotoba_test.rb +0 -72
  180. data/test/lru_test.rb +0 -79
  181. data/test/safely_test.rb +0 -84
  182. data/test/scheduler_1_test.rb +0 -88
  183. data/test/scheduler_test.rb +0 -363
  184. data/test/time_test.rb +0 -84
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2005-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -57,14 +57,6 @@ module OpenWFE
57
57
  xmlElt.elements.detect { |elt| elt.name == elementName }
58
58
  end
59
59
 
60
- #
61
- # Used in tests, is equivalent to Perl's die() method.
62
- #
63
- def OpenWFE.die (text)
64
- puts text
65
- exit 1
66
- end
67
-
68
60
  #
69
61
  # see
70
62
  # http://wiki.rubygarden.org/Ruby/page/show/Make_A_Deep_Copy_Of_An_Object
@@ -88,6 +80,10 @@ module OpenWFE
88
80
  def OpenWFE.fulldup (object)
89
81
 
90
82
  return nil if object == nil
83
+
84
+ return object.fulldup if object.respond_to?("fulldup")
85
+ # trusting client objects providing a fulldup() implementation
86
+ # Tomaso Tosolini 2007.12.11
91
87
 
92
88
  return object if object.kind_of?(Float)
93
89
  return object if object.kind_of?(Fixnum)
@@ -115,7 +111,7 @@ module OpenWFE
115
111
 
116
112
  begin
117
113
  o = object.class.new
118
- rescue ArgumentError
114
+ rescue ArgumentError => ae
119
115
  return deep_clone(object)
120
116
  end
121
117
 
@@ -270,7 +266,7 @@ module OpenWFE
270
266
  # Sets the name of the current thread (the attribute :name if it is
271
267
  # a ruby thread, the java thread name if we're in JRuby)
272
268
  #
273
- def set_current_thread_name (name)
269
+ def OpenWFE.set_current_thread_name (name)
274
270
  if defined?(JRUBY_VERSION)
275
271
  require 'java'
276
272
  java.lang.Thread.current_thread.name = "#{name} (Ruby Thread)"
@@ -349,6 +345,9 @@ module OpenWFE
349
345
  end
350
346
 
351
347
 
348
+ #
349
+ # (2008.03.12 Deprecated, kept here for a while
350
+ # for backward compatibility)
352
351
  #
353
352
  # A simple Hash that accepts String or Symbol as lookup keys []
354
353
  #
@@ -474,6 +473,29 @@ module OpenWFE
474
473
  container[key[i+1..-1]] = value
475
474
  end
476
475
 
476
+ #
477
+ # This method is used within the InFlowWorkItem and the CsvTable classes.
478
+ #
479
+ def OpenWFE.unset_attribute (container, key)
480
+
481
+ i = key.rindex(".")
482
+
483
+ if not i
484
+ container.delete key
485
+ return
486
+ end
487
+
488
+ container = lookup_attribute container, key[0..i-1]
489
+
490
+ if container.is_a?(Array)
491
+
492
+ container.delete_at key[i+1..-1].to_i
493
+ else
494
+
495
+ container.delete key[i+1..-1]
496
+ end
497
+ end
498
+
477
499
  #
478
500
  # Returns true if this host is currently online (has access to the web /
479
501
  # internet).
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2005-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -32,5 +32,5 @@
32
32
  #
33
33
 
34
34
  module OpenWFE
35
- OPENWFERU_VERSION = '0.9.16'
35
+ OPENWFERU_VERSION = '0.9.17'
36
36
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2005-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -72,10 +72,12 @@ module OpenWFE
72
72
  # Sets the last_modified field to now
73
73
  #
74
74
  def touch
75
+
75
76
  @last_modified = Time.now
76
77
  end
77
78
 
78
79
  def to_h
80
+
79
81
  h = {}
80
82
  h[:type] = self.class.name
81
83
  h[:last_modified] = @last_modified
@@ -84,12 +86,48 @@ module OpenWFE
84
86
  end
85
87
 
86
88
  def WorkItem.from_h (h)
87
- wi = eval("#{h[:type]}.new")
89
+
90
+ #wi = eval("#{h[:type]}.new")
91
+ wi = OpenWFE.get_class(h).new
88
92
  wi.last_modified = h[:last_modified]
89
93
  wi.attributes = h[:attributes]
90
94
  wi
91
95
  end
92
96
 
97
+ #
98
+ # A shortcut for
99
+ #
100
+ # workitem.attributes['key']
101
+ #
102
+ # is
103
+ #
104
+ # workitem['key']
105
+ #
106
+ # (Note that
107
+ #
108
+ # workitem.key
109
+ #
110
+ # will raise an exception if there is no attribute key).
111
+ #
112
+ def [] (key)
113
+
114
+ @attributes[key]
115
+ end
116
+
117
+ #
118
+ # A shortcut for
119
+ #
120
+ # workitem.attributes['key'] = value
121
+ #
122
+ # is
123
+ #
124
+ # workitem['key'] = value
125
+ #
126
+ def []= (key, value)
127
+
128
+ @attributes[key] = value
129
+ end
130
+
93
131
  #
94
132
  # In order to simplify code like :
95
133
  #
@@ -119,15 +157,14 @@ module OpenWFE
119
157
  raise "Missing attribute '#{methodname}' in workitem"
120
158
  end
121
159
 
122
- if methodname == "[]" and args.length == 1
123
- value = @attributes[args[0]]
124
- return value if value
125
- raise "Missing attribute '#{methodname}' in workitem"
126
- end
127
-
128
- if methodname == "[]=" and args.length == 2
129
- return @attributes[args[0]] = args[1]
130
- end
160
+ #if methodname == "[]" and args.length == 1
161
+ # value = @attributes[args[0]]
162
+ # return value if value
163
+ # raise "Missing attribute '#{methodname}' in workitem"
164
+ #end
165
+ #if methodname == "[]=" and args.length == 2
166
+ # return @attributes[args[0]] = args[1]
167
+ #end
131
168
 
132
169
  if args.length == 1 and methodname[-1, 1] == "="
133
170
  return @attributes[methodname[0..-2]] = args[0]
@@ -188,9 +225,17 @@ module OpenWFE
188
225
  OpenWFE.set_attribute(@attributes, key, value)
189
226
  end
190
227
 
228
+ #
229
+ # unset_attribute() accomodates itself with nested key constructs.
230
+ #
231
+ def unset_attribute (key)
232
+ OpenWFE.unset_attribute(@attributes, key)
233
+ end
234
+
191
235
  alias :lookup_field :lookup_attribute
192
236
  alias :has_field? :has_attribute?
193
237
  alias :set_field :set_attribute
238
+ alias :unset_field :unset_attribute
194
239
 
195
240
  end
196
241
 
@@ -283,6 +328,7 @@ module OpenWFE
283
328
  # Rebuilds an InFlowWorkItem from its hash version.
284
329
  #
285
330
  def InFlowWorkItem.from_h (h)
331
+
286
332
  wi = super
287
333
  wi.dispatch_time = h[:dispatch_time]
288
334
  wi.history = h[:history]
@@ -294,6 +340,7 @@ module OpenWFE
294
340
  # Sets the '__result__' field of this workitem
295
341
  #
296
342
  def set_result (result)
343
+
297
344
  @attributes[FIELD_RESULT] = result
298
345
  end
299
346
 
@@ -301,6 +348,7 @@ module OpenWFE
301
348
  # Makes sure the '__result__' field of this workitem is empty.
302
349
  #
303
350
  def unset_result
351
+
304
352
  @attributes.delete FIELD_RESULT
305
353
  end
306
354
 
@@ -310,6 +358,7 @@ module OpenWFE
310
358
  # workitem.attributes["__result__"]
311
359
  #
312
360
  def get_result
361
+
313
362
  @attributes[FIELD_RESULT]
314
363
  end
315
364
 
@@ -317,9 +366,10 @@ module OpenWFE
317
366
  # Returns true or false.
318
367
  #
319
368
  def get_boolean_result
369
+
320
370
  r = get_result
321
371
  return false unless r
322
- return (r == true or r == "true")
372
+ (r == true or r == "true")
323
373
  end
324
374
  end
325
375
 
@@ -332,6 +382,7 @@ module OpenWFE
332
382
  class CancelItem < InFlowItem
333
383
 
334
384
  def initialize (workitem)
385
+
335
386
  super()
336
387
  @flow_expression_id = workitem.fei.dup
337
388
  end
@@ -402,12 +453,14 @@ module OpenWFE
402
453
  # serializable to other formats).
403
454
  #
404
455
  def to_h
456
+
405
457
  h = super
406
458
  h[:workflow_definition_url] = @workflow_definition_url
407
459
  h
408
460
  end
409
461
 
410
462
  def LaunchItem.from_h (h)
463
+
411
464
  li = super
412
465
  li.workflow_definition_url = h[:workflow_definition_url]
413
466
  li
@@ -419,10 +472,19 @@ module OpenWFE
419
472
  # LaunchItem).
420
473
  #
421
474
  def OpenWFE.workitem_from_h (h)
422
- wi_class = h[:type]
423
- wi_class = eval(wi_class)
475
+
476
+ #wi_class = eval(h[:type])
477
+ wi_class = get_class(h)
424
478
  wi_class.from_h(h)
425
479
  end
426
480
 
481
+ def OpenWFE.get_class (h)
482
+
483
+ cl = h[:type]
484
+ return nil if cl.index(";")
485
+ return nil if cl.index(" ")
486
+ eval(cl)
487
+ end
488
+
427
489
  end
428
490
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -39,8 +39,8 @@
39
39
  #
40
40
 
41
41
  require 'thread'
42
+ require 'rufus/otime'
42
43
  require 'openwfe/contextual'
43
- require 'openwfe/util/otime'
44
44
 
45
45
 
46
46
  module OpenWFE
@@ -87,7 +87,7 @@ module OpenWFE
87
87
  self.application_context = application_context
88
88
 
89
89
  @lock_max_age = params[:lock_max_age] || DEFAULT_LOCK_MAX_AGE
90
- @lock_max_age = OpenWFE::parse_time_string @lock_max_age
90
+ @lock_max_age = Rufus::parse_time_string @lock_max_age
91
91
 
92
92
  @locks = {}
93
93
  @lock_mutex = Mutex.new
@@ -133,6 +133,7 @@ module OpenWFE
133
133
  # Gets a workitem without locking it.
134
134
  #
135
135
  def get (key)
136
+
136
137
  @store[key]
137
138
  end
138
139
 
@@ -184,6 +185,7 @@ module OpenWFE
184
185
  # Directly forwards the list_workitems() call to the wrapped store.
185
186
  #
186
187
  def list_workitems (workflow_instance_id=nil)
188
+
187
189
  @store.list_workitems(workflow_instance_id)
188
190
  end
189
191
 
@@ -191,6 +193,7 @@ module OpenWFE
191
193
  # Returns the count of workitems in the store.
192
194
  #
193
195
  def size
196
+
194
197
  @store.size
195
198
  end
196
199
 
@@ -198,6 +201,7 @@ module OpenWFE
198
201
  # Just calls the consume method of the underlying store.
199
202
  #
200
203
  def consume (workitem)
204
+
201
205
  @store.consume workitem
202
206
  end
203
207
 
@@ -207,7 +211,7 @@ module OpenWFE
207
211
  # Doesn't care about any order for now.
208
212
  #
209
213
  def each (&block) # :yields: workitem, locked
210
- return unless block
214
+
211
215
  @store.each do |fei, workitem|
212
216
  block.call workitem, locked?(fei)
213
217
  end
@@ -247,6 +251,7 @@ module OpenWFE
247
251
  # Returns true if the object is locked
248
252
  #
249
253
  def locked? (key)
254
+
250
255
  @locks[key] != nil
251
256
  end
252
257
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -0,0 +1,101 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Tue Feb 19 10:58:43 JST 2008
8
+ #
9
+
10
+ require 'test/unit'
11
+ require 'fileutils'
12
+ require 'openwfe/def'
13
+ require 'openwfe/engine/file_persisted_engine'
14
+
15
+ include OpenWFE
16
+
17
+
18
+ class Back0916Test < Test::Unit::TestCase
19
+
20
+ WORK = 'work_back'
21
+
22
+ def setup
23
+
24
+ FileUtils.rm_rf WORK
25
+ FileUtils.mkdir WORK
26
+
27
+ `cd work_back && tar xzvf ../test/expool_20031219_0916.tgz`
28
+
29
+ ac = { :work_directory => WORK }
30
+
31
+ @engine = FilePersistedEngine.new ac
32
+
33
+ end
34
+
35
+ def teardown
36
+
37
+ $OWFE_LOG.level = Logger::INFO
38
+ FileUtils.rm_rf WORK
39
+ end
40
+
41
+ def test_0
42
+
43
+ #$OWFE_LOG.level = Logger::DEBUG
44
+
45
+ trace = []
46
+
47
+ @engine.register_participant :alpha do
48
+ trace << :alpha
49
+ end
50
+
51
+ @engine.reload
52
+
53
+ ps = @engine.process_status "20080212-moshijuzuke" # an XML process
54
+ exp = ps.expressions.first
55
+ wi = exp.applied_workitem
56
+ wi.message = "back from obsolesence"
57
+
58
+ @engine.reply wi
59
+
60
+ sleep 0.350
61
+
62
+ assert_equal [ :alpha ], trace
63
+
64
+ ps = @engine.process_status "20080212-moshijuzuke" # an XML process
65
+
66
+ assert_nil ps
67
+ end
68
+
69
+ def test_1
70
+
71
+ #$OWFE_LOG.level = Logger::DEBUG
72
+
73
+ trace = []
74
+
75
+ #@engine.register_participant :employee do
76
+ # trace << :assistant
77
+ #end
78
+ #@engine.register_participant :employee do
79
+ # trace << :employee
80
+ #end
81
+ [ :user_bob, :user_alice ].each do |p|
82
+ @engine.register_participant p do
83
+ trace << p
84
+ end
85
+ end
86
+
87
+ @engine.reload
88
+
89
+ ps = @engine.process_status "20080213-depejetzube" # an ruby procdef
90
+ exp = ps.expressions.first
91
+ wi = exp.applied_workitem
92
+
93
+ @engine.reply wi
94
+
95
+ sleep 0.400
96
+
97
+ assert_equal [ :user_bob, :user_bob ], trace
98
+
99
+ assert_nil @engine.process_status("20080213-depejetzube")
100
+ end
101
+ end