ruote-maestrodev 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. data/CHANGELOG.txt +290 -0
  2. data/CREDITS.txt +99 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.rdoc +88 -0
  5. data/Rakefile +108 -0
  6. data/TODO.txt +488 -0
  7. data/lib/ruote.rb +7 -0
  8. data/lib/ruote/context.rb +194 -0
  9. data/lib/ruote/engine.rb +1062 -0
  10. data/lib/ruote/engine/process_error.rb +122 -0
  11. data/lib/ruote/engine/process_status.rb +448 -0
  12. data/lib/ruote/exp/command.rb +87 -0
  13. data/lib/ruote/exp/commanded.rb +69 -0
  14. data/lib/ruote/exp/condition.rb +227 -0
  15. data/lib/ruote/exp/fe_add_branches.rb +138 -0
  16. data/lib/ruote/exp/fe_apply.rb +154 -0
  17. data/lib/ruote/exp/fe_cancel_process.rb +78 -0
  18. data/lib/ruote/exp/fe_command.rb +156 -0
  19. data/lib/ruote/exp/fe_concurrence.rb +321 -0
  20. data/lib/ruote/exp/fe_concurrent_iterator.rb +219 -0
  21. data/lib/ruote/exp/fe_cron.rb +141 -0
  22. data/lib/ruote/exp/fe_cursor.rb +324 -0
  23. data/lib/ruote/exp/fe_define.rb +112 -0
  24. data/lib/ruote/exp/fe_echo.rb +60 -0
  25. data/lib/ruote/exp/fe_equals.rb +115 -0
  26. data/lib/ruote/exp/fe_error.rb +82 -0
  27. data/lib/ruote/exp/fe_filter.rb +648 -0
  28. data/lib/ruote/exp/fe_forget.rb +88 -0
  29. data/lib/ruote/exp/fe_given.rb +154 -0
  30. data/lib/ruote/exp/fe_if.rb +127 -0
  31. data/lib/ruote/exp/fe_inc.rb +205 -0
  32. data/lib/ruote/exp/fe_iterator.rb +234 -0
  33. data/lib/ruote/exp/fe_let.rb +75 -0
  34. data/lib/ruote/exp/fe_listen.rb +304 -0
  35. data/lib/ruote/exp/fe_lose.rb +110 -0
  36. data/lib/ruote/exp/fe_noop.rb +45 -0
  37. data/lib/ruote/exp/fe_once.rb +215 -0
  38. data/lib/ruote/exp/fe_participant.rb +287 -0
  39. data/lib/ruote/exp/fe_read.rb +69 -0
  40. data/lib/ruote/exp/fe_redo.rb +82 -0
  41. data/lib/ruote/exp/fe_ref.rb +152 -0
  42. data/lib/ruote/exp/fe_registerp.rb +110 -0
  43. data/lib/ruote/exp/fe_reserve.rb +126 -0
  44. data/lib/ruote/exp/fe_restore.rb +102 -0
  45. data/lib/ruote/exp/fe_save.rb +72 -0
  46. data/lib/ruote/exp/fe_sequence.rb +59 -0
  47. data/lib/ruote/exp/fe_set.rb +154 -0
  48. data/lib/ruote/exp/fe_subprocess.rb +211 -0
  49. data/lib/ruote/exp/fe_that.rb +92 -0
  50. data/lib/ruote/exp/fe_undo.rb +67 -0
  51. data/lib/ruote/exp/fe_unregisterp.rb +69 -0
  52. data/lib/ruote/exp/fe_wait.rb +95 -0
  53. data/lib/ruote/exp/flowexpression.rb +886 -0
  54. data/lib/ruote/exp/iterator.rb +81 -0
  55. data/lib/ruote/exp/merge.rb +118 -0
  56. data/lib/ruote/exp/ro_attributes.rb +212 -0
  57. data/lib/ruote/exp/ro_filters.rb +136 -0
  58. data/lib/ruote/exp/ro_persist.rb +154 -0
  59. data/lib/ruote/exp/ro_variables.rb +189 -0
  60. data/lib/ruote/exp/ro_vf.rb +68 -0
  61. data/lib/ruote/fei.rb +260 -0
  62. data/lib/ruote/id/mnemo_wfid_generator.rb +43 -0
  63. data/lib/ruote/id/wfid_generator.rb +81 -0
  64. data/lib/ruote/log/default_history.rb +122 -0
  65. data/lib/ruote/log/pretty.rb +176 -0
  66. data/lib/ruote/log/storage_history.rb +159 -0
  67. data/lib/ruote/log/test_logger.rb +208 -0
  68. data/lib/ruote/log/wait_logger.rb +64 -0
  69. data/lib/ruote/part/block_participant.rb +137 -0
  70. data/lib/ruote/part/code_participant.rb +81 -0
  71. data/lib/ruote/part/engine_participant.rb +189 -0
  72. data/lib/ruote/part/local_participant.rb +138 -0
  73. data/lib/ruote/part/no_op_participant.rb +60 -0
  74. data/lib/ruote/part/null_participant.rb +54 -0
  75. data/lib/ruote/part/rev_participant.rb +169 -0
  76. data/lib/ruote/part/smtp_participant.rb +116 -0
  77. data/lib/ruote/part/storage_participant.rb +392 -0
  78. data/lib/ruote/part/template.rb +84 -0
  79. data/lib/ruote/participant.rb +7 -0
  80. data/lib/ruote/reader.rb +278 -0
  81. data/lib/ruote/reader/json.rb +49 -0
  82. data/lib/ruote/reader/radial.rb +290 -0
  83. data/lib/ruote/reader/ruby_dsl.rb +186 -0
  84. data/lib/ruote/reader/xml.rb +99 -0
  85. data/lib/ruote/receiver/base.rb +212 -0
  86. data/lib/ruote/storage/base.rb +364 -0
  87. data/lib/ruote/storage/composite_storage.rb +121 -0
  88. data/lib/ruote/storage/fs_storage.rb +139 -0
  89. data/lib/ruote/storage/hash_storage.rb +211 -0
  90. data/lib/ruote/svc/dispatch_pool.rb +158 -0
  91. data/lib/ruote/svc/dollar_sub.rb +298 -0
  92. data/lib/ruote/svc/error_handler.rb +138 -0
  93. data/lib/ruote/svc/expression_map.rb +97 -0
  94. data/lib/ruote/svc/participant_list.rb +397 -0
  95. data/lib/ruote/svc/tracker.rb +172 -0
  96. data/lib/ruote/svc/treechecker.rb +141 -0
  97. data/lib/ruote/tree_dot.rb +85 -0
  98. data/lib/ruote/util/filter.rb +525 -0
  99. data/lib/ruote/util/hashdot.rb +79 -0
  100. data/lib/ruote/util/look.rb +128 -0
  101. data/lib/ruote/util/lookup.rb +127 -0
  102. data/lib/ruote/util/misc.rb +167 -0
  103. data/lib/ruote/util/ometa.rb +71 -0
  104. data/lib/ruote/util/serializer.rb +103 -0
  105. data/lib/ruote/util/subprocess.rb +88 -0
  106. data/lib/ruote/util/time.rb +100 -0
  107. data/lib/ruote/util/tree.rb +58 -0
  108. data/lib/ruote/version.rb +29 -0
  109. data/lib/ruote/worker.rb +386 -0
  110. data/lib/ruote/workitem.rb +394 -0
  111. data/phil.txt +14 -0
  112. data/ruote.gemspec +44 -0
  113. data/test/bm/ci.rb +55 -0
  114. data/test/bm/ici.rb +71 -0
  115. data/test/bm/juuman.rb +54 -0
  116. data/test/bm/launch_bench.rb +37 -0
  117. data/test/bm/load_26c.rb +97 -0
  118. data/test/bm/mega.rb +64 -0
  119. data/test/bm/seq_thousand.rb +31 -0
  120. data/test/bm/t.rb +35 -0
  121. data/test/functional/base.rb +247 -0
  122. data/test/functional/concurrent_base.rb +98 -0
  123. data/test/functional/crunner.rb +31 -0
  124. data/test/functional/ct_0_concurrence.rb +65 -0
  125. data/test/functional/ct_1_iterator.rb +67 -0
  126. data/test/functional/ct_2_cancel.rb +81 -0
  127. data/test/functional/eft_0_process_definition.rb +65 -0
  128. data/test/functional/eft_10_cancel_process.rb +46 -0
  129. data/test/functional/eft_11_wait.rb +109 -0
  130. data/test/functional/eft_12_listen.rb +500 -0
  131. data/test/functional/eft_13_iterator.rb +342 -0
  132. data/test/functional/eft_14_cursor.rb +456 -0
  133. data/test/functional/eft_15_loop.rb +69 -0
  134. data/test/functional/eft_16_if.rb +183 -0
  135. data/test/functional/eft_17_equals.rb +55 -0
  136. data/test/functional/eft_18_concurrent_iterator.rb +410 -0
  137. data/test/functional/eft_19_reserve.rb +136 -0
  138. data/test/functional/eft_1_echo.rb +68 -0
  139. data/test/functional/eft_20_save.rb +116 -0
  140. data/test/functional/eft_21_restore.rb +61 -0
  141. data/test/functional/eft_22_noop.rb +28 -0
  142. data/test/functional/eft_23_apply.rb +168 -0
  143. data/test/functional/eft_24_add_branches.rb +98 -0
  144. data/test/functional/eft_25_command.rb +28 -0
  145. data/test/functional/eft_26_error.rb +77 -0
  146. data/test/functional/eft_27_inc.rb +280 -0
  147. data/test/functional/eft_28_once.rb +135 -0
  148. data/test/functional/eft_29_cron.rb +64 -0
  149. data/test/functional/eft_2_sequence.rb +58 -0
  150. data/test/functional/eft_30_ref.rb +155 -0
  151. data/test/functional/eft_31_registerp.rb +130 -0
  152. data/test/functional/eft_32_lose.rb +93 -0
  153. data/test/functional/eft_33_let.rb +31 -0
  154. data/test/functional/eft_34_given.rb +123 -0
  155. data/test/functional/eft_35_filter.rb +375 -0
  156. data/test/functional/eft_36_read.rb +95 -0
  157. data/test/functional/eft_3_participant.rb +149 -0
  158. data/test/functional/eft_4_set.rb +296 -0
  159. data/test/functional/eft_5_subprocess.rb +163 -0
  160. data/test/functional/eft_6_concurrence.rb +304 -0
  161. data/test/functional/eft_7_forget.rb +61 -0
  162. data/test/functional/eft_8_undo.rb +114 -0
  163. data/test/functional/eft_9_redo.rb +138 -0
  164. data/test/functional/ft_0_worker.rb +65 -0
  165. data/test/functional/ft_10_dollar.rb +304 -0
  166. data/test/functional/ft_11_recursion.rb +109 -0
  167. data/test/functional/ft_12_launchitem.rb +43 -0
  168. data/test/functional/ft_13_variables.rb +151 -0
  169. data/test/functional/ft_14_re_apply.rb +324 -0
  170. data/test/functional/ft_15_timeout.rb +226 -0
  171. data/test/functional/ft_16_participant_params.rb +98 -0
  172. data/test/functional/ft_17_conditional.rb +102 -0
  173. data/test/functional/ft_18_kill.rb +138 -0
  174. data/test/functional/ft_19_participant_code.rb +67 -0
  175. data/test/functional/ft_1_process_status.rb +796 -0
  176. data/test/functional/ft_20_storage_participant.rb +543 -0
  177. data/test/functional/ft_21_forget.rb +153 -0
  178. data/test/functional/ft_22_process_definitions.rb +90 -0
  179. data/test/functional/ft_23_load_defs.rb +79 -0
  180. data/test/functional/ft_24_block_participant.rb +235 -0
  181. data/test/functional/ft_25_receiver.rb +207 -0
  182. data/test/functional/ft_26_participant_rtimeout.rb +179 -0
  183. data/test/functional/ft_27_var_indirection.rb +128 -0
  184. data/test/functional/ft_28_null_noop_participants.rb +51 -0
  185. data/test/functional/ft_29_part_template.rb +60 -0
  186. data/test/functional/ft_2_errors.rb +380 -0
  187. data/test/functional/ft_30_smtp_participant.rb +122 -0
  188. data/test/functional/ft_31_part_blocking.rb +72 -0
  189. data/test/functional/ft_33_participant_subprocess_priority.rb +32 -0
  190. data/test/functional/ft_34_cursor_rewind.rb +101 -0
  191. data/test/functional/ft_35_add_service.rb +56 -0
  192. data/test/functional/ft_36_storage_history.rb +150 -0
  193. data/test/functional/ft_37_default_history.rb +109 -0
  194. data/test/functional/ft_38_participant_more.rb +193 -0
  195. data/test/functional/ft_39_wait_for.rb +136 -0
  196. data/test/functional/ft_3_participant_registration.rb +574 -0
  197. data/test/functional/ft_40_wait_logger.rb +62 -0
  198. data/test/functional/ft_41_participants.rb +91 -0
  199. data/test/functional/ft_42_storage_copy.rb +71 -0
  200. data/test/functional/ft_43_participant_on_reply.rb +87 -0
  201. data/test/functional/ft_44_var_participant.rb +35 -0
  202. data/test/functional/ft_45_participant_accept.rb +64 -0
  203. data/test/functional/ft_46_launch_single.rb +83 -0
  204. data/test/functional/ft_47_wfid_generator.rb +54 -0
  205. data/test/functional/ft_48_lose.rb +112 -0
  206. data/test/functional/ft_49_engine_on_error.rb +201 -0
  207. data/test/functional/ft_4_cancel.rb +132 -0
  208. data/test/functional/ft_50_engine_config.rb +22 -0
  209. data/test/functional/ft_51_misc.rb +67 -0
  210. data/test/functional/ft_52_case.rb +134 -0
  211. data/test/functional/ft_53_engine_on_terminate.rb +95 -0
  212. data/test/functional/ft_54_patterns.rb +104 -0
  213. data/test/functional/ft_55_engine_participant.rb +303 -0
  214. data/test/functional/ft_56_filter_attribute.rb +259 -0
  215. data/test/functional/ft_57_rev_participant.rb +252 -0
  216. data/test/functional/ft_58_workitem.rb +69 -0
  217. data/test/functional/ft_59_pause.rb +343 -0
  218. data/test/functional/ft_5_on_error.rb +384 -0
  219. data/test/functional/ft_60_code_participant.rb +45 -0
  220. data/test/functional/ft_61_trailing_fields.rb +34 -0
  221. data/test/functional/ft_62_exp_name_and_dollar_substitution.rb +35 -0
  222. data/test/functional/ft_6_on_cancel.rb +221 -0
  223. data/test/functional/ft_7_tags.rb +177 -0
  224. data/test/functional/ft_8_participant_consumption.rb +124 -0
  225. data/test/functional/ft_9_subprocesses.rb +146 -0
  226. data/test/functional/restart_base.rb +34 -0
  227. data/test/functional/rt_0_wait.rb +55 -0
  228. data/test/functional/rt_1_listen.rb +56 -0
  229. data/test/functional/rt_2_errors.rb +56 -0
  230. data/test/functional/rt_3_once.rb +70 -0
  231. data/test/functional/rt_4_cron.rb +64 -0
  232. data/test/functional/rt_5_timeout.rb +60 -0
  233. data/test/functional/rtest.rb +8 -0
  234. data/test/functional/storage_helper.rb +93 -0
  235. data/test/functional/test.rb +44 -0
  236. data/test/functional/vertical.rb +46 -0
  237. data/test/path_helper.rb +15 -0
  238. data/test/test.rb +13 -0
  239. data/test/test_helper.rb +28 -0
  240. data/test/unit/storage.rb +428 -0
  241. data/test/unit/storages.rb +37 -0
  242. data/test/unit/test.rb +28 -0
  243. data/test/unit/ut_0_ruby_reader.rb +223 -0
  244. data/test/unit/ut_11_lookup.rb +122 -0
  245. data/test/unit/ut_13_serializer.rb +65 -0
  246. data/test/unit/ut_14_is_uri.rb +28 -0
  247. data/test/unit/ut_15_util.rb +57 -0
  248. data/test/unit/ut_16_reader.rb +225 -0
  249. data/test/unit/ut_18_engine.rb +47 -0
  250. data/test/unit/ut_19_part_template.rb +86 -0
  251. data/test/unit/ut_1_fei.rb +165 -0
  252. data/test/unit/ut_20_composite_storage.rb +74 -0
  253. data/test/unit/ut_21_svc_participant_list.rb +46 -0
  254. data/test/unit/ut_22_filter.rb +1094 -0
  255. data/test/unit/ut_23_svc_tracker.rb +48 -0
  256. data/test/unit/ut_24_radial_reader.rb +332 -0
  257. data/test/unit/ut_25_merge.rb +113 -0
  258. data/test/unit/ut_3_wait_logger.rb +39 -0
  259. data/test/unit/ut_4_expmap.rb +20 -0
  260. data/test/unit/ut_5_tree.rb +54 -0
  261. data/test/unit/ut_6_condition.rb +303 -0
  262. data/test/unit/ut_7_workitem.rb +99 -0
  263. data/test/unit/ut_8_tree_to_dot.rb +72 -0
  264. data/test/unit/ut_9_xml_reader.rb +61 -0
  265. metadata +504 -0
@@ -0,0 +1,57 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Sat Sep 19 13:27:18 JST 2009
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
9
+
10
+ require 'ruote/util/misc'
11
+
12
+
13
+ class UtMiscTest < Test::Unit::TestCase
14
+
15
+ def test_narrow_to_number
16
+
17
+ assert_equal nil, Ruote.narrow_to_number(nil)
18
+ assert_equal nil, Ruote.narrow_to_number('a')
19
+ assert_equal nil, Ruote.narrow_to_number(Object.new)
20
+
21
+ assert_equal 0, Ruote.narrow_to_number(0)
22
+ assert_equal 1, Ruote.narrow_to_number(1)
23
+
24
+ assert_equal 0.0, Ruote.narrow_to_number(0.0)
25
+ assert_equal 1.0, Ruote.narrow_to_number(1.0)
26
+
27
+ assert_equal 0, Ruote.narrow_to_number('0')
28
+ assert_equal 1, Ruote.narrow_to_number('1')
29
+
30
+ assert_equal 0.0, Ruote.narrow_to_number('0.0')
31
+ assert_equal 1.0, Ruote.narrow_to_number('1.0')
32
+ end
33
+
34
+ def test_regex_or_s
35
+
36
+ assert_equal /bravo/, Ruote.regex_or_s('/bravo/')
37
+ assert_equal 'nada', Ruote.regex_or_s('nada')
38
+ assert_equal nil, Ruote.regex_or_s(nil)
39
+ end
40
+
41
+ class Klass
42
+ def initialize(s)
43
+ @s = s
44
+ end
45
+ end
46
+
47
+ def test_fulldup
48
+
49
+ a = Klass.new('hello')
50
+ b = Ruote.fulldup(a)
51
+
52
+ assert_equal Klass, b.class
53
+ assert_not_equal a.object_id, b.object_id
54
+ assert_equal 'hello', b.instance_variable_get(:@s)
55
+ end
56
+ end
57
+
@@ -0,0 +1,225 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Tue Oct 20 10:48:11 JST 2009
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
9
+
10
+ require_json
11
+ require 'ruote/reader'
12
+
13
+
14
+ class PdefReaderTest < Test::Unit::TestCase
15
+
16
+ DEF0 = %{
17
+ Ruote.define :name => 'nada' do
18
+ sequence do
19
+ alpha
20
+ bravo
21
+ end
22
+ end
23
+ }
24
+
25
+ TREE1 = Ruote::Reader.read(%{
26
+ Ruote.define :name => 'nada' do
27
+ sequence do
28
+ alpha
29
+ participant 'bravo', :timeout => '2d', :on_board => true
30
+ end
31
+ end
32
+ })
33
+
34
+ def test_from_string
35
+
36
+ tree = Ruote::Reader.read(DEF0)
37
+
38
+ assert_equal(
39
+ ["define", {"name"=>"nada"}, [
40
+ ["sequence", {}, [["alpha", {}, []], ["bravo", {}, []]]]
41
+ ]],
42
+ tree)
43
+ end
44
+
45
+ def test_from_file
46
+
47
+ fn = File.join(File.dirname(__FILE__), '_ut_16_def.rb')
48
+
49
+ File.open(fn, 'w') { |f| f.write(DEF0) }
50
+
51
+ tree = Ruote::Reader.read(fn)
52
+
53
+ assert_equal(
54
+ ["define", {"name"=>"nada"}, [
55
+ ["sequence", {}, [["alpha", {}, []], ["bravo", {}, []]]]
56
+ ]],
57
+ tree)
58
+
59
+ FileUtils.rm_f(fn) # sooner or later, it will get erased
60
+ end
61
+
62
+ def test_to_xml
63
+
64
+ assert_equal(
65
+ %{
66
+ <?xml version="1.0" encoding="UTF-8"?>
67
+ <define name="nada">
68
+ <sequence>
69
+ <alpha/>
70
+ <participant timeout="2d" on-board="true" ref="bravo"/>
71
+ </sequence>
72
+ </define>
73
+ }.strip,
74
+ Ruote::Reader.to_xml(TREE1, :indent => 2).strip)
75
+ end
76
+
77
+ def test_if_to_xml
78
+
79
+ tree = Ruote.process_definition do
80
+ _if 'nada' do
81
+ participant 'nemo'
82
+ end
83
+ end
84
+
85
+ assert_equal(
86
+ %{
87
+ <?xml version="1.0" encoding="UTF-8"?>
88
+ <define>
89
+ <if test="nada">
90
+ <participant ref="nemo"/>
91
+ </if>
92
+ </define>
93
+ }.strip,
94
+ Ruote::Reader.to_xml(tree, :indent => 2).strip)
95
+ end
96
+
97
+ def test_to_ruby
98
+
99
+ assert_equal(
100
+ %{
101
+ Ruote.process_definition :name => "nada" do
102
+ sequence do
103
+ alpha
104
+ participant "bravo", :timeout => "2d", :on_board => true
105
+ end
106
+ end
107
+ }.strip,
108
+ Ruote::Reader.to_ruby(TREE1).strip)
109
+ end
110
+
111
+ def test_to_json
112
+
113
+ require 'json'
114
+
115
+ assert_equal TREE1.to_json, Ruote::Reader.to_json(TREE1)
116
+ end
117
+
118
+ def test_to_radial
119
+
120
+ assert_equal(
121
+ %{
122
+ define name: "nada"
123
+ sequence
124
+ alpha
125
+ participant "bravo", timeout: "2d", on_board: true
126
+ }.strip,
127
+ Ruote::Reader.to_radial(TREE1).strip)
128
+ end
129
+
130
+ DEF1 = %{
131
+ Ruote.process_definition do
132
+ sequence do
133
+ alpha
134
+ set :field => 'f', :value => 'v'
135
+ bravo
136
+ end
137
+ end
138
+ }
139
+
140
+ def test_from_ruby_file
141
+
142
+ fn = File.expand_path(File.join(File.dirname(__FILE__), '_ut_16_def1.rb'))
143
+
144
+ File.open(fn, 'wb') { |f| f.write(DEF1) }
145
+
146
+ assert_equal(
147
+ ["define", {}, [["sequence", {}, [["alpha", {}, []], ["set", {"field"=>"f", "value"=>"v"}, []], ["bravo", {}, []]]]]],
148
+ Ruote::Reader.read(fn))
149
+
150
+ FileUtils.rm(fn)
151
+ end
152
+
153
+ # Make sure that ruby method names like 'freeze' or 'clone' can be used
154
+ # in process definitions.
155
+ #
156
+ def test_ruby_blank_slate
157
+
158
+ t = Ruote::Reader.read(%{
159
+ Ruote.define do
160
+ freeze
161
+ clone
162
+ untrust
163
+ end
164
+ })
165
+
166
+ assert_equal(
167
+ [ 'define', {}, [
168
+ [ 'freeze', {}, [] ], [ 'clone', {}, [] ], [ 'untrust', {}, [] ]
169
+ ] ],
170
+ t)
171
+ end
172
+
173
+ def test_radial
174
+
175
+ tree = Ruote::Reader.read(%{
176
+ define name: 'nada'
177
+ sequence
178
+ alpha
179
+ participant bravo, timeout: 2d, on-board: true
180
+ })
181
+
182
+ assert_equal(
183
+ [ 'define', { 'name' => 'nada' }, [
184
+ [ 'sequence', {}, [
185
+ [ 'alpha', {}, [] ],
186
+ [ 'participant', { 'bravo' => nil, 'timeout' => '2d', 'on_board' => true }, [] ]
187
+ ] ]
188
+ ] ],
189
+ tree)
190
+ end
191
+
192
+ def test_parse_error__ruby
193
+
194
+ err = nil
195
+
196
+ begin
197
+ Ruote::Reader.read(%{
198
+ Ruote.process_definition # missing "do"
199
+ alpha
200
+ end
201
+ })
202
+ rescue => err
203
+ end
204
+
205
+ assert_equal Ruote::Reader::Error, err.class
206
+ assert_equal Racc::ParseError, err.cause.class
207
+ end
208
+
209
+ def test_parse_error__radial
210
+
211
+ err = nil
212
+
213
+ begin
214
+ Ruote::Reader.read(%{
215
+ process_definition ${f:y}
216
+ alpha
217
+ })
218
+ rescue => err
219
+ end
220
+
221
+ assert_equal Ruote::Reader::Error, err.class
222
+ assert_equal Parslet::UnconsumedInput, err.cause.class
223
+ end
224
+ end
225
+
@@ -0,0 +1,47 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Sun Jan 3 12:04:07 JST 2010
6
+ #
7
+ # Matt Nichols (http://github.com/mattnichols)
8
+ #
9
+
10
+ require File.join(File.dirname(__FILE__), %w[ .. test_helper.rb ])
11
+ require File.join(File.dirname(__FILE__), %w[ .. functional storage_helper.rb ])
12
+
13
+ require 'ruote'
14
+
15
+
16
+ class UtEngineTest < Test::Unit::TestCase
17
+
18
+ def test_initialize_with_worker
19
+
20
+ storage = determine_storage(
21
+ 's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])
22
+ worker = Ruote::Worker.new(storage)
23
+ engine = Ruote::Engine.new(worker, false)
24
+ end
25
+
26
+ def test_initialize_with_worker_and_without_logger
27
+
28
+ storage = determine_storage({})
29
+ worker = Ruote::Worker.new(storage)
30
+ engine = Ruote::Engine.new(worker, false)
31
+ end
32
+
33
+ def test_initialize_with_storage
34
+
35
+ storage = determine_storage(
36
+ 's_logger' => [ 'ruote/log/test_logger', 'Ruote::TestLogger' ])
37
+
38
+ engine = Ruote::Engine.new(storage)
39
+ end
40
+
41
+ def test_initialize_storage_without_logger
42
+
43
+ storage = determine_storage({})
44
+ engine = Ruote::Engine.new(storage)
45
+ end
46
+ end
47
+
@@ -0,0 +1,86 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Thu Mar 4 10:24:30 JST 2010
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
9
+
10
+ require_json
11
+ require 'ruote/context'
12
+ require 'ruote/part/template'
13
+ require 'ruote/storage/hash_storage'
14
+
15
+
16
+ class UtPartTemplateTest < Test::Unit::TestCase
17
+
18
+ class MyParticipant
19
+ include ::Ruote::TemplateMixin
20
+
21
+ def initialize
22
+
23
+ @context = ::Ruote::Context.new(::Ruote::HashStorage.new)
24
+ end
25
+ end
26
+
27
+ DEFAULT = %{
28
+ workitem for gonzalo
29
+
30
+ {
31
+ "wfid": "20100304-bidehachina",
32
+ "expid": "0_0_1"
33
+ }
34
+
35
+ - 'car' ==> "BMW"
36
+ - 'model' ==> "BMW 328 Mille Miglia"
37
+ }.strip
38
+
39
+ def setup
40
+
41
+ @workitem = {
42
+ 'fei'=> { 'wfid' => '20100304-bidehachina', 'expid' => '0_0_1' },
43
+ 'participant_name' => 'gonzalo',
44
+ 'fields' => {
45
+ 'car' => 'BMW',
46
+ 'model' => 'BMW 328 Mille Miglia'
47
+ }
48
+ }
49
+ end
50
+
51
+ def test_default_template
52
+
53
+ assert_equal(
54
+ DEFAULT,
55
+ MyParticipant.new.render_default_template(@workitem))
56
+
57
+ assert_equal(
58
+ DEFAULT,
59
+ MyParticipant.new.render_template(nil, nil, @workitem))
60
+ end
61
+
62
+ def test_file_template
63
+
64
+ fn = "#{__FILE__}.template"
65
+
66
+ File.open(fn, 'wb') { |f| f.write('the model is ${f:model}') }
67
+
68
+ assert_equal(
69
+ 'the model is BMW 328 Mille Miglia',
70
+ MyParticipant.new.render_template(fn, nil, @workitem))
71
+
72
+ FileUtils.rm_f(fn)
73
+ end
74
+
75
+ def test_string_template
76
+
77
+ template = %{
78
+ My car is a ${f:car}
79
+ }.strip
80
+
81
+ assert_equal(
82
+ 'My car is a BMW',
83
+ MyParticipant.new.render_template(template, nil, @workitem))
84
+ end
85
+ end
86
+
@@ -0,0 +1,165 @@
1
+
2
+ #
3
+ # testing ruote
4
+ #
5
+ # Fri May 15 10:08:51 JST 2009
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), '..', 'test_helper.rb')
9
+
10
+ require 'ruote'
11
+
12
+
13
+ class UtFeiTest < Test::Unit::TestCase
14
+
15
+ def test_misc
16
+
17
+ fei = Ruote::FlowExpressionId.new(
18
+ 'expid' => '0_0',
19
+ 'wfid' => '20101224-bababa',
20
+ 'subid' => '5dbf4ce1553453baa17c2213d239e5fa',
21
+ 'engine_id' => 'engine')
22
+
23
+ assert_equal(
24
+ '0_0!5dbf4ce1553453baa17c2213d239e5fa!20101224-bababa',
25
+ fei.to_storage_id)
26
+
27
+ assert_equal(
28
+ 0,
29
+ fei.child_id)
30
+
31
+ assert_equal(
32
+ { 'expid' => '0_0',
33
+ 'wfid' => '20101224-bababa',
34
+ 'subid' => '5dbf4ce1553453baa17c2213d239e5fa',
35
+ 'engine_id' => 'engine' },
36
+ fei.to_h)
37
+ end
38
+
39
+ def test_direct_child
40
+
41
+ f0 = {
42
+ 'expid' => '0', 'wfid' => '20101224-bababa', 'engine_id' => 'engine' }
43
+ f1 = {
44
+ 'expid' => '0_0', 'wfid' => '20101224-bababa', 'engine_id' => 'engine' }
45
+ f2 = {
46
+ 'expid' => '0_0_0', 'wfid' => '20101224-bababa', 'engine_id' => 'engine' }
47
+ f3 = {
48
+ 'expid' => '0_0', 'wfid' => '20101224-bakayaro', 'engine_id' => 'engine' }
49
+
50
+ assert_equal false, Ruote::FlowExpressionId.direct_child?(f0, f0)
51
+ assert_equal true, Ruote::FlowExpressionId.direct_child?(f0, f1)
52
+ assert_equal false, Ruote::FlowExpressionId.direct_child?(f0, f2)
53
+ assert_equal false, Ruote::FlowExpressionId.direct_child?(f0, f3)
54
+ end
55
+
56
+ def test_is_a_fei
57
+
58
+ assert_equal(
59
+ true,
60
+ Ruote::FlowExpressionId.is_a_fei?(
61
+ 'expid' => '0', 'wfid' => '20101224-bababa', 'engine_id' => 'engine'))
62
+ assert_equal(
63
+ false,
64
+ Ruote::FlowExpressionId.is_a_fei?(
65
+ 'nada' => '0', 'wfid' => '20101224-bababa', 'engine_id' => 'engine'))
66
+ end
67
+
68
+ def test_equality
69
+
70
+ f0 = Ruote::FlowExpressionId.new(
71
+ 'expid' => '0_0', 'wfid' => '20101224-bababa', 'engine_id' => 'engine')
72
+ f1 = Ruote::FlowExpressionId.new(
73
+ 'expid' => '0_0', 'wfid' => '20101224-bababa', 'engine_id' => 'engine')
74
+ f2 = Ruote::FlowExpressionId.new(
75
+ 'expid' => '0_1', 'wfid' => '20101224-bababa', 'engine_id' => 'engine')
76
+
77
+ assert f0 == f1
78
+ assert f0 != f2
79
+
80
+ assert_equal f0.hash, f1.hash
81
+ assert_not_equal f0.hash, f2.hash
82
+ end
83
+
84
+ def test_from_id
85
+
86
+ assert_equal(
87
+ '0_0_1!!20100224-fake',
88
+ Ruote::FlowExpressionId.from_id('0_0_1!!20100224-fake').to_storage_id)
89
+ assert_equal(
90
+ '0_0_1!!20100224-fake',
91
+ Ruote::FlowExpressionId.from_id('wi!0_0_1!!20100224-fake').to_storage_id)
92
+ assert_equal(
93
+ '0_0_1!!20100224-fake',
94
+ Ruote::FlowExpressionId.from_id('wi!store!0_0_1!!20100224-fake').to_storage_id)
95
+
96
+ assert_equal(
97
+ '0_0_1!!20100224-fake',
98
+ Ruote::FlowExpressionId.from_id('eng!0_0_1!!20100224-fake').to_storage_id)
99
+ assert_equal(
100
+ 'eng',
101
+ Ruote::FlowExpressionId.from_id('eng!0_0_1!!20100224-fake').engine_id)
102
+ end
103
+
104
+ def test_extract_h
105
+
106
+ assert_equal(
107
+ { 'engine_id' => 'engine',
108
+ 'expid' => '0_0_1',
109
+ 'subid' => '5dbf4ce1553453baa17c2213d239e5fa',
110
+ 'wfid' => '20100224-fake' },
111
+ Ruote::FlowExpressionId.extract_h(
112
+ '0_0_1!5dbf4ce1553453baa17c2213d239e5fa!20100224-fake'))
113
+ end
114
+
115
+ def test_extract
116
+
117
+ assert_equal(
118
+ Ruote::FlowExpressionId.new(
119
+ 'engine_id' => 'engine',
120
+ 'expid' => '0_0_1',
121
+ 'subid' => '5dbf4ce1553453baa17c2213d239e5fa',
122
+ 'wfid' => '20100224-fake'),
123
+ Ruote::FlowExpressionId.extract(
124
+ '0_0_1!5dbf4ce1553453baa17c2213d239e5fa!20100224-fake'))
125
+ end
126
+
127
+ def test_subid_backward_compatibility__subid
128
+
129
+ fei = Ruote::FlowExpressionId.new(
130
+ 'engine_id' => 'engine',
131
+ 'expid' => '0_0_1',
132
+ 'subid' => 'd7ca677379e2a1f4933402b9196cf2a1',
133
+ 'wfid' => '20100224-fake')
134
+
135
+ assert_equal 'd7ca677379e2a1f4933402b9196cf2a1', fei.sub_wfid
136
+ assert_equal 'd7ca677379e2a1f4933402b9196cf2a1', fei.subid
137
+ assert_equal 'd7ca677379e2a1f4933402b9196cf2a1', fei.h['subid']
138
+ assert_nil fei.h['sub_wfid']
139
+ end
140
+
141
+ def test_subid_backward_compatibility__sub_wfid
142
+
143
+ fei = Ruote::FlowExpressionId.new(
144
+ 'engine_id' => 'engine',
145
+ 'expid' => '0_0_1',
146
+ 'sub_wfid' => 'd7ca677379e2a1f4933402b9196cf2a1',
147
+ 'wfid' => '20100224-fake')
148
+
149
+ assert_equal 'd7ca677379e2a1f4933402b9196cf2a1', fei.sub_wfid
150
+ assert_equal 'd7ca677379e2a1f4933402b9196cf2a1', fei.subid
151
+ assert_equal 'd7ca677379e2a1f4933402b9196cf2a1', fei.h['subid']
152
+ assert_nil fei.h['sub_wfid']
153
+ end
154
+
155
+ def test_generate_subid
156
+
157
+ n = 21_000
158
+ h = '0_0'
159
+
160
+ ids = n.times.collect { Ruote.generate_subid(h) }
161
+
162
+ assert_equal n, ids.uniq.size, "subid generation seems weak"
163
+ end
164
+ end
165
+