ruote 2.1.11 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +60 -0
- data/CREDITS.txt +22 -4
- data/LICENSE.txt +1 -1
- data/README.rdoc +6 -7
- data/Rakefile +58 -59
- data/TODO.txt +137 -65
- data/couch_url.txt +1 -0
- data/jruby_issue.txt +32 -0
- data/lib/ruote.rb +1 -1
- data/lib/ruote/context.rb +12 -10
- data/lib/ruote/engine.rb +280 -145
- data/lib/ruote/engine/process_error.rb +5 -5
- data/lib/ruote/engine/process_status.rb +47 -28
- data/lib/ruote/exp/command.rb +7 -10
- data/lib/ruote/exp/commanded.rb +2 -2
- data/lib/ruote/exp/condition.rb +130 -43
- data/lib/ruote/exp/fe_add_branches.rb +2 -2
- data/lib/ruote/exp/fe_apply.rb +1 -1
- data/lib/ruote/exp/fe_cancel_process.rb +3 -3
- data/lib/ruote/exp/fe_command.rb +3 -3
- data/lib/ruote/exp/fe_concurrence.rb +4 -4
- data/lib/ruote/exp/fe_concurrent_iterator.rb +17 -5
- data/lib/ruote/exp/fe_cron.rb +3 -3
- data/lib/ruote/exp/fe_cursor.rb +5 -5
- data/lib/ruote/exp/fe_define.rb +3 -3
- data/lib/ruote/exp/fe_echo.rb +3 -3
- data/lib/ruote/exp/fe_equals.rb +2 -2
- data/lib/ruote/exp/fe_error.rb +2 -2
- data/lib/ruote/exp/fe_filter.rb +519 -0
- data/lib/ruote/exp/fe_forget.rb +9 -2
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +16 -13
- data/lib/ruote/exp/fe_inc.rb +3 -3
- data/lib/ruote/exp/fe_iterator.rb +4 -4
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +68 -12
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +1 -1
- data/lib/ruote/exp/{fe_when.rb → fe_once.rb} +25 -21
- data/lib/ruote/exp/fe_participant.rb +14 -17
- data/lib/ruote/exp/fe_redo.rb +10 -6
- data/lib/ruote/exp/fe_ref.rb +1 -1
- data/lib/ruote/exp/fe_registerp.rb +112 -0
- data/lib/ruote/exp/fe_reserve.rb +3 -3
- data/lib/ruote/exp/fe_restore.rb +2 -2
- data/lib/ruote/exp/fe_save.rb +2 -2
- data/lib/ruote/exp/fe_sequence.rb +3 -4
- data/lib/ruote/exp/fe_set.rb +16 -7
- data/lib/ruote/exp/fe_subprocess.rb +23 -1
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +3 -3
- data/lib/ruote/exp/fe_unregisterp.rb +71 -0
- data/lib/ruote/exp/fe_wait.rb +2 -2
- data/lib/ruote/exp/flowexpression.rb +153 -78
- data/lib/ruote/exp/iterator.rb +2 -2
- data/lib/ruote/exp/merge.rb +2 -2
- data/lib/ruote/exp/ro_attributes.rb +14 -12
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +51 -35
- data/lib/ruote/exp/ro_variables.rb +18 -27
- data/lib/ruote/fei.rb +73 -33
- data/lib/ruote/id/mnemo_wfid_generator.rb +1 -1
- data/lib/ruote/id/wfid_generator.rb +11 -4
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +36 -8
- data/lib/ruote/log/storage_history.rb +37 -5
- data/lib/ruote/log/test_logger.rb +26 -24
- data/lib/ruote/log/wait_logger.rb +5 -3
- data/lib/ruote/part/block_participant.rb +22 -11
- data/lib/ruote/part/engine_participant.rb +6 -7
- data/lib/ruote/part/local_participant.rb +6 -12
- data/lib/ruote/part/no_op_participant.rb +4 -4
- data/lib/ruote/part/null_participant.rb +4 -4
- data/lib/ruote/part/smtp_participant.rb +4 -4
- data/lib/ruote/part/storage_participant.rb +40 -20
- data/lib/ruote/part/template.rb +4 -4
- data/lib/ruote/participant.rb +0 -1
- data/lib/ruote/{parser.rb → reader.rb} +30 -25
- data/lib/ruote/{parser → reader}/ruby_dsl.rb +28 -11
- data/lib/ruote/{parser → reader}/xml.rb +6 -5
- data/lib/ruote/receiver/base.rb +35 -13
- data/lib/ruote/storage/base.rb +20 -18
- data/lib/ruote/storage/composite_storage.rb +10 -10
- data/lib/ruote/storage/fs_storage.rb +17 -10
- data/lib/ruote/storage/hash_storage.rb +29 -18
- data/lib/ruote/svc/dispatch_pool.rb +41 -14
- data/lib/ruote/svc/dollar_sub.rb +50 -17
- data/lib/ruote/svc/error_handler.rb +19 -11
- data/lib/ruote/svc/expression_map.rb +4 -4
- data/lib/ruote/svc/participant_list.rb +105 -100
- data/lib/ruote/svc/tracker.rb +58 -18
- data/lib/ruote/svc/treechecker.rb +51 -24
- data/lib/ruote/tree_dot.rb +4 -4
- data/lib/ruote/util/filter.rb +440 -0
- data/lib/ruote/util/hashdot.rb +4 -4
- data/lib/ruote/util/look.rb +2 -6
- data/lib/ruote/util/lookup.rb +9 -7
- data/lib/ruote/util/misc.rb +40 -8
- data/lib/ruote/util/ometa.rb +1 -1
- data/lib/ruote/util/serializer.rb +4 -4
- data/lib/ruote/util/subprocess.rb +29 -9
- data/lib/ruote/util/time.rb +4 -4
- data/lib/ruote/util/tree.rb +3 -3
- data/lib/ruote/version.rb +2 -2
- data/lib/ruote/worker.rb +55 -32
- data/lib/ruote/workitem.rb +64 -11
- data/ruote.gemspec +31 -302
- data/test/bm/launch_bench.rb +37 -0
- data/test/functional/base.rb +60 -18
- data/test/functional/concurrent_base.rb +2 -2
- data/test/functional/ct_0_concurrence.rb +1 -1
- data/test/functional/ct_1_iterator.rb +1 -1
- data/test/functional/ct_2_cancel.rb +1 -1
- data/test/functional/eft_0_process_definition.rb +2 -2
- data/test/functional/eft_10_cancel_process.rb +1 -1
- data/test/functional/eft_11_wait.rb +19 -11
- data/test/functional/eft_12_listen.rb +79 -13
- data/test/functional/eft_13_iterator.rb +13 -10
- data/test/functional/eft_14_cursor.rb +98 -9
- data/test/functional/eft_15_loop.rb +6 -4
- data/test/functional/eft_16_if.rb +12 -0
- data/test/functional/eft_18_concurrent_iterator.rb +31 -32
- data/test/functional/eft_19_reserve.rb +4 -4
- data/test/functional/eft_1_echo.rb +9 -0
- data/test/functional/eft_20_save.rb +4 -4
- data/test/functional/{eft_28_when.rb → eft_28_once.rb} +33 -7
- data/test/functional/eft_30_ref.rb +17 -2
- data/test/functional/eft_31_registerp.rb +130 -0
- data/test/functional/eft_32_lose.rb +93 -0
- data/test/functional/eft_33_let.rb +31 -0
- data/test/functional/eft_34_given.rb +123 -0
- data/test/functional/eft_35_filter.rb +269 -0
- data/test/functional/eft_3_participant.rb +4 -6
- data/test/functional/eft_4_set.rb +16 -2
- data/test/functional/eft_5_subprocess.rb +2 -4
- data/test/functional/eft_6_concurrence.rb +29 -29
- data/test/functional/eft_8_undo.rb +39 -3
- data/test/functional/eft_9_redo.rb +94 -2
- data/test/functional/ft_10_dollar.rb +81 -2
- data/test/functional/ft_11_recursion.rb +13 -17
- data/test/functional/ft_12_launchitem.rb +9 -5
- data/test/functional/ft_13_variables.rb +7 -9
- data/test/functional/ft_14_re_apply.rb +6 -9
- data/test/functional/ft_15_timeout.rb +18 -18
- data/test/functional/ft_16_participant_params.rb +1 -3
- data/test/functional/ft_17_conditional.rb +25 -2
- data/test/functional/ft_18_kill.rb +65 -12
- data/test/functional/ft_1_process_status.rb +147 -71
- data/test/functional/ft_20_storage_participant.rb +0 -1
- data/test/functional/ft_21_forget.rb +82 -1
- data/test/functional/{ft_24_block_participants.rb → ft_24_block_participant.rb} +42 -11
- data/test/functional/ft_25_receiver.rb +47 -17
- data/test/functional/{ft_26_participant_timeout.rb → ft_26_participant_rtimeout.rb} +56 -19
- data/test/functional/ft_29_part_template.rb +6 -5
- data/test/functional/ft_2_errors.rb +21 -37
- data/test/functional/ft_30_smtp_participant.rb +1 -1
- data/test/functional/ft_31_part_blocking.rb +8 -6
- data/test/functional/ft_34_cursor_rewind.rb +13 -10
- data/test/functional/ft_35_add_service.rb +1 -1
- data/test/functional/ft_36_storage_history.rb +24 -1
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +10 -10
- data/test/functional/ft_39_wait_for.rb +12 -9
- data/test/functional/ft_3_participant_registration.rb +111 -32
- data/test/functional/ft_40_wait_logger.rb +2 -1
- data/test/functional/ft_41_participants.rb +30 -4
- data/test/functional/ft_43_participant_on_reply.rb +6 -23
- data/test/functional/ft_45_participant_accept.rb +4 -4
- data/test/functional/ft_46_launch_single.rb +36 -2
- data/test/functional/ft_47_wfid_generator.rb +54 -0
- data/test/functional/ft_48_lose.rb +112 -0
- data/test/functional/ft_49_engine_on_error.rb +201 -0
- data/test/functional/ft_4_cancel.rb +66 -6
- data/test/functional/ft_50_engine_config.rb +22 -0
- data/test/functional/ft_51_misc.rb +67 -0
- data/test/functional/ft_52_case.rb +134 -0
- data/test/functional/ft_53_engine_on_terminate.rb +95 -0
- data/test/functional/ft_54_patterns.rb +104 -0
- data/test/functional/{ft_37_engine_participant.rb → ft_55_engine_participant.rb} +4 -5
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_5_on_error.rb +77 -30
- data/test/functional/ft_6_on_cancel.rb +66 -11
- data/test/functional/ft_7_tags.rb +94 -5
- data/test/functional/ft_8_participant_consumption.rb +36 -5
- data/test/functional/ft_9_subprocesses.rb +10 -10
- data/test/functional/rt_1_listen.rb +3 -3
- data/test/functional/{rt_3_when.rb → rt_3_once.rb} +4 -4
- data/test/functional/storage_helper.rb +15 -13
- data/test/functional/test.rb +1 -3
- data/test/test_helper.rb +0 -8
- data/test/unit/storage.rb +154 -10
- data/test/unit/{ut_0_ruby_parser.rb → ut_0_ruby_reader.rb} +61 -11
- data/test/unit/ut_11_lookup.rb +7 -0
- data/test/unit/ut_13_serializer.rb +1 -1
- data/test/unit/ut_15_util.rb +23 -0
- data/test/unit/{ut_16_parser.rb → ut_16_reader.rb} +11 -13
- data/test/unit/ut_1_fei.rb +57 -10
- data/test/unit/ut_20_composite_storage.rb +25 -11
- data/test/unit/ut_21_participant_list.rb +47 -0
- data/test/unit/ut_22_filter.rb +903 -0
- data/test/unit/ut_3_wait_logger.rb +2 -6
- data/test/unit/ut_6_condition.rb +164 -17
- data/test/unit/ut_7_workitem.rb +28 -0
- data/test/unit/ut_8_tree_to_dot.rb +1 -1
- data/test/unit/{ut_9_xml_parser.rb → ut_9_xml_reader.rb} +5 -5
- metadata +108 -84
- data/.gitignore +0 -4
- data/examples/barley.rb +0 -391
- data/examples/flickr_report.rb +0 -107
- data/examples/pong.rb +0 -37
- data/examples/ruote_quickstart.rb +0 -43
- data/examples/web_first_page.rb +0 -68
- data/lib/ruote/part/hash_participant.rb +0 -91
- data/test/README.rdoc +0 -15
- data/test/functional/crunner.sh +0 -19
- data/test/pdef.xml +0 -7
- data/test/unit/ut_2_wfidgen.rb +0 -21
@@ -20,22 +20,53 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
20
20
|
@engine.register_participant :alpha do |workitem|
|
21
21
|
@tracer << 'alpha'
|
22
22
|
end
|
23
|
+
@engine.register_participant /^user_/, Ruote::NullParticipant
|
23
24
|
|
24
|
-
wait_for(
|
25
|
+
wait_for(2)
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
assert_equal(
|
28
|
+
'participant_registered',
|
29
|
+
logger.log[0]['action'])
|
29
30
|
|
30
31
|
assert_equal(
|
31
|
-
[
|
32
|
-
|
32
|
+
%w[ alpha /^user_/ ],
|
33
|
+
logger.log.collect { |msg| msg['regex'] })
|
33
34
|
|
34
35
|
assert_equal(
|
35
|
-
[ [
|
36
|
+
[ [ "^alpha$",
|
37
|
+
[ "Ruote::BlockParticipant",
|
38
|
+
{ "block" => "proc { |workitem| (@tracer << \"alpha\") }" } ] ],
|
39
|
+
[ "^user_",
|
40
|
+
[ "Ruote::NullParticipant",
|
41
|
+
{} ] ] ],
|
36
42
|
@engine.participant_list.collect { |pe| pe.to_a })
|
37
43
|
end
|
38
44
|
|
45
|
+
def test_participant_register_position
|
46
|
+
|
47
|
+
@engine.register_participant :ur, Ruote::StorageParticipant
|
48
|
+
|
49
|
+
assert_equal(
|
50
|
+
%w[ ^ur$ ],
|
51
|
+
@engine.participant_list.collect { |pe| pe.regex.to_s })
|
52
|
+
|
53
|
+
@engine.register_participant(
|
54
|
+
:first, Ruote::StorageParticipant, :position => :first)
|
55
|
+
@engine.register_participant(
|
56
|
+
:last, Ruote::StorageParticipant, :position => :last)
|
57
|
+
|
58
|
+
assert_equal(
|
59
|
+
%w[ ^first$ ^ur$ ^last$ ],
|
60
|
+
@engine.participant_list.collect { |pe| pe.regex.to_s })
|
61
|
+
|
62
|
+
@engine.register_participant(
|
63
|
+
:x, Ruote::StorageParticipant, :position => -2)
|
64
|
+
|
65
|
+
assert_equal(
|
66
|
+
%w[ ^first$ ^ur$ ^x$ ^last$ ],
|
67
|
+
@engine.participant_list.collect { |pe| pe.regex.to_s })
|
68
|
+
end
|
69
|
+
|
39
70
|
def test_double_registration
|
40
71
|
|
41
72
|
@engine.register_participant :alpha do |workitem|
|
@@ -48,12 +79,14 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
48
79
|
assert_equal 1, @engine.context.plist.send(:get_list)['list'].size
|
49
80
|
end
|
50
81
|
|
51
|
-
def
|
82
|
+
def test_register_and_return_something
|
52
83
|
|
53
84
|
pa = @engine.register_participant :alpha do |workitem|
|
54
85
|
end
|
86
|
+
pb = @engine.register_participant :bravo, Ruote::StorageParticipant
|
55
87
|
|
56
|
-
|
88
|
+
assert_nil pa
|
89
|
+
assert_equal Ruote::StorageParticipant, pb.class
|
57
90
|
end
|
58
91
|
|
59
92
|
def test_participant_unregister_by_name
|
@@ -63,7 +96,7 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
63
96
|
@engine.register_participant :alpha do |workitem|
|
64
97
|
end
|
65
98
|
|
66
|
-
@engine.unregister_participant
|
99
|
+
@engine.unregister_participant(:alpha)
|
67
100
|
|
68
101
|
wait_for(2)
|
69
102
|
Thread.pass
|
@@ -71,16 +104,14 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
71
104
|
msg = logger.log.last
|
72
105
|
assert_equal 'participant_unregistered', msg['action']
|
73
106
|
assert_equal '^alpha$', msg['regex']
|
74
|
-
|
75
|
-
assert_equal 0, @engine.context.plist.instantiated_participants.size
|
76
107
|
end
|
77
108
|
|
78
109
|
def test_participant_unregister
|
79
110
|
|
80
|
-
|
111
|
+
@engine.register_participant :alpha do |workitem|
|
81
112
|
end
|
82
113
|
|
83
|
-
@engine.unregister_participant
|
114
|
+
@engine.unregister_participant('alpha')
|
84
115
|
|
85
116
|
wait_for(2)
|
86
117
|
|
@@ -88,26 +119,28 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
88
119
|
assert_equal 'participant_unregistered', msg['action']
|
89
120
|
assert_equal '^alpha$', msg['regex']
|
90
121
|
|
91
|
-
assert_equal 0, @engine.context.plist.
|
122
|
+
assert_equal 0, @engine.context.plist.list.size
|
92
123
|
end
|
93
124
|
|
94
125
|
class MyParticipant
|
95
|
-
|
126
|
+
@@down = false
|
127
|
+
def self.down
|
128
|
+
@@down
|
129
|
+
end
|
96
130
|
def initialize
|
97
|
-
@down = false
|
98
131
|
end
|
99
132
|
def shutdown
|
100
|
-
|
133
|
+
@@down = true
|
101
134
|
end
|
102
135
|
end
|
103
136
|
|
104
137
|
def test_participant_shutdown
|
105
138
|
|
106
|
-
alpha = @engine.register :alpha, MyParticipant
|
139
|
+
alpha = @engine.register :alpha, MyParticipant
|
107
140
|
|
108
141
|
@engine.context.plist.shutdown
|
109
142
|
|
110
|
-
assert_equal true,
|
143
|
+
assert_equal true, MyParticipant.down
|
111
144
|
end
|
112
145
|
|
113
146
|
def test_participant_list_of_names
|
@@ -128,10 +161,10 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
128
161
|
f.write(%{
|
129
162
|
class RequiredParticipant
|
130
163
|
include Ruote::LocalParticipant
|
131
|
-
def initialize
|
164
|
+
def initialize(opts)
|
132
165
|
@opts = opts
|
133
166
|
end
|
134
|
-
def consume
|
167
|
+
def consume(workitem)
|
135
168
|
workitem.fields['message'] = @opts['message']
|
136
169
|
reply(workitem)
|
137
170
|
end
|
@@ -164,10 +197,10 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
164
197
|
f.write(%{
|
165
198
|
class RequiredParticipant
|
166
199
|
include Ruote::LocalParticipant
|
167
|
-
def initialize
|
200
|
+
def initialize(opts)
|
168
201
|
@opts = opts
|
169
202
|
end
|
170
|
-
def consume
|
203
|
+
def consume(workitem)
|
171
204
|
workitem.fields['message'] = 'second run'
|
172
205
|
reply(workitem)
|
173
206
|
end
|
@@ -194,10 +227,10 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
194
227
|
f.write(%{
|
195
228
|
class LoadedParticipant
|
196
229
|
include Ruote::LocalParticipant
|
197
|
-
def initialize
|
230
|
+
def initialize(opts)
|
198
231
|
@opts = opts
|
199
232
|
end
|
200
|
-
def consume
|
233
|
+
def consume(workitem)
|
201
234
|
workitem.fields['message'] = @opts['message']
|
202
235
|
reply(workitem)
|
203
236
|
end
|
@@ -230,10 +263,10 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
230
263
|
f.write(%{
|
231
264
|
class LoadedParticipant
|
232
265
|
include Ruote::LocalParticipant
|
233
|
-
def initialize
|
266
|
+
def initialize(opts)
|
234
267
|
@opts = opts
|
235
268
|
end
|
236
|
-
def consume
|
269
|
+
def consume(workitem)
|
237
270
|
workitem.fields['message'] = 'second run'
|
238
271
|
reply(workitem)
|
239
272
|
end
|
@@ -348,25 +381,31 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
348
381
|
alpha 'Participants::Alpha', 'flavour' => 'vanilla'
|
349
382
|
participant 'bravo', 'Participants::Bravo', :flavour => 'peach'
|
350
383
|
participant 'charlie', 'Participants::Charlie'
|
384
|
+
participant 'david' do |wi|
|
385
|
+
p wi
|
386
|
+
end
|
351
387
|
catchall 'Participants::Zebda', 'flavour' => 'coconut'
|
352
388
|
end
|
353
389
|
|
354
|
-
assert_equal
|
390
|
+
assert_equal 5, @engine.participant_list.size
|
355
391
|
|
356
392
|
assert_equal(
|
357
|
-
%w[ ^alpha$ ^bravo$ ^charlie$ ^.+$ ],
|
393
|
+
%w[ ^alpha$ ^bravo$ ^charlie$ ^david$ ^.+$ ],
|
358
394
|
@engine.participant_list.collect { |pe| pe.regex.to_s })
|
359
395
|
|
360
396
|
assert_equal(
|
361
397
|
%w[ Participants::Alpha
|
362
398
|
Participants::Bravo
|
363
399
|
Participants::Charlie
|
400
|
+
Ruote::BlockParticipant
|
364
401
|
Participants::Zebda ],
|
365
402
|
@engine.participant_list.collect { |pe| pe.classname })
|
366
403
|
|
367
404
|
assert_equal(
|
368
|
-
%w[ vanilla peach nil coconut ],
|
369
|
-
@engine.participant_list.collect { |pe|
|
405
|
+
%w[ vanilla peach nil nil coconut ],
|
406
|
+
@engine.participant_list.collect { |pe|
|
407
|
+
(pe.options['flavour'] || 'nil') rescue 'nil'
|
408
|
+
})
|
370
409
|
end
|
371
410
|
|
372
411
|
def test_register_block_catchall_default
|
@@ -379,5 +418,45 @@ class FtParticipantRegistrationTest < Test::Unit::TestCase
|
|
379
418
|
%w[ Ruote::StorageParticipant ],
|
380
419
|
@engine.participant_list.collect { |pe| pe.classname })
|
381
420
|
end
|
421
|
+
|
422
|
+
def test_argument_error_on_instantiated_participant
|
423
|
+
|
424
|
+
assert_raise ArgumentError do
|
425
|
+
@engine.register 'alpha', Ruote::StorageParticipant.new
|
426
|
+
end
|
427
|
+
assert_raise ArgumentError do
|
428
|
+
@engine.register 'alpha', Ruote::StorageParticipant.new, 'hello' => 'kitty'
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
class AaParticipant
|
433
|
+
include Ruote::LocalParticipant
|
434
|
+
attr_reader :opts
|
435
|
+
def initialize(opts)
|
436
|
+
@opts = opts
|
437
|
+
end
|
438
|
+
end
|
439
|
+
class BbParticipant < AaParticipant
|
440
|
+
def accept?(workitem)
|
441
|
+
false
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
def test_engine_participant
|
446
|
+
|
447
|
+
@engine.register do
|
448
|
+
alpha AaParticipant
|
449
|
+
bravo BbParticipant
|
450
|
+
catchall AaParticipant, :catch_all => 'oh yeah'
|
451
|
+
end
|
452
|
+
|
453
|
+
assert_equal AaParticipant, @engine.participant('alpha').class
|
454
|
+
assert_equal BbParticipant, @engine.participant('bravo').class
|
455
|
+
|
456
|
+
assert_equal AaParticipant, @engine.participant('charly').class
|
457
|
+
assert_equal 'oh yeah', @engine.participant('charly').opts['catch_all']
|
458
|
+
|
459
|
+
assert_equal Ruote::Context, @engine.participant('alpha').context.class
|
460
|
+
end
|
382
461
|
end
|
383
462
|
|
@@ -48,7 +48,8 @@ class FtWaitLoggerTest < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
wfid = @engine.launch(pdef)
|
50
50
|
|
51
|
-
sleep
|
51
|
+
sleep 0.500
|
52
|
+
sleep 2.000 if @engine.storage.class.name.match(/Couch/)
|
52
53
|
|
53
54
|
assert_equal 2, @engine.context.logger.instance_variable_get(:@seen).size
|
54
55
|
|
@@ -10,12 +10,12 @@ require File.join(File.dirname(__FILE__), 'base')
|
|
10
10
|
require 'ruote/part/local_participant'
|
11
11
|
|
12
12
|
|
13
|
-
class
|
13
|
+
class FtParticipantsTest < Test::Unit::TestCase
|
14
14
|
include FunctionalBase
|
15
15
|
|
16
16
|
class MyParticipant
|
17
17
|
include Ruote::LocalParticipant
|
18
|
-
def consume
|
18
|
+
def consume(workitem)
|
19
19
|
workitem.fields['seen'] = true
|
20
20
|
reply_to_engine(workitem)
|
21
21
|
end
|
@@ -23,10 +23,10 @@ class FtMiscParticipantTest < Test::Unit::TestCase
|
|
23
23
|
|
24
24
|
class MyMessageParticipant
|
25
25
|
include Ruote::LocalParticipant
|
26
|
-
def initialize
|
26
|
+
def initialize(opts)
|
27
27
|
@opts = opts
|
28
28
|
end
|
29
|
-
def consume
|
29
|
+
def consume(workitem)
|
30
30
|
workitem.fields['message'] = @opts['message']
|
31
31
|
reply_to_engine(workitem)
|
32
32
|
end
|
@@ -61,5 +61,31 @@ class FtMiscParticipantTest < Test::Unit::TestCase
|
|
61
61
|
|
62
62
|
assert_equal 'hi', r['workitem']['fields']['message']
|
63
63
|
end
|
64
|
+
|
65
|
+
class MyOtherParticipant
|
66
|
+
include Ruote::LocalParticipant
|
67
|
+
def consume(wi)
|
68
|
+
wi.fields['hello'] = 'kitty'
|
69
|
+
reply_to_engine(wi)
|
70
|
+
end
|
71
|
+
def on_reply(wi)
|
72
|
+
@context.tracer << wi.fields['hello'] + "\n"
|
73
|
+
@context.tracer << applied_workitem(wi.fei).fields['hello'] + "\n"
|
74
|
+
@context.tracer << workitem(wi.fei).fields['hello']
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_workitem_method
|
79
|
+
|
80
|
+
@engine.register 'alpha', MyOtherParticipant
|
81
|
+
|
82
|
+
#noisy
|
83
|
+
|
84
|
+
wfid = @engine.launch(Ruote.define { alpha }, 'hello' => 'world')
|
85
|
+
|
86
|
+
@engine.wait_for(wfid)
|
87
|
+
|
88
|
+
assert_equal %w[ kitty world world ], @tracer.to_a
|
89
|
+
end
|
64
90
|
end
|
65
91
|
|
@@ -15,12 +15,12 @@ class FtParticipantOnReplyTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
class MyParticipant
|
17
17
|
include Ruote::LocalParticipant
|
18
|
-
def initialize
|
18
|
+
def initialize(opts)
|
19
19
|
end
|
20
|
-
def consume
|
20
|
+
def consume(workitem)
|
21
21
|
reply(workitem)
|
22
22
|
end
|
23
|
-
def on_reply
|
23
|
+
def on_reply(workitem)
|
24
24
|
workitem.fields['message'] = 'hello'
|
25
25
|
end
|
26
26
|
end
|
@@ -41,31 +41,14 @@ class FtParticipantOnReplyTest < Test::Unit::TestCase
|
|
41
41
|
assert_trace('hello', pdef)
|
42
42
|
end
|
43
43
|
|
44
|
-
def test_instantiated_participant_on_reply
|
45
|
-
|
46
|
-
pdef = Ruote.process_definition do
|
47
|
-
sequence do
|
48
|
-
alpha
|
49
|
-
echo '${f:message}'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
@engine.register_participant :alpha, MyParticipant.new(nil)
|
54
|
-
# instantiated participant :-(
|
55
|
-
|
56
|
-
#noisy
|
57
|
-
|
58
|
-
assert_trace('hello', pdef)
|
59
|
-
end
|
60
|
-
|
61
44
|
class AwkwardParticipant
|
62
45
|
include Ruote::LocalParticipant
|
63
|
-
def initialize
|
46
|
+
def initialize(opts)
|
64
47
|
end
|
65
|
-
def consume
|
48
|
+
def consume(workitem)
|
66
49
|
reply(workitem)
|
67
50
|
end
|
68
|
-
def on_reply
|
51
|
+
def on_reply(workitem)
|
69
52
|
return if workitem.fields['pass']
|
70
53
|
raise "something went wrong"
|
71
54
|
end
|
@@ -16,15 +16,15 @@ class FtParticipantAcceptTest < Test::Unit::TestCase
|
|
16
16
|
class MyParticipant
|
17
17
|
include Ruote::LocalParticipant
|
18
18
|
|
19
|
-
def initialize
|
19
|
+
def initialize(opts)
|
20
20
|
@opts = opts
|
21
21
|
end
|
22
22
|
|
23
|
-
def accept?
|
23
|
+
def accept?(workitem)
|
24
24
|
workitem.participant_name.match(@opts['filter'] || '.?')
|
25
25
|
end
|
26
26
|
|
27
|
-
def consume
|
27
|
+
def consume(workitem)
|
28
28
|
@context.tracer << 'filtered:'
|
29
29
|
@context.tracer << workitem.participant_name
|
30
30
|
@context.tracer << "\n"
|
@@ -35,7 +35,7 @@ class FtParticipantAcceptTest < Test::Unit::TestCase
|
|
35
35
|
class MyOtherParticipant
|
36
36
|
include Ruote::LocalParticipant
|
37
37
|
|
38
|
-
def consume
|
38
|
+
def consume(workitem)
|
39
39
|
@context.tracer << workitem.participant_name
|
40
40
|
@context.tracer << "\n"
|
41
41
|
reply(workitem)
|
@@ -28,22 +28,56 @@ class FtLaunchSingleTest < Test::Unit::TestCase
|
|
28
28
|
echo 'over.'
|
29
29
|
end
|
30
30
|
|
31
|
+
#noisy
|
32
|
+
|
31
33
|
wfid = @engine.launch_single(pdef)
|
32
34
|
|
33
35
|
assert_equal(
|
34
36
|
wfid,
|
35
37
|
@engine.storage.get('variables', 'singles')['h']['unique_process'].first)
|
36
38
|
|
37
|
-
|
39
|
+
@engine.wait_for(2)
|
38
40
|
|
39
41
|
assert_not_nil @engine.process(wfid)
|
40
42
|
|
41
43
|
wfid1 = @engine.launch_single(pdef)
|
42
44
|
|
43
|
-
sleep
|
45
|
+
sleep 1
|
44
46
|
|
45
47
|
assert_equal wfid, wfid1
|
46
48
|
assert_equal 1, @engine.processes.size
|
47
49
|
end
|
50
|
+
|
51
|
+
# Fighting the issue reported by Gonzalo in
|
52
|
+
# http://groups.google.com/group/openwferu-users/browse_thread/thread/fa9c8b414f355f79
|
53
|
+
#
|
54
|
+
def test_launch_single_cancel_launch_single
|
55
|
+
|
56
|
+
pdef = Ruote.process_definition 'unique_process' do
|
57
|
+
wait '2y'
|
58
|
+
echo 'over.'
|
59
|
+
end
|
60
|
+
|
61
|
+
#noisy
|
62
|
+
|
63
|
+
wfid0 = @engine.launch_single(pdef)
|
64
|
+
|
65
|
+
sleep 0.700
|
66
|
+
assert_not_nil @engine.process(wfid0)
|
67
|
+
|
68
|
+
@engine.cancel(wfid0)
|
69
|
+
|
70
|
+
@engine.wait_for(6)
|
71
|
+
assert_nil @engine.process(wfid0)
|
72
|
+
|
73
|
+
sleep 0.700
|
74
|
+
wfid1 = @engine.launch_single(pdef)
|
75
|
+
|
76
|
+
@engine.wait_for(2)
|
77
|
+
|
78
|
+
assert_not_equal wfid0, wfid1
|
79
|
+
assert_nil @engine.process(wfid0)
|
80
|
+
assert_not_nil @engine.process(wfid1)
|
81
|
+
end
|
48
82
|
end
|
49
83
|
|