ruote 2.1.11 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (217) hide show
  1. data/CHANGELOG.txt +60 -0
  2. data/CREDITS.txt +22 -4
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +6 -7
  5. data/Rakefile +58 -59
  6. data/TODO.txt +137 -65
  7. data/couch_url.txt +1 -0
  8. data/jruby_issue.txt +32 -0
  9. data/lib/ruote.rb +1 -1
  10. data/lib/ruote/context.rb +12 -10
  11. data/lib/ruote/engine.rb +280 -145
  12. data/lib/ruote/engine/process_error.rb +5 -5
  13. data/lib/ruote/engine/process_status.rb +47 -28
  14. data/lib/ruote/exp/command.rb +7 -10
  15. data/lib/ruote/exp/commanded.rb +2 -2
  16. data/lib/ruote/exp/condition.rb +130 -43
  17. data/lib/ruote/exp/fe_add_branches.rb +2 -2
  18. data/lib/ruote/exp/fe_apply.rb +1 -1
  19. data/lib/ruote/exp/fe_cancel_process.rb +3 -3
  20. data/lib/ruote/exp/fe_command.rb +3 -3
  21. data/lib/ruote/exp/fe_concurrence.rb +4 -4
  22. data/lib/ruote/exp/fe_concurrent_iterator.rb +17 -5
  23. data/lib/ruote/exp/fe_cron.rb +3 -3
  24. data/lib/ruote/exp/fe_cursor.rb +5 -5
  25. data/lib/ruote/exp/fe_define.rb +3 -3
  26. data/lib/ruote/exp/fe_echo.rb +3 -3
  27. data/lib/ruote/exp/fe_equals.rb +2 -2
  28. data/lib/ruote/exp/fe_error.rb +2 -2
  29. data/lib/ruote/exp/fe_filter.rb +519 -0
  30. data/lib/ruote/exp/fe_forget.rb +9 -2
  31. data/lib/ruote/exp/fe_given.rb +154 -0
  32. data/lib/ruote/exp/fe_if.rb +16 -13
  33. data/lib/ruote/exp/fe_inc.rb +3 -3
  34. data/lib/ruote/exp/fe_iterator.rb +4 -4
  35. data/lib/ruote/exp/fe_let.rb +75 -0
  36. data/lib/ruote/exp/fe_listen.rb +68 -12
  37. data/lib/ruote/exp/fe_lose.rb +110 -0
  38. data/lib/ruote/exp/fe_noop.rb +1 -1
  39. data/lib/ruote/exp/{fe_when.rb → fe_once.rb} +25 -21
  40. data/lib/ruote/exp/fe_participant.rb +14 -17
  41. data/lib/ruote/exp/fe_redo.rb +10 -6
  42. data/lib/ruote/exp/fe_ref.rb +1 -1
  43. data/lib/ruote/exp/fe_registerp.rb +112 -0
  44. data/lib/ruote/exp/fe_reserve.rb +3 -3
  45. data/lib/ruote/exp/fe_restore.rb +2 -2
  46. data/lib/ruote/exp/fe_save.rb +2 -2
  47. data/lib/ruote/exp/fe_sequence.rb +3 -4
  48. data/lib/ruote/exp/fe_set.rb +16 -7
  49. data/lib/ruote/exp/fe_subprocess.rb +23 -1
  50. data/lib/ruote/exp/fe_that.rb +92 -0
  51. data/lib/ruote/exp/fe_undo.rb +3 -3
  52. data/lib/ruote/exp/fe_unregisterp.rb +71 -0
  53. data/lib/ruote/exp/fe_wait.rb +2 -2
  54. data/lib/ruote/exp/flowexpression.rb +153 -78
  55. data/lib/ruote/exp/iterator.rb +2 -2
  56. data/lib/ruote/exp/merge.rb +2 -2
  57. data/lib/ruote/exp/ro_attributes.rb +14 -12
  58. data/lib/ruote/exp/ro_filters.rb +136 -0
  59. data/lib/ruote/exp/ro_persist.rb +51 -35
  60. data/lib/ruote/exp/ro_variables.rb +18 -27
  61. data/lib/ruote/fei.rb +73 -33
  62. data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
  63. data/lib/ruote/id/wfid_generator.rb +11 -4
  64. data/lib/ruote/log/default_history.rb +122 -0
  65. data/lib/ruote/log/pretty.rb +36 -8
  66. data/lib/ruote/log/storage_history.rb +37 -5
  67. data/lib/ruote/log/test_logger.rb +26 -24
  68. data/lib/ruote/log/wait_logger.rb +5 -3
  69. data/lib/ruote/part/block_participant.rb +22 -11
  70. data/lib/ruote/part/engine_participant.rb +6 -7
  71. data/lib/ruote/part/local_participant.rb +6 -12
  72. data/lib/ruote/part/no_op_participant.rb +4 -4
  73. data/lib/ruote/part/null_participant.rb +4 -4
  74. data/lib/ruote/part/smtp_participant.rb +4 -4
  75. data/lib/ruote/part/storage_participant.rb +40 -20
  76. data/lib/ruote/part/template.rb +4 -4
  77. data/lib/ruote/participant.rb +0 -1
  78. data/lib/ruote/{parser.rb → reader.rb} +30 -25
  79. data/lib/ruote/{parser → reader}/ruby_dsl.rb +28 -11
  80. data/lib/ruote/{parser → reader}/xml.rb +6 -5
  81. data/lib/ruote/receiver/base.rb +35 -13
  82. data/lib/ruote/storage/base.rb +20 -18
  83. data/lib/ruote/storage/composite_storage.rb +10 -10
  84. data/lib/ruote/storage/fs_storage.rb +17 -10
  85. data/lib/ruote/storage/hash_storage.rb +29 -18
  86. data/lib/ruote/svc/dispatch_pool.rb +41 -14
  87. data/lib/ruote/svc/dollar_sub.rb +50 -17
  88. data/lib/ruote/svc/error_handler.rb +19 -11
  89. data/lib/ruote/svc/expression_map.rb +4 -4
  90. data/lib/ruote/svc/participant_list.rb +105 -100
  91. data/lib/ruote/svc/tracker.rb +58 -18
  92. data/lib/ruote/svc/treechecker.rb +51 -24
  93. data/lib/ruote/tree_dot.rb +4 -4
  94. data/lib/ruote/util/filter.rb +440 -0
  95. data/lib/ruote/util/hashdot.rb +4 -4
  96. data/lib/ruote/util/look.rb +2 -6
  97. data/lib/ruote/util/lookup.rb +9 -7
  98. data/lib/ruote/util/misc.rb +40 -8
  99. data/lib/ruote/util/ometa.rb +1 -1
  100. data/lib/ruote/util/serializer.rb +4 -4
  101. data/lib/ruote/util/subprocess.rb +29 -9
  102. data/lib/ruote/util/time.rb +4 -4
  103. data/lib/ruote/util/tree.rb +3 -3
  104. data/lib/ruote/version.rb +2 -2
  105. data/lib/ruote/worker.rb +55 -32
  106. data/lib/ruote/workitem.rb +64 -11
  107. data/ruote.gemspec +31 -302
  108. data/test/bm/launch_bench.rb +37 -0
  109. data/test/functional/base.rb +60 -18
  110. data/test/functional/concurrent_base.rb +2 -2
  111. data/test/functional/ct_0_concurrence.rb +1 -1
  112. data/test/functional/ct_1_iterator.rb +1 -1
  113. data/test/functional/ct_2_cancel.rb +1 -1
  114. data/test/functional/eft_0_process_definition.rb +2 -2
  115. data/test/functional/eft_10_cancel_process.rb +1 -1
  116. data/test/functional/eft_11_wait.rb +19 -11
  117. data/test/functional/eft_12_listen.rb +79 -13
  118. data/test/functional/eft_13_iterator.rb +13 -10
  119. data/test/functional/eft_14_cursor.rb +98 -9
  120. data/test/functional/eft_15_loop.rb +6 -4
  121. data/test/functional/eft_16_if.rb +12 -0
  122. data/test/functional/eft_18_concurrent_iterator.rb +31 -32
  123. data/test/functional/eft_19_reserve.rb +4 -4
  124. data/test/functional/eft_1_echo.rb +9 -0
  125. data/test/functional/eft_20_save.rb +4 -4
  126. data/test/functional/{eft_28_when.rb → eft_28_once.rb} +33 -7
  127. data/test/functional/eft_30_ref.rb +17 -2
  128. data/test/functional/eft_31_registerp.rb +130 -0
  129. data/test/functional/eft_32_lose.rb +93 -0
  130. data/test/functional/eft_33_let.rb +31 -0
  131. data/test/functional/eft_34_given.rb +123 -0
  132. data/test/functional/eft_35_filter.rb +269 -0
  133. data/test/functional/eft_3_participant.rb +4 -6
  134. data/test/functional/eft_4_set.rb +16 -2
  135. data/test/functional/eft_5_subprocess.rb +2 -4
  136. data/test/functional/eft_6_concurrence.rb +29 -29
  137. data/test/functional/eft_8_undo.rb +39 -3
  138. data/test/functional/eft_9_redo.rb +94 -2
  139. data/test/functional/ft_10_dollar.rb +81 -2
  140. data/test/functional/ft_11_recursion.rb +13 -17
  141. data/test/functional/ft_12_launchitem.rb +9 -5
  142. data/test/functional/ft_13_variables.rb +7 -9
  143. data/test/functional/ft_14_re_apply.rb +6 -9
  144. data/test/functional/ft_15_timeout.rb +18 -18
  145. data/test/functional/ft_16_participant_params.rb +1 -3
  146. data/test/functional/ft_17_conditional.rb +25 -2
  147. data/test/functional/ft_18_kill.rb +65 -12
  148. data/test/functional/ft_1_process_status.rb +147 -71
  149. data/test/functional/ft_20_storage_participant.rb +0 -1
  150. data/test/functional/ft_21_forget.rb +82 -1
  151. data/test/functional/{ft_24_block_participants.rb → ft_24_block_participant.rb} +42 -11
  152. data/test/functional/ft_25_receiver.rb +47 -17
  153. data/test/functional/{ft_26_participant_timeout.rb → ft_26_participant_rtimeout.rb} +56 -19
  154. data/test/functional/ft_29_part_template.rb +6 -5
  155. data/test/functional/ft_2_errors.rb +21 -37
  156. data/test/functional/ft_30_smtp_participant.rb +1 -1
  157. data/test/functional/ft_31_part_blocking.rb +8 -6
  158. data/test/functional/ft_34_cursor_rewind.rb +13 -10
  159. data/test/functional/ft_35_add_service.rb +1 -1
  160. data/test/functional/ft_36_storage_history.rb +24 -1
  161. data/test/functional/ft_37_default_history.rb +109 -0
  162. data/test/functional/ft_38_participant_more.rb +10 -10
  163. data/test/functional/ft_39_wait_for.rb +12 -9
  164. data/test/functional/ft_3_participant_registration.rb +111 -32
  165. data/test/functional/ft_40_wait_logger.rb +2 -1
  166. data/test/functional/ft_41_participants.rb +30 -4
  167. data/test/functional/ft_43_participant_on_reply.rb +6 -23
  168. data/test/functional/ft_45_participant_accept.rb +4 -4
  169. data/test/functional/ft_46_launch_single.rb +36 -2
  170. data/test/functional/ft_47_wfid_generator.rb +54 -0
  171. data/test/functional/ft_48_lose.rb +112 -0
  172. data/test/functional/ft_49_engine_on_error.rb +201 -0
  173. data/test/functional/ft_4_cancel.rb +66 -6
  174. data/test/functional/ft_50_engine_config.rb +22 -0
  175. data/test/functional/ft_51_misc.rb +67 -0
  176. data/test/functional/ft_52_case.rb +134 -0
  177. data/test/functional/ft_53_engine_on_terminate.rb +95 -0
  178. data/test/functional/ft_54_patterns.rb +104 -0
  179. data/test/functional/{ft_37_engine_participant.rb → ft_55_engine_participant.rb} +4 -5
  180. data/test/functional/ft_56_filter_attribute.rb +259 -0
  181. data/test/functional/ft_5_on_error.rb +77 -30
  182. data/test/functional/ft_6_on_cancel.rb +66 -11
  183. data/test/functional/ft_7_tags.rb +94 -5
  184. data/test/functional/ft_8_participant_consumption.rb +36 -5
  185. data/test/functional/ft_9_subprocesses.rb +10 -10
  186. data/test/functional/rt_1_listen.rb +3 -3
  187. data/test/functional/{rt_3_when.rb → rt_3_once.rb} +4 -4
  188. data/test/functional/storage_helper.rb +15 -13
  189. data/test/functional/test.rb +1 -3
  190. data/test/test_helper.rb +0 -8
  191. data/test/unit/storage.rb +154 -10
  192. data/test/unit/{ut_0_ruby_parser.rb → ut_0_ruby_reader.rb} +61 -11
  193. data/test/unit/ut_11_lookup.rb +7 -0
  194. data/test/unit/ut_13_serializer.rb +1 -1
  195. data/test/unit/ut_15_util.rb +23 -0
  196. data/test/unit/{ut_16_parser.rb → ut_16_reader.rb} +11 -13
  197. data/test/unit/ut_1_fei.rb +57 -10
  198. data/test/unit/ut_20_composite_storage.rb +25 -11
  199. data/test/unit/ut_21_participant_list.rb +47 -0
  200. data/test/unit/ut_22_filter.rb +903 -0
  201. data/test/unit/ut_3_wait_logger.rb +2 -6
  202. data/test/unit/ut_6_condition.rb +164 -17
  203. data/test/unit/ut_7_workitem.rb +28 -0
  204. data/test/unit/ut_8_tree_to_dot.rb +1 -1
  205. data/test/unit/{ut_9_xml_parser.rb → ut_9_xml_reader.rb} +5 -5
  206. metadata +108 -84
  207. data/.gitignore +0 -4
  208. data/examples/barley.rb +0 -391
  209. data/examples/flickr_report.rb +0 -107
  210. data/examples/pong.rb +0 -37
  211. data/examples/ruote_quickstart.rb +0 -43
  212. data/examples/web_first_page.rb +0 -68
  213. data/lib/ruote/part/hash_participant.rb +0 -91
  214. data/test/README.rdoc +0 -15
  215. data/test/functional/crunner.sh +0 -19
  216. data/test/pdef.xml +0 -7
  217. data/test/unit/ut_2_wfidgen.rb +0 -21
@@ -0,0 +1,269 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Mon Jan 31 14:45:09 JST 2011
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+
11
+ class EftFilterTest < Test::Unit::TestCase
12
+ include FunctionalBase
13
+
14
+ def assert_terminates(pdef, fields, result=nil)
15
+
16
+ wfid = @engine.launch(pdef, fields)
17
+ r = @engine.wait_for(wfid)
18
+
19
+ assert_equal 'terminated', r['action']
20
+ assert_equal(result, r['workitem']['fields']) if result
21
+ end
22
+
23
+ def assert_does_not_validate(pdef, fields={})
24
+
25
+ wfid = @engine.launch(pdef, fields)
26
+ r = @engine.wait_for(wfid)
27
+
28
+ assert_equal 'error_intercepted', r['action']
29
+ assert_match /ValidationError/, @engine.errors.first.message
30
+ end
31
+
32
+ #
33
+ # the tests
34
+
35
+ def test_filter_single_rule_validation
36
+
37
+ pdef = Ruote.process_definition do
38
+ filter 'x', :type => 'string'
39
+ end
40
+
41
+ assert_terminates(pdef, 'x' => 'nada')
42
+ end
43
+
44
+ def test_filter_single_rule_validation_failure
45
+
46
+ pdef = Ruote.process_definition do
47
+ filter 'x', :type => 'string'
48
+ end
49
+
50
+ assert_does_not_validate(pdef, 'x' => 2)
51
+ end
52
+
53
+ def test_filter_single_rule_transformation
54
+
55
+ pdef = Ruote.process_definition do
56
+ filter 'x', :or => 'crimea'
57
+ end
58
+
59
+ assert_terminates(pdef, {}, { 'x' => 'crimea' })
60
+ end
61
+
62
+ def test_filter_single_rule_in
63
+
64
+ pdef = Ruote.process_definition do
65
+ filter 'colour', :in => %w[ red green blue ]
66
+ end
67
+
68
+ assert_terminates(pdef, 'colour' => 'green')
69
+ end
70
+
71
+ PDEF1 = Ruote.process_definition do
72
+ filter :in => [
73
+ { :field => 'x', :type => 'string' },
74
+ { :field => 'y', :type => 'number' }
75
+ ]
76
+ end
77
+
78
+ def test_filter_multiple_rules_validation
79
+
80
+ assert_terminates(PDEF1, 'x' => 's', 'y' => 2)
81
+ end
82
+
83
+ def test_filter_multiple_rules_validation_failure
84
+
85
+ assert_does_not_validate(PDEF1, 'x' => 's', 'y' => 's')
86
+ end
87
+
88
+ def test_filter_multiple_rules_transformation
89
+
90
+ pdef = Ruote.process_definition do
91
+ filter :in => [
92
+ { :field => 'x', :or => 'alpha' },
93
+ { :field => 'y', :or => 'bravo' }
94
+ ]
95
+ end
96
+
97
+ assert_terminates(pdef, {}, { 'x' => 'alpha', 'y' => 'bravo' })
98
+ end
99
+
100
+ def test_filter_in_variable
101
+
102
+ pdef = Ruote.process_definition do
103
+ set 'v:toto' => [
104
+ { :field => 'a', :set => 'A' },
105
+ { :field => 'b', :or => 'B' },
106
+ ]
107
+ filter 'v:toto'
108
+ end
109
+
110
+ assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
111
+ end
112
+
113
+ def test_in_filter_in_variable
114
+
115
+ # compatibility with the :filter attribute
116
+
117
+ pdef = Ruote.process_definition do
118
+ set 'v:toto' => { :in => [
119
+ { :field => 'a', :set => 'A' },
120
+ { :field => 'b', :or => 'B' },
121
+ ] }
122
+ filter 'v:toto'
123
+ end
124
+
125
+ assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
126
+ end
127
+
128
+ def test_filter_in_field
129
+
130
+ pdef = Ruote.process_definition do
131
+ set 'f:toto' => [
132
+ { :field => 'a', :set => 'A' },
133
+ { :field => 'b', :or => 'B' },
134
+ ]
135
+ filter 'f:toto'
136
+ unset 'f:toto'
137
+ end
138
+
139
+ assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
140
+ end
141
+
142
+ def test_in_filter_in_field
143
+
144
+ pdef = Ruote.process_definition do
145
+ set 'f:toto' => { :in => [
146
+ { :field => 'a', :set => 'A' },
147
+ { :field => 'b', :or => 'B' },
148
+ ] }
149
+ filter 'f:toto'
150
+ unset 'f:toto'
151
+ end
152
+
153
+ assert_terminates(pdef, {}, { 'a' => 'A', 'b' => 'B' })
154
+ end
155
+
156
+ def test_tilde
157
+
158
+ # the ~ points to the hash as it was right before the filtering began
159
+
160
+ pdef = Ruote.process_definition do
161
+ filter :in => [
162
+ { :field => 'x', :set => 'X' },
163
+ { :field => 'x', :copy_from => '~.x' },
164
+ ]
165
+ end
166
+
167
+ assert_terminates(pdef, { 'x' => 1 }, { 'x' => 1 })
168
+ end
169
+
170
+ def test_double_tilde
171
+
172
+ # the ~~ points to the workitem fields as they are in the parent expression
173
+
174
+ pdef = Ruote.process_definition do
175
+ filter 'x', :set => 'X'
176
+ filter 'x', :copy_from => '~~.x'
177
+ end
178
+
179
+ assert_terminates(pdef, { 'x' => 1 }, { 'x' => 1 })
180
+ end
181
+
182
+ def test_record
183
+
184
+ pdef = Ruote.process_definition do
185
+ filter 'x', :type => 'string', :record => true
186
+ end
187
+
188
+ assert_terminates(
189
+ pdef,
190
+ { 'x' => 1 },
191
+ { '__validation_errors__' => [
192
+ [ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ]
193
+ ],
194
+ 'x' => 1
195
+ })
196
+ end
197
+
198
+ def test_record__complex
199
+
200
+ pdef = Ruote.process_definition do
201
+ filter :in => [
202
+ { :field => 'x', :type => 'string', :record => true },
203
+ { :field => 'y', :type => 'number' }
204
+ ]
205
+ end
206
+
207
+ assert_terminates(
208
+ pdef,
209
+ { 'x' => 1 },
210
+ { '__validation_errors__' => [
211
+ [ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ],
212
+ [ { 'type' => 'number', 'field' => 'y' }, 'y', nil ]
213
+ ],
214
+ 'x' => 1
215
+ })
216
+ end
217
+
218
+ def test_record_in_designated_field
219
+
220
+ pdef = Ruote.process_definition do
221
+ filter 'x', :type => 'string', :record => 'verrors'
222
+ end
223
+
224
+ assert_terminates(
225
+ pdef,
226
+ { 'x' => 1 },
227
+ { 'verrors' => [
228
+ [ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ]
229
+ ],
230
+ 'x' => 1
231
+ })
232
+ end
233
+
234
+ def test_record_accumulates
235
+
236
+ pdef = Ruote.process_definition do
237
+ filter 'x', :type => 'string', :record => true
238
+ filter 'y', :type => 'number', :record => true
239
+ end
240
+
241
+ assert_terminates(
242
+ pdef,
243
+ { 'x' => 1 },
244
+ { '__validation_errors__' => [
245
+ [ { 'type' => 'string', 'field' => 'x' }, 'x', 1 ],
246
+ [ { 'type' => 'number', 'field' => 'y' }, 'y', nil ]
247
+ ],
248
+ 'x' => 1
249
+ })
250
+ end
251
+
252
+ def test_record_flushes_and_accumulates
253
+
254
+ pdef = Ruote.process_definition do
255
+ filter 'x', :type => 'string', :record => true
256
+ filter 'y', :type => 'number', :record => true, :flush => true
257
+ end
258
+
259
+ assert_terminates(
260
+ pdef,
261
+ { 'x' => 1 },
262
+ { '__validation_errors__' => [
263
+ [ { 'type' => 'number', 'field' => 'y' }, 'y', nil ]
264
+ ],
265
+ 'x' => 1
266
+ })
267
+ end
268
+ end
269
+
@@ -68,7 +68,7 @@ class EftParticipantTest < Test::Unit::TestCase
68
68
  delta :tag => 'whatever'
69
69
  end
70
70
 
71
- delta = @engine.register_participant :delta, Ruote::HashParticipant.new
71
+ delta = @engine.register_participant :delta, Ruote::StorageParticipant
72
72
 
73
73
  @engine.launch(pdef)
74
74
  wait_for(:delta)
@@ -88,7 +88,7 @@ class EftParticipantTest < Test::Unit::TestCase
88
88
 
89
89
  %w[ eecho fox gamma ].each do |pname|
90
90
  @engine.register_participant pname do |workitem|
91
- @tracer << "#{pname}\n"
91
+ @tracer << "#{workitem.participant_name}\n"
92
92
  end
93
93
  end
94
94
 
@@ -104,11 +104,9 @@ class EftParticipantTest < Test::Unit::TestCase
104
104
  echo 'done.'
105
105
  end
106
106
 
107
- atts = nil
108
-
109
107
  @engine.register_participant :notify do |wi, fe|
110
108
  #p fe.attribute_text
111
- atts = fe.attributes
109
+ stash[:atts] = fe.attributes
112
110
  end
113
111
 
114
112
  #noisy
@@ -117,7 +115,7 @@ class EftParticipantTest < Test::Unit::TestCase
117
115
 
118
116
  assert_equal(
119
117
  { "commander of the left guard"=>nil, "if"=>"true", "ref"=>"notify" },
120
- atts)
118
+ stash[:atts])
121
119
  end
122
120
 
123
121
  def test_dispatched
@@ -223,9 +223,23 @@ class EftSetTest < Test::Unit::TestCase
223
223
 
224
224
  wait_for(wfid)
225
225
 
226
- ps = @engine.process(wfid)
226
+ assert_nil @engine.process(wfid)
227
+ assert_nil @engine.variables['v']
228
+ end
229
+
230
+ # 'rset' is an alias for 'set'.
231
+ #
232
+ # motivation at http://groups.google.com/group/openwferu-users/browse_thread/thread/9ac606e30ada686e
233
+ #
234
+ def test_rset
235
+
236
+ wfid = @engine.launch(Ruote.define do
237
+ rset 'developer' => 'Rebo'
238
+ end)
239
+
240
+ r = @engine.wait_for(wfid)
227
241
 
228
- assert_equal 1, ps.errors.size
242
+ assert_equal 'Rebo', r['workitem']['fields']['developer']
229
243
  end
230
244
  end
231
245
 
@@ -96,17 +96,15 @@ class EftSubprocessTest < Test::Unit::TestCase
96
96
  end
97
97
  end
98
98
 
99
- tree = nil
100
-
101
99
  @engine.register_participant :alpha do |workitem, fexp|
102
- tree = fexp.lookup_variable('tree')
100
+ stash[:tree] = fexp.lookup_variable('tree')
103
101
  end
104
102
 
105
103
  #noisy
106
104
 
107
105
  assert_trace '', pdef
108
106
 
109
- assert_equal ["noop", {}, []], tree
107
+ assert_equal ["noop", {}, []], stash[:tree]
110
108
  end
111
109
 
112
110
  def test_subprocess_uri
@@ -7,7 +7,7 @@
7
7
 
8
8
  require File.join(File.dirname(__FILE__), 'base')
9
9
 
10
- require 'ruote/part/hash_participant'
10
+ #require 'ruote/part/hash_participant'
11
11
 
12
12
 
13
13
  class EftConcurrenceTest < Test::Unit::TestCase
@@ -42,20 +42,20 @@ class EftConcurrenceTest < Test::Unit::TestCase
42
42
  bravo
43
43
  end
44
44
 
45
- count = 0
45
+ @engine.context.instance_eval do
46
+ @count = 0
47
+ end
48
+ # since block participants are evaluated in the context context
46
49
 
47
- alpha = @engine.register_participant :alpha do |workitem|
48
- workitem.fields['seen'] = 'indeed' if count == 1
50
+ alpha = @engine.register_participant :alpha, 'do_not_thread' => true do |wi|
51
+ wi.fields['seen'] = 'indeed' if @count == 1
49
52
  @tracer << "alpha\n"
50
- count = count + 1
53
+ @count = @count + 1
51
54
  nil
52
55
  end
53
- alpha.do_not_thread = true
54
-
55
- fields = nil
56
56
 
57
57
  @engine.register_participant :bravo do |workitem|
58
- fields = workitem.fields
58
+ stash[:fields] = workitem.fields
59
59
  nil
60
60
  end
61
61
 
@@ -67,10 +67,10 @@ class EftConcurrenceTest < Test::Unit::TestCase
67
67
  # {'1'=>{"seen"=>"indeed"}, '0'=>{}, "params"=>{"ref"=>"bravo"}},
68
68
  # fields)
69
69
 
70
- params = fields.delete('params')
70
+ params = @engine.context.stash[:fields].delete('params')
71
71
 
72
72
  assert_equal({ 'ref' => 'bravo' }, params)
73
- assert_match /seen/, fields.inspect
73
+ assert_match /seen/, @engine.context.stash[:fields].inspect
74
74
  end
75
75
 
76
76
  def test_over_unless
@@ -85,17 +85,19 @@ class EftConcurrenceTest < Test::Unit::TestCase
85
85
  echo 'done.'
86
86
  end
87
87
 
88
- count = 0
88
+ @engine.context.instance_eval do
89
+ @count = 0
90
+ end
91
+ # since block participants are evaluated in the context context
89
92
 
90
- alpha = @engine.register_participant :alpha do |workitem|
91
- if count > 1
92
- workitem.fields['ok'] = false
93
+ alpha = @engine.register_participant :alpha, 'do_not_thread' => true do |wi|
94
+ if @count > 1
95
+ wi.fields['ok'] = false
93
96
  else
94
97
  @tracer << "a\n"
95
- count = count + 1
98
+ @count = @count + 1
96
99
  end
97
100
  end
98
- alpha.do_not_thread = true
99
101
 
100
102
  fields = nil
101
103
 
@@ -125,7 +127,7 @@ class EftConcurrenceTest < Test::Unit::TestCase
125
127
 
126
128
  # helper
127
129
  #
128
- def run_concurrence (concurrence_attributes, noise)
130
+ def run_concurrence(concurrence_attributes, noise)
129
131
 
130
132
  pdef = Ruote.process_definition do
131
133
  sequence do
@@ -137,7 +139,7 @@ class EftConcurrenceTest < Test::Unit::TestCase
137
139
  alpha
138
140
  end
139
141
 
140
- alpha = @engine.register_participant :alpha, Ruote::HashParticipant.new
142
+ alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
141
143
 
142
144
  noisy if noise
143
145
 
@@ -206,7 +208,7 @@ class EftConcurrenceTest < Test::Unit::TestCase
206
208
 
207
209
  # helper
208
210
  #
209
- def run_test_count (remaining, noise)
211
+ def run_test_count(remaining, noise)
210
212
 
211
213
  pdef = Ruote.process_definition do
212
214
  concurrence :count => 1, :remaining => remaining do
@@ -215,8 +217,7 @@ class EftConcurrenceTest < Test::Unit::TestCase
215
217
  end
216
218
  end
217
219
 
218
- @alpha = @engine.register_participant :alpha, Ruote::HashParticipant.new
219
- @bravo = @engine.register_participant :bravo, Ruote::HashParticipant.new
220
+ @engine.register_participant '.+', Ruote::StorageParticipant
220
221
 
221
222
  noisy if noise
222
223
 
@@ -224,7 +225,7 @@ class EftConcurrenceTest < Test::Unit::TestCase
224
225
 
225
226
  wait_for(:alpha)
226
227
 
227
- @alpha.reply(@alpha.first)
228
+ @engine.storage_participant.reply(@engine.storage_participant.first)
228
229
 
229
230
  wait_for(wfid)
230
231
 
@@ -244,8 +245,7 @@ class EftConcurrenceTest < Test::Unit::TestCase
244
245
 
245
246
  sleep 0.350 # since now dispatch_cancel occurs asynchronously...
246
247
 
247
- assert_equal 0, @alpha.size
248
- assert_equal 0, @bravo.size
248
+ assert_equal 0, @engine.storage_participant.size
249
249
  end
250
250
 
251
251
  def test_count_remaining_forget
@@ -256,15 +256,15 @@ class EftConcurrenceTest < Test::Unit::TestCase
256
256
 
257
257
  #assert_equal 1, logger.log.select { |e| e['action'] == 'forget' }.size
258
258
 
259
- assert_equal 0, @alpha.size
260
- assert_equal 1, @bravo.size
259
+ assert_equal 1, @engine.storage_participant.size
260
+ assert_equal 'bravo', @engine.storage_participant.first.participant_name
261
261
 
262
262
  #@engine.context.storage.get_many('expressions').each { |e| p e['fei'] }
263
263
  #puts @engine.context.storage.dump('expressions')
264
264
  assert_equal 2, @engine.context.storage.get_many('expressions').size
265
265
  assert_not_nil @engine.process(wfid)
266
266
 
267
- @bravo.reply(@bravo.first)
267
+ @engine.storage_participant.reply(@engine.storage_participant.first)
268
268
 
269
269
  wait_for(wfid)
270
270
 
@@ -281,7 +281,7 @@ class EftConcurrenceTest < Test::Unit::TestCase
281
281
  end
282
282
  end
283
283
 
284
- alpha = @engine.register_participant :alpha, Ruote::HashParticipant.new
284
+ alpha = @engine.register_participant :alpha, Ruote::StorageParticipant
285
285
 
286
286
  #noisy
287
287