ruote-maestrodev 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +290 -0
- data/CREDITS.txt +99 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +88 -0
- data/Rakefile +108 -0
- data/TODO.txt +488 -0
- data/lib/ruote.rb +7 -0
- data/lib/ruote/context.rb +194 -0
- data/lib/ruote/engine.rb +1062 -0
- data/lib/ruote/engine/process_error.rb +122 -0
- data/lib/ruote/engine/process_status.rb +448 -0
- data/lib/ruote/exp/command.rb +87 -0
- data/lib/ruote/exp/commanded.rb +69 -0
- data/lib/ruote/exp/condition.rb +227 -0
- data/lib/ruote/exp/fe_add_branches.rb +138 -0
- data/lib/ruote/exp/fe_apply.rb +154 -0
- data/lib/ruote/exp/fe_cancel_process.rb +78 -0
- data/lib/ruote/exp/fe_command.rb +156 -0
- data/lib/ruote/exp/fe_concurrence.rb +321 -0
- data/lib/ruote/exp/fe_concurrent_iterator.rb +219 -0
- data/lib/ruote/exp/fe_cron.rb +141 -0
- data/lib/ruote/exp/fe_cursor.rb +324 -0
- data/lib/ruote/exp/fe_define.rb +112 -0
- data/lib/ruote/exp/fe_echo.rb +60 -0
- data/lib/ruote/exp/fe_equals.rb +115 -0
- data/lib/ruote/exp/fe_error.rb +82 -0
- data/lib/ruote/exp/fe_filter.rb +648 -0
- data/lib/ruote/exp/fe_forget.rb +88 -0
- data/lib/ruote/exp/fe_given.rb +154 -0
- data/lib/ruote/exp/fe_if.rb +127 -0
- data/lib/ruote/exp/fe_inc.rb +205 -0
- data/lib/ruote/exp/fe_iterator.rb +234 -0
- data/lib/ruote/exp/fe_let.rb +75 -0
- data/lib/ruote/exp/fe_listen.rb +304 -0
- data/lib/ruote/exp/fe_lose.rb +110 -0
- data/lib/ruote/exp/fe_noop.rb +45 -0
- data/lib/ruote/exp/fe_once.rb +215 -0
- data/lib/ruote/exp/fe_participant.rb +287 -0
- data/lib/ruote/exp/fe_read.rb +69 -0
- data/lib/ruote/exp/fe_redo.rb +82 -0
- data/lib/ruote/exp/fe_ref.rb +152 -0
- data/lib/ruote/exp/fe_registerp.rb +110 -0
- data/lib/ruote/exp/fe_reserve.rb +126 -0
- data/lib/ruote/exp/fe_restore.rb +102 -0
- data/lib/ruote/exp/fe_save.rb +72 -0
- data/lib/ruote/exp/fe_sequence.rb +59 -0
- data/lib/ruote/exp/fe_set.rb +154 -0
- data/lib/ruote/exp/fe_subprocess.rb +211 -0
- data/lib/ruote/exp/fe_that.rb +92 -0
- data/lib/ruote/exp/fe_undo.rb +67 -0
- data/lib/ruote/exp/fe_unregisterp.rb +69 -0
- data/lib/ruote/exp/fe_wait.rb +95 -0
- data/lib/ruote/exp/flowexpression.rb +886 -0
- data/lib/ruote/exp/iterator.rb +81 -0
- data/lib/ruote/exp/merge.rb +118 -0
- data/lib/ruote/exp/ro_attributes.rb +212 -0
- data/lib/ruote/exp/ro_filters.rb +136 -0
- data/lib/ruote/exp/ro_persist.rb +154 -0
- data/lib/ruote/exp/ro_variables.rb +189 -0
- data/lib/ruote/exp/ro_vf.rb +68 -0
- data/lib/ruote/fei.rb +260 -0
- data/lib/ruote/id/mnemo_wfid_generator.rb +43 -0
- data/lib/ruote/id/wfid_generator.rb +81 -0
- data/lib/ruote/log/default_history.rb +122 -0
- data/lib/ruote/log/pretty.rb +176 -0
- data/lib/ruote/log/storage_history.rb +159 -0
- data/lib/ruote/log/test_logger.rb +208 -0
- data/lib/ruote/log/wait_logger.rb +64 -0
- data/lib/ruote/part/block_participant.rb +137 -0
- data/lib/ruote/part/code_participant.rb +81 -0
- data/lib/ruote/part/engine_participant.rb +189 -0
- data/lib/ruote/part/local_participant.rb +138 -0
- data/lib/ruote/part/no_op_participant.rb +60 -0
- data/lib/ruote/part/null_participant.rb +54 -0
- data/lib/ruote/part/rev_participant.rb +169 -0
- data/lib/ruote/part/smtp_participant.rb +116 -0
- data/lib/ruote/part/storage_participant.rb +392 -0
- data/lib/ruote/part/template.rb +84 -0
- data/lib/ruote/participant.rb +7 -0
- data/lib/ruote/reader.rb +278 -0
- data/lib/ruote/reader/json.rb +49 -0
- data/lib/ruote/reader/radial.rb +290 -0
- data/lib/ruote/reader/ruby_dsl.rb +186 -0
- data/lib/ruote/reader/xml.rb +99 -0
- data/lib/ruote/receiver/base.rb +212 -0
- data/lib/ruote/storage/base.rb +364 -0
- data/lib/ruote/storage/composite_storage.rb +121 -0
- data/lib/ruote/storage/fs_storage.rb +139 -0
- data/lib/ruote/storage/hash_storage.rb +211 -0
- data/lib/ruote/svc/dispatch_pool.rb +158 -0
- data/lib/ruote/svc/dollar_sub.rb +298 -0
- data/lib/ruote/svc/error_handler.rb +138 -0
- data/lib/ruote/svc/expression_map.rb +97 -0
- data/lib/ruote/svc/participant_list.rb +397 -0
- data/lib/ruote/svc/tracker.rb +172 -0
- data/lib/ruote/svc/treechecker.rb +141 -0
- data/lib/ruote/tree_dot.rb +85 -0
- data/lib/ruote/util/filter.rb +525 -0
- data/lib/ruote/util/hashdot.rb +79 -0
- data/lib/ruote/util/look.rb +128 -0
- data/lib/ruote/util/lookup.rb +127 -0
- data/lib/ruote/util/misc.rb +167 -0
- data/lib/ruote/util/ometa.rb +71 -0
- data/lib/ruote/util/serializer.rb +103 -0
- data/lib/ruote/util/subprocess.rb +88 -0
- data/lib/ruote/util/time.rb +100 -0
- data/lib/ruote/util/tree.rb +58 -0
- data/lib/ruote/version.rb +29 -0
- data/lib/ruote/worker.rb +386 -0
- data/lib/ruote/workitem.rb +394 -0
- data/phil.txt +14 -0
- data/ruote.gemspec +44 -0
- data/test/bm/ci.rb +55 -0
- data/test/bm/ici.rb +71 -0
- data/test/bm/juuman.rb +54 -0
- data/test/bm/launch_bench.rb +37 -0
- data/test/bm/load_26c.rb +97 -0
- data/test/bm/mega.rb +64 -0
- data/test/bm/seq_thousand.rb +31 -0
- data/test/bm/t.rb +35 -0
- data/test/functional/base.rb +247 -0
- data/test/functional/concurrent_base.rb +98 -0
- data/test/functional/crunner.rb +31 -0
- data/test/functional/ct_0_concurrence.rb +65 -0
- data/test/functional/ct_1_iterator.rb +67 -0
- data/test/functional/ct_2_cancel.rb +81 -0
- data/test/functional/eft_0_process_definition.rb +65 -0
- data/test/functional/eft_10_cancel_process.rb +46 -0
- data/test/functional/eft_11_wait.rb +109 -0
- data/test/functional/eft_12_listen.rb +500 -0
- data/test/functional/eft_13_iterator.rb +342 -0
- data/test/functional/eft_14_cursor.rb +456 -0
- data/test/functional/eft_15_loop.rb +69 -0
- data/test/functional/eft_16_if.rb +183 -0
- data/test/functional/eft_17_equals.rb +55 -0
- data/test/functional/eft_18_concurrent_iterator.rb +410 -0
- data/test/functional/eft_19_reserve.rb +136 -0
- data/test/functional/eft_1_echo.rb +68 -0
- data/test/functional/eft_20_save.rb +116 -0
- data/test/functional/eft_21_restore.rb +61 -0
- data/test/functional/eft_22_noop.rb +28 -0
- data/test/functional/eft_23_apply.rb +168 -0
- data/test/functional/eft_24_add_branches.rb +98 -0
- data/test/functional/eft_25_command.rb +28 -0
- data/test/functional/eft_26_error.rb +77 -0
- data/test/functional/eft_27_inc.rb +280 -0
- data/test/functional/eft_28_once.rb +135 -0
- data/test/functional/eft_29_cron.rb +64 -0
- data/test/functional/eft_2_sequence.rb +58 -0
- data/test/functional/eft_30_ref.rb +155 -0
- 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 +375 -0
- data/test/functional/eft_36_read.rb +95 -0
- data/test/functional/eft_3_participant.rb +149 -0
- data/test/functional/eft_4_set.rb +296 -0
- data/test/functional/eft_5_subprocess.rb +163 -0
- data/test/functional/eft_6_concurrence.rb +304 -0
- data/test/functional/eft_7_forget.rb +61 -0
- data/test/functional/eft_8_undo.rb +114 -0
- data/test/functional/eft_9_redo.rb +138 -0
- data/test/functional/ft_0_worker.rb +65 -0
- data/test/functional/ft_10_dollar.rb +304 -0
- data/test/functional/ft_11_recursion.rb +109 -0
- data/test/functional/ft_12_launchitem.rb +43 -0
- data/test/functional/ft_13_variables.rb +151 -0
- data/test/functional/ft_14_re_apply.rb +324 -0
- data/test/functional/ft_15_timeout.rb +226 -0
- data/test/functional/ft_16_participant_params.rb +98 -0
- data/test/functional/ft_17_conditional.rb +102 -0
- data/test/functional/ft_18_kill.rb +138 -0
- data/test/functional/ft_19_participant_code.rb +67 -0
- data/test/functional/ft_1_process_status.rb +796 -0
- data/test/functional/ft_20_storage_participant.rb +543 -0
- data/test/functional/ft_21_forget.rb +153 -0
- data/test/functional/ft_22_process_definitions.rb +90 -0
- data/test/functional/ft_23_load_defs.rb +79 -0
- data/test/functional/ft_24_block_participant.rb +235 -0
- data/test/functional/ft_25_receiver.rb +207 -0
- data/test/functional/ft_26_participant_rtimeout.rb +179 -0
- data/test/functional/ft_27_var_indirection.rb +128 -0
- data/test/functional/ft_28_null_noop_participants.rb +51 -0
- data/test/functional/ft_29_part_template.rb +60 -0
- data/test/functional/ft_2_errors.rb +380 -0
- data/test/functional/ft_30_smtp_participant.rb +122 -0
- data/test/functional/ft_31_part_blocking.rb +72 -0
- data/test/functional/ft_33_participant_subprocess_priority.rb +32 -0
- data/test/functional/ft_34_cursor_rewind.rb +101 -0
- data/test/functional/ft_35_add_service.rb +56 -0
- data/test/functional/ft_36_storage_history.rb +150 -0
- data/test/functional/ft_37_default_history.rb +109 -0
- data/test/functional/ft_38_participant_more.rb +193 -0
- data/test/functional/ft_39_wait_for.rb +136 -0
- data/test/functional/ft_3_participant_registration.rb +574 -0
- data/test/functional/ft_40_wait_logger.rb +62 -0
- data/test/functional/ft_41_participants.rb +91 -0
- data/test/functional/ft_42_storage_copy.rb +71 -0
- data/test/functional/ft_43_participant_on_reply.rb +87 -0
- data/test/functional/ft_44_var_participant.rb +35 -0
- data/test/functional/ft_45_participant_accept.rb +64 -0
- data/test/functional/ft_46_launch_single.rb +83 -0
- 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 +132 -0
- 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_55_engine_participant.rb +303 -0
- data/test/functional/ft_56_filter_attribute.rb +259 -0
- data/test/functional/ft_57_rev_participant.rb +252 -0
- data/test/functional/ft_58_workitem.rb +69 -0
- data/test/functional/ft_59_pause.rb +343 -0
- data/test/functional/ft_5_on_error.rb +384 -0
- data/test/functional/ft_60_code_participant.rb +45 -0
- data/test/functional/ft_61_trailing_fields.rb +34 -0
- data/test/functional/ft_62_exp_name_and_dollar_substitution.rb +35 -0
- data/test/functional/ft_6_on_cancel.rb +221 -0
- data/test/functional/ft_7_tags.rb +177 -0
- data/test/functional/ft_8_participant_consumption.rb +124 -0
- data/test/functional/ft_9_subprocesses.rb +146 -0
- data/test/functional/restart_base.rb +34 -0
- data/test/functional/rt_0_wait.rb +55 -0
- data/test/functional/rt_1_listen.rb +56 -0
- data/test/functional/rt_2_errors.rb +56 -0
- data/test/functional/rt_3_once.rb +70 -0
- data/test/functional/rt_4_cron.rb +64 -0
- data/test/functional/rt_5_timeout.rb +60 -0
- data/test/functional/rtest.rb +8 -0
- data/test/functional/storage_helper.rb +93 -0
- data/test/functional/test.rb +44 -0
- data/test/functional/vertical.rb +46 -0
- data/test/path_helper.rb +15 -0
- data/test/test.rb +13 -0
- data/test/test_helper.rb +28 -0
- data/test/unit/storage.rb +428 -0
- data/test/unit/storages.rb +37 -0
- data/test/unit/test.rb +28 -0
- data/test/unit/ut_0_ruby_reader.rb +223 -0
- data/test/unit/ut_11_lookup.rb +122 -0
- data/test/unit/ut_13_serializer.rb +65 -0
- data/test/unit/ut_14_is_uri.rb +28 -0
- data/test/unit/ut_15_util.rb +57 -0
- data/test/unit/ut_16_reader.rb +225 -0
- data/test/unit/ut_18_engine.rb +47 -0
- data/test/unit/ut_19_part_template.rb +86 -0
- data/test/unit/ut_1_fei.rb +165 -0
- data/test/unit/ut_20_composite_storage.rb +74 -0
- data/test/unit/ut_21_svc_participant_list.rb +46 -0
- data/test/unit/ut_22_filter.rb +1094 -0
- data/test/unit/ut_23_svc_tracker.rb +48 -0
- data/test/unit/ut_24_radial_reader.rb +332 -0
- data/test/unit/ut_25_merge.rb +113 -0
- data/test/unit/ut_3_wait_logger.rb +39 -0
- data/test/unit/ut_4_expmap.rb +20 -0
- data/test/unit/ut_5_tree.rb +54 -0
- data/test/unit/ut_6_condition.rb +303 -0
- data/test/unit/ut_7_workitem.rb +99 -0
- data/test/unit/ut_8_tree_to_dot.rb +72 -0
- data/test/unit/ut_9_xml_reader.rb +61 -0
- metadata +504 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Mon Jul 27 09:17:51 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
require 'ruote/participant'
|
11
|
+
|
12
|
+
|
13
|
+
class FtForgetTest < Test::Unit::TestCase
|
14
|
+
include FunctionalBase
|
15
|
+
|
16
|
+
def test_basic
|
17
|
+
|
18
|
+
pdef = Ruote.process_definition do
|
19
|
+
sequence do
|
20
|
+
alpha :forget => true
|
21
|
+
alpha
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
@engine.register_participant :alpha do
|
26
|
+
@tracer << "alpha\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
#noisy
|
30
|
+
|
31
|
+
wfid = @engine.launch(pdef)
|
32
|
+
|
33
|
+
wait_for(wfid)
|
34
|
+
wait_for(wfid)
|
35
|
+
|
36
|
+
assert_equal %w[ alpha alpha ].join("\n"), @tracer.to_s
|
37
|
+
|
38
|
+
#logger.log.each { |e| p e }
|
39
|
+
|
40
|
+
assert_equal 1, logger.log.select { |e| e['action'] == 'ceased' }.size
|
41
|
+
assert_equal 1, logger.log.select { |e| e['action'] == 'terminated' }.size
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_forgotten_tree
|
45
|
+
|
46
|
+
sp = @engine.register_participant :alpha, Ruote::StorageParticipant
|
47
|
+
|
48
|
+
pdef = Ruote.process_definition do
|
49
|
+
sequence do
|
50
|
+
alpha :forget => true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
wfid = @engine.launch(pdef)
|
55
|
+
|
56
|
+
wait_for(wfid)
|
57
|
+
|
58
|
+
ps = @engine.process(wfid)
|
59
|
+
|
60
|
+
assert_not_nil ps
|
61
|
+
assert_equal 0, ps.errors.size
|
62
|
+
assert_equal 1, ps.expressions.size
|
63
|
+
|
64
|
+
fei = ps.expressions.first.fei
|
65
|
+
assert_equal fei, ps.root_expression_for(fei).fei
|
66
|
+
|
67
|
+
#puts "not sure..."
|
68
|
+
#p ps.original_tree
|
69
|
+
#p ps.current_tree
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_forget_true_string
|
73
|
+
|
74
|
+
pdef = Ruote.process_definition do
|
75
|
+
concurrence :count => 1 do
|
76
|
+
alpha :forget => 'true'
|
77
|
+
bravo
|
78
|
+
end
|
79
|
+
charly
|
80
|
+
end
|
81
|
+
|
82
|
+
@engine.register_participant '.+' do |wi|
|
83
|
+
@tracer << wi.participant_name + "\n"
|
84
|
+
end
|
85
|
+
|
86
|
+
wfid = @engine.launch(pdef)
|
87
|
+
|
88
|
+
wait_for(wfid)
|
89
|
+
wait_for(wfid)
|
90
|
+
|
91
|
+
#assert_equal "alpha\nbravo\ncharly", @tracer.to_s
|
92
|
+
assert_equal %w[ alpha bravo charly ], @tracer.to_a.sort
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_forget_and_cursor
|
96
|
+
|
97
|
+
pdef = Ruote.define do
|
98
|
+
cursor do
|
99
|
+
alpha :forget => true
|
100
|
+
bravo
|
101
|
+
rewind
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
@engine.register_participant 'alpha', Ruote::NullParticipant
|
106
|
+
# this participant never replies
|
107
|
+
|
108
|
+
@engine.register_participant 'bravo', Ruote::NoOpParticipant
|
109
|
+
# this one simply replies
|
110
|
+
|
111
|
+
#@engine.noisy = true
|
112
|
+
|
113
|
+
wfid = @engine.launch(pdef)
|
114
|
+
|
115
|
+
@engine.wait_for(:bravo)
|
116
|
+
@engine.wait_for(:bravo)
|
117
|
+
|
118
|
+
assert_not_nil @engine.process(wfid)
|
119
|
+
end
|
120
|
+
|
121
|
+
# As reported by Nando Sola
|
122
|
+
#
|
123
|
+
# http://groups.google.com/group/openwferu-users/browse_thread/thread/50308e9dce8359e6
|
124
|
+
#
|
125
|
+
def test_forget_on_forget
|
126
|
+
|
127
|
+
pdef = Ruote.define do
|
128
|
+
concurrence do
|
129
|
+
listen :to => 'bravo', :upon =>'reply', :wfid => true do
|
130
|
+
sequence :forget => true do
|
131
|
+
alpha
|
132
|
+
end
|
133
|
+
end
|
134
|
+
bravo
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
@engine.register do
|
139
|
+
catchall Ruote::NoOpParticipant
|
140
|
+
end
|
141
|
+
|
142
|
+
#noisy
|
143
|
+
|
144
|
+
wfid = @engine.launch(pdef)
|
145
|
+
|
146
|
+
@engine.wait_for(wfid)
|
147
|
+
|
148
|
+
assert_equal(
|
149
|
+
[],
|
150
|
+
@engine.history.all.select { |e| e['action'] == 'error_intercepted' })
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
@@ -0,0 +1,90 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Fri Jul 31 10:21:51 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'socket' # just for SocketError
|
9
|
+
|
10
|
+
require File.join(File.dirname(__FILE__), 'base')
|
11
|
+
|
12
|
+
|
13
|
+
class FtProcessDefinitionTest < Test::Unit::TestCase
|
14
|
+
include FunctionalBase
|
15
|
+
|
16
|
+
def test_sequence
|
17
|
+
|
18
|
+
pdef = %{
|
19
|
+
<process-definition name="test">
|
20
|
+
<sequence>
|
21
|
+
<echo>a</echo>
|
22
|
+
<echo>b</echo>
|
23
|
+
</sequence>
|
24
|
+
</process-definition>
|
25
|
+
}
|
26
|
+
|
27
|
+
#noisy
|
28
|
+
|
29
|
+
assert_trace(%w[ a b ], pdef)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_remote_definitions_not_allowed
|
33
|
+
|
34
|
+
assert_raise ArgumentError do
|
35
|
+
@engine.launch('http://defs.example.com/def0.rb')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_remote_definitions_allowed
|
40
|
+
|
41
|
+
@engine.context['remote_definition_allowed'] = true
|
42
|
+
|
43
|
+
e = assert_raise SocketError, OpenURI::HTTPError, ArgumentError do
|
44
|
+
@engine.launch('http://defs.example.com/def0.rb')
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_not_equal 'remote process definitions are not allowed', e.message
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_json_definition
|
51
|
+
|
52
|
+
prev = Rufus::Json.backend
|
53
|
+
|
54
|
+
require 'json' # warning, json 1.4.3 is buggy...
|
55
|
+
#require 'json/pure'
|
56
|
+
Rufus::Json.backend = :json
|
57
|
+
|
58
|
+
#pdef = Ruote.process_definition :name => 'test' do
|
59
|
+
# sequence do
|
60
|
+
# echo 'a'
|
61
|
+
# echo 'b'
|
62
|
+
# end
|
63
|
+
#end
|
64
|
+
#p pdef.to_json
|
65
|
+
|
66
|
+
assert_trace(
|
67
|
+
%w[ a b ],
|
68
|
+
"[\"define\",{\"name\":\"test\"},[[\"sequence\",{},[[\"echo\",{\"a\":null},[]],[\"echo\",{\"b\":null},[]]]]]]")
|
69
|
+
|
70
|
+
Rufus::Json.backend = prev
|
71
|
+
# back to initial state
|
72
|
+
rescue => e
|
73
|
+
p e
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_local_definition
|
77
|
+
|
78
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'pdef.xml'))
|
79
|
+
|
80
|
+
assert_trace(%w[ a b ], path)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_local_unexpanded_definition
|
84
|
+
|
85
|
+
path = File.join(File.dirname(__FILE__), '..', 'pdef.xml')
|
86
|
+
|
87
|
+
assert_trace(%w[ a b ], path)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Wed Aug 5 08:35:38 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtLoadDefsTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_load_definition
|
15
|
+
|
16
|
+
pdef = %{
|
17
|
+
Ruote.process_definition :name => 'test' do
|
18
|
+
sequence do
|
19
|
+
echo 'a'
|
20
|
+
echo 'b'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
path = File.join('work', 'tmp')
|
26
|
+
fn = File.join(path, 'pdef.rb')
|
27
|
+
|
28
|
+
FileUtils.mkdir_p(path)
|
29
|
+
File.open(fn, 'w') { |f| f.write(pdef) }
|
30
|
+
|
31
|
+
assert_equal(
|
32
|
+
[ 'define', { 'name' => 'test' }, [
|
33
|
+
['sequence', {}, [
|
34
|
+
['echo', { 'a' => nil }, [] ],
|
35
|
+
['echo', { 'b' => nil}, [] ] ] ] ] ],
|
36
|
+
@engine.load_definition(fn))
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_load_definition_with_absolute_path
|
40
|
+
|
41
|
+
pdef = %{
|
42
|
+
Ruote.process_definition do
|
43
|
+
echo 'a'
|
44
|
+
end
|
45
|
+
}
|
46
|
+
|
47
|
+
path = File.join('work', 'tmp')
|
48
|
+
fn = File.join(path, 'pdef.rb')
|
49
|
+
|
50
|
+
FileUtils.mkdir_p(path)
|
51
|
+
File.open(fn, 'w') { |f| f.write(pdef) }
|
52
|
+
|
53
|
+
fn = File.expand_path(fn)
|
54
|
+
|
55
|
+
assert_equal(
|
56
|
+
[ 'define', {}, [ [ 'echo', { 'a' => nil }, [] ] ] ],
|
57
|
+
@engine.load_definition(fn))
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_load_illegal_definition
|
61
|
+
|
62
|
+
pdef = %{
|
63
|
+
Ruote.process_definition :name => 'test' do
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
}
|
67
|
+
|
68
|
+
path = File.join('work', 'tmp')
|
69
|
+
fn = File.join(path, 'pdef.rb')
|
70
|
+
|
71
|
+
FileUtils.mkdir_p(path)
|
72
|
+
File.open(fn, 'w') { |f| f.write(pdef) }
|
73
|
+
|
74
|
+
assert_raise Ruote::Reader::Error do
|
75
|
+
@engine.load_definition(fn)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,235 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote
|
4
|
+
#
|
5
|
+
# Tue Aug 11 13:56:28 JST 2009
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtBlockParticipantTest < Test::Unit::TestCase
|
12
|
+
include FunctionalBase
|
13
|
+
|
14
|
+
def test_workitems_dispatching_message
|
15
|
+
|
16
|
+
pdef = Ruote.process_definition do
|
17
|
+
sequence do
|
18
|
+
set :var => 'v0', :val => 'v0val'
|
19
|
+
set :field => 'f0', :val => 'f0val'
|
20
|
+
alpha
|
21
|
+
bravo
|
22
|
+
charly
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
@engine.register_participant :alpha do
|
27
|
+
@tracer << "a\n"
|
28
|
+
end
|
29
|
+
@engine.register_participant :bravo do |workitem|
|
30
|
+
@tracer << "b:f0:#{workitem.fields['f0']}\n"
|
31
|
+
end
|
32
|
+
@engine.register_participant :charly do |workitem, fexp|
|
33
|
+
@tracer << "c:f0:#{workitem.fields['f0']}:#{fexp.lookup_variable('v0')}\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
#noisy
|
37
|
+
|
38
|
+
assert_trace "a\nb:f0:f0val\nc:f0:f0val:v0val", pdef
|
39
|
+
end
|
40
|
+
|
41
|
+
TEST_BLOCK = Ruote.process_definition do
|
42
|
+
sequence do
|
43
|
+
alpha
|
44
|
+
echo '${f:__result__}'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_block_result
|
49
|
+
|
50
|
+
return if Ruote::WIN or Ruote::JAVA
|
51
|
+
# defective 'json' lib on windows render this test useless
|
52
|
+
|
53
|
+
@engine.register_participant :alpha do |workitem|
|
54
|
+
'seen'
|
55
|
+
end
|
56
|
+
|
57
|
+
#noisy
|
58
|
+
|
59
|
+
assert_trace 'seen', TEST_BLOCK
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_non_jsonfiable_result
|
63
|
+
|
64
|
+
return if Ruote::WIN
|
65
|
+
# defective 'json' lib on windows renders this test useless
|
66
|
+
|
67
|
+
@engine.register_participant :alpha do |workitem|
|
68
|
+
Time.now
|
69
|
+
end
|
70
|
+
|
71
|
+
#noisy
|
72
|
+
|
73
|
+
match = if defined?(DataMapper) && DataMapper::VERSION < '1.0.0'
|
74
|
+
/^$/
|
75
|
+
else
|
76
|
+
/\b#{Time.now.year}\b/
|
77
|
+
end
|
78
|
+
|
79
|
+
wfid = @engine.launch(TEST_BLOCK)
|
80
|
+
|
81
|
+
@engine.wait_for(wfid)
|
82
|
+
|
83
|
+
assert_match match, @tracer.to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_raise_security_error_before_evaluating_rogue_code
|
87
|
+
|
88
|
+
fn = "test/bad.#{Time.now.to_f}.txt"
|
89
|
+
|
90
|
+
@engine.participant_list = [
|
91
|
+
#[ 'alpha', [ 'Ruote::BlockParticipant', { 'block' => 'exit(3)' } ] ]
|
92
|
+
[ 'alpha', [ 'Ruote::BlockParticipant', { 'block' => "proc { File.open(\"#{fn}\", \"wb\") { |f| f.puts(\"bad\") } }" } ] ]
|
93
|
+
]
|
94
|
+
|
95
|
+
#noisy
|
96
|
+
|
97
|
+
wfid = @engine.launch(Ruote.define { alpha })
|
98
|
+
|
99
|
+
@engine.wait_for(wfid)
|
100
|
+
|
101
|
+
assert_equal false, File.exist?(fn), 'security check not enforced'
|
102
|
+
|
103
|
+
assert_equal 1, @engine.errors(wfid).size
|
104
|
+
assert_match /SecurityError/, @engine.errors(wfid).first.message
|
105
|
+
|
106
|
+
FileUtils.rm(fn) rescue nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_raise_security_error_upon_registering_rogue_block_participant
|
110
|
+
|
111
|
+
assert_raise Rufus::SecurityError do
|
112
|
+
|
113
|
+
@engine.register 'rogue' do |workitem|
|
114
|
+
workitem.content = File.read('test/nada.txt')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_on_cancel_registration
|
120
|
+
|
121
|
+
@engine.register 'nemo',
|
122
|
+
:on_workitem => lambda { |wi|
|
123
|
+
p wi
|
124
|
+
},
|
125
|
+
:on_cancel => lambda { |fei, flavour|
|
126
|
+
p fei, flavour
|
127
|
+
}
|
128
|
+
|
129
|
+
assert_equal(
|
130
|
+
{ 'on_cancel' => "proc { |fei, flavour|\n p fei, flavour\n }",
|
131
|
+
'on_workitem' => "proc { |wi|\n p wi\n }" },
|
132
|
+
@engine.participant_list.first.options)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_on_cancel
|
136
|
+
|
137
|
+
@engine.register 'sleeper',
|
138
|
+
:on_workitem => lambda { |workitem|
|
139
|
+
context.tracer << "consumed\n"
|
140
|
+
sleep 60 # preventing the implicit reply_to_engine(workitem)
|
141
|
+
},
|
142
|
+
:on_cancel => lambda { |fei, flavour|
|
143
|
+
context.tracer << "cancelled\n"
|
144
|
+
}
|
145
|
+
|
146
|
+
pdef = Ruote.define do
|
147
|
+
sleeper
|
148
|
+
end
|
149
|
+
|
150
|
+
#@engine.noisy = true
|
151
|
+
|
152
|
+
wfid = @engine.launch(pdef)
|
153
|
+
|
154
|
+
@engine.wait_for(:sleeper)
|
155
|
+
sleep 0.350
|
156
|
+
|
157
|
+
assert_equal 'consumed', @tracer.to_s
|
158
|
+
|
159
|
+
@engine.cancel(wfid)
|
160
|
+
|
161
|
+
@engine.wait_for(wfid)
|
162
|
+
|
163
|
+
assert_equal "consumed\ncancelled", @tracer.to_s
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_on_reply
|
167
|
+
|
168
|
+
@engine.register 'consumer',
|
169
|
+
:on_workitem => lambda { |workitem|
|
170
|
+
context.tracer << "consumed\n"
|
171
|
+
},
|
172
|
+
:on_reply => lambda { |workitem|
|
173
|
+
context.tracer << "replied\n"
|
174
|
+
}
|
175
|
+
|
176
|
+
pdef = Ruote.define do
|
177
|
+
consumer
|
178
|
+
end
|
179
|
+
|
180
|
+
#@engine.noisy = true
|
181
|
+
|
182
|
+
wfid = @engine.launch(pdef)
|
183
|
+
@engine.wait_for(wfid)
|
184
|
+
|
185
|
+
assert_equal "consumed\nreplied", @tracer.to_s
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_accept
|
189
|
+
|
190
|
+
@engine.register 'consumer',
|
191
|
+
:on_workitem => lambda { |workitem|
|
192
|
+
raise 'fail miserably'
|
193
|
+
},
|
194
|
+
:accept? => lambda { |workitem|
|
195
|
+
false
|
196
|
+
}
|
197
|
+
|
198
|
+
pdef = Ruote.define do
|
199
|
+
consumer
|
200
|
+
end
|
201
|
+
|
202
|
+
#@engine.noisy = true
|
203
|
+
|
204
|
+
wfid = @engine.launch(pdef)
|
205
|
+
@engine.wait_for(wfid)
|
206
|
+
|
207
|
+
assert_match /unknown participant/, @engine.ps(wfid).errors.first.message
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_do_not_thread
|
211
|
+
|
212
|
+
@engine.register 'consumer',
|
213
|
+
:on_workitem => lambda { |workitem|
|
214
|
+
context.tracer << "in\n"
|
215
|
+
},
|
216
|
+
:do_not_thread => lambda { |workitem|
|
217
|
+
context.tracer << "dnt\n"
|
218
|
+
false
|
219
|
+
}
|
220
|
+
|
221
|
+
pdef = Ruote.define do
|
222
|
+
consumer
|
223
|
+
end
|
224
|
+
|
225
|
+
#@engine.noisy = true
|
226
|
+
|
227
|
+
wfid = @engine.launch(pdef)
|
228
|
+
@engine.wait_for(:consumer)
|
229
|
+
|
230
|
+
sleep 0.350
|
231
|
+
|
232
|
+
assert_equal "dnt\nin", @tracer.to_s
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|