ruote 0.9.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. data/README.txt +24 -0
  2. data/bin/validate-workflow.rb +89 -0
  3. data/examples/about_state.rb +81 -0
  4. data/examples/bigflow.rb +19 -0
  5. data/examples/csv_weather.rb +23 -0
  6. data/examples/engine_template.rb +247 -0
  7. data/examples/flowtracing.rb +24 -0
  8. data/examples/homeworkreview.rb +68 -0
  9. data/examples/kotoba.rb +22 -0
  10. data/examples/mano_tracker.rb +172 -0
  11. data/examples/openwferu.rb +58 -0
  12. data/examples/quotereporter.rb +157 -0
  13. data/examples/scheduler_cron_usage.rb +48 -0
  14. data/examples/scheduler_usage.rb +56 -0
  15. data/lib/openwfe.rb +41 -0
  16. data/lib/openwfe/contextual.rb +111 -0
  17. data/lib/openwfe/def.rb +46 -0
  18. data/lib/openwfe/engine.rb +37 -0
  19. data/lib/openwfe/engine/engine.rb +756 -0
  20. data/lib/openwfe/engine/expool_methods.rb +172 -0
  21. data/lib/openwfe/engine/file_persisted_engine.rb +105 -0
  22. data/lib/openwfe/engine/participant_methods.rb +133 -0
  23. data/lib/openwfe/engine/status_methods.rb +353 -0
  24. data/lib/openwfe/engine/update_exp_methods.rb +112 -0
  25. data/lib/openwfe/exceptions.rb +51 -0
  26. data/lib/openwfe/expool/errorjournal.rb +476 -0
  27. data/lib/openwfe/expool/expressionpool.rb +1144 -0
  28. data/lib/openwfe/expool/expstorage.rb +403 -0
  29. data/lib/openwfe/expool/history.rb +174 -0
  30. data/lib/openwfe/expool/journal.rb +224 -0
  31. data/lib/openwfe/expool/journal_replay.rb +321 -0
  32. data/lib/openwfe/expool/parser.rb +242 -0
  33. data/lib/openwfe/expool/representation.rb +121 -0
  34. data/lib/openwfe/expool/threadedexpstorage.rb +188 -0
  35. data/lib/openwfe/expool/wfidgen.rb +388 -0
  36. data/lib/openwfe/expool/yamlexpstorage.rb +224 -0
  37. data/lib/openwfe/expressions/condition.rb +244 -0
  38. data/lib/openwfe/expressions/environment.rb +246 -0
  39. data/lib/openwfe/expressions/expressionmap.rb +258 -0
  40. data/lib/openwfe/expressions/fe_cancel.rb +109 -0
  41. data/lib/openwfe/expressions/fe_command.rb +241 -0
  42. data/lib/openwfe/expressions/fe_concurrence.rb +662 -0
  43. data/lib/openwfe/expressions/fe_cron.rb +259 -0
  44. data/lib/openwfe/expressions/fe_cursor.rb +259 -0
  45. data/lib/openwfe/expressions/fe_define.rb +192 -0
  46. data/lib/openwfe/expressions/fe_do.rb +168 -0
  47. data/lib/openwfe/expressions/fe_equals.rb +291 -0
  48. data/lib/openwfe/expressions/fe_filter.rb +129 -0
  49. data/lib/openwfe/expressions/fe_filter_definition.rb +168 -0
  50. data/lib/openwfe/expressions/fe_fqv.rb +250 -0
  51. data/lib/openwfe/expressions/fe_if.rb +303 -0
  52. data/lib/openwfe/expressions/fe_iterator.rb +145 -0
  53. data/lib/openwfe/expressions/fe_listen.rb +371 -0
  54. data/lib/openwfe/expressions/fe_losfor.rb +111 -0
  55. data/lib/openwfe/expressions/fe_misc.rb +421 -0
  56. data/lib/openwfe/expressions/fe_participant.rb +269 -0
  57. data/lib/openwfe/expressions/fe_reserve.rb +212 -0
  58. data/lib/openwfe/expressions/fe_save.rb +274 -0
  59. data/lib/openwfe/expressions/fe_sequence.rb +117 -0
  60. data/lib/openwfe/expressions/fe_set.rb +139 -0
  61. data/lib/openwfe/expressions/fe_sleep.rb +166 -0
  62. data/lib/openwfe/expressions/fe_step.rb +159 -0
  63. data/lib/openwfe/expressions/fe_subprocess.rb +168 -0
  64. data/lib/openwfe/expressions/fe_timeout.rb +127 -0
  65. data/lib/openwfe/expressions/fe_wait.rb +78 -0
  66. data/lib/openwfe/expressions/fe_when.rb +142 -0
  67. data/lib/openwfe/expressions/filter.rb +104 -0
  68. data/lib/openwfe/expressions/flowexpression.rb +847 -0
  69. data/lib/openwfe/expressions/iterator.rb +221 -0
  70. data/lib/openwfe/expressions/merge.rb +84 -0
  71. data/lib/openwfe/expressions/raw.rb +547 -0
  72. data/lib/openwfe/expressions/rprocdef.rb +375 -0
  73. data/lib/openwfe/expressions/time.rb +333 -0
  74. data/lib/openwfe/expressions/timeout.rb +178 -0
  75. data/lib/openwfe/expressions/value.rb +126 -0
  76. data/lib/openwfe/filterdef.rb +259 -0
  77. data/lib/openwfe/flowexpressionid.rb +357 -0
  78. data/lib/openwfe/listeners/listener.rb +97 -0
  79. data/lib/openwfe/listeners/listeners.rb +139 -0
  80. data/lib/openwfe/listeners/socketlisteners.rb +272 -0
  81. data/lib/openwfe/logging.rb +122 -0
  82. data/lib/openwfe/omixins.rb +95 -0
  83. data/lib/openwfe/orest/controlclient.rb +119 -0
  84. data/lib/openwfe/orest/definitions.rb +113 -0
  85. data/lib/openwfe/orest/exception.rb +60 -0
  86. data/lib/openwfe/orest/oldrestservlet.rb +279 -0
  87. data/lib/openwfe/orest/osocket.rb +148 -0
  88. data/lib/openwfe/orest/restclient.rb +176 -0
  89. data/lib/openwfe/orest/workitem.rb +206 -0
  90. data/lib/openwfe/orest/worklistclient.rb +272 -0
  91. data/lib/openwfe/orest/xmlcodec.rb +670 -0
  92. data/lib/openwfe/participants.rb +38 -0
  93. data/lib/openwfe/participants/enoparticipants.rb +230 -0
  94. data/lib/openwfe/participants/participant.rb +141 -0
  95. data/lib/openwfe/participants/participantmap.rb +249 -0
  96. data/lib/openwfe/participants/participants.rb +407 -0
  97. data/lib/openwfe/participants/soapparticipants.rb +135 -0
  98. data/lib/openwfe/participants/socketparticipants.rb +202 -0
  99. data/lib/openwfe/participants/storeparticipants.rb +254 -0
  100. data/lib/openwfe/rudefinitions.rb +130 -0
  101. data/lib/openwfe/service.rb +103 -0
  102. data/lib/openwfe/storage/yamlcustom.rb +106 -0
  103. data/lib/openwfe/storage/yamlfilestorage.rb +245 -0
  104. data/lib/openwfe/tools/flowtracer.rb +81 -0
  105. data/lib/openwfe/util/dollar.rb +217 -0
  106. data/lib/openwfe/util/irb.rb +86 -0
  107. data/lib/openwfe/util/observable.rb +144 -0
  108. data/lib/openwfe/util/ometa.rb +62 -0
  109. data/lib/openwfe/util/workqueue.rb +124 -0
  110. data/lib/openwfe/util/xml.rb +418 -0
  111. data/lib/openwfe/utils.rb +554 -0
  112. data/lib/openwfe/version.rb +37 -0
  113. data/lib/openwfe/workitem.rb +499 -0
  114. data/lib/openwfe/worklist/oldrest.rb +244 -0
  115. data/lib/openwfe/worklist/storelocks.rb +293 -0
  116. data/lib/openwfe/worklist/storeparticipant.rb +44 -0
  117. data/lib/openwfe/worklist/worklist.rb +297 -0
  118. data/test/README.txt +27 -0
  119. data/test/back_0916_test.rb +111 -0
  120. data/test/bm/bm_1_xml_vs_prog.rb +56 -0
  121. data/test/bm/bm_2_step.rb +109 -0
  122. data/test/bm/ft_0f_5ms.rb +35 -0
  123. data/test/bm/ft_26_load.rb +210 -0
  124. data/test/bm/ft_26b_load.rb +86 -0
  125. data/test/bm/ft_26c_load.rb +97 -0
  126. data/test/bm/ft_26d_load.rb +97 -0
  127. data/test/bm/ft_recu.rb +71 -0
  128. data/test/clone_test.rb +122 -0
  129. data/test/concurrence_test.rb +77 -0
  130. data/test/condition_test.rb +155 -0
  131. data/test/console_test.rb +12 -0
  132. data/test/cron_ltest.rb +15 -0
  133. data/test/description_test.rb +87 -0
  134. data/test/eno_test.rb +76 -0
  135. data/test/expmap_test.rb +54 -0
  136. data/test/expool_20031219_0916.tgz +0 -0
  137. data/test/fe_lookup_att_test.rb +62 -0
  138. data/test/fei_test.rb +181 -0
  139. data/test/file_persisted_engine_test.rb +64 -0
  140. data/test/file_persistence_test.rb +134 -0
  141. data/test/filep_cancel_test.rb +123 -0
  142. data/test/filter_test.rb +109 -0
  143. data/test/flowtestbase.rb +351 -0
  144. data/test/ft_0.rb +68 -0
  145. data/test/ft_0b_sequence.rb +36 -0
  146. data/test/ft_0c_testname.rb +33 -0
  147. data/test/ft_0d_participant.rb +30 -0
  148. data/test/ft_0e_multibody.rb +34 -0
  149. data/test/ft_10_loop.rb +134 -0
  150. data/test/ft_11_ppd.rb +415 -0
  151. data/test/ft_11b_ppd.rb +54 -0
  152. data/test/ft_12_blockparticipant.rb +97 -0
  153. data/test/ft_13_eno.rb +52 -0
  154. data/test/ft_14_subprocess.rb +88 -0
  155. data/test/ft_14b_subprocess.rb +192 -0
  156. data/test/ft_14c_subprocess.rb +68 -0
  157. data/test/ft_15_iterator.rb +216 -0
  158. data/test/ft_15b_iterator.rb +74 -0
  159. data/test/ft_16_fqv.rb +73 -0
  160. data/test/ft_17_condition.rb +84 -0
  161. data/test/ft_18_pname.rb +56 -0
  162. data/test/ft_1_unset.rb +175 -0
  163. data/test/ft_1b_unset.rb +39 -0
  164. data/test/ft_20_cron.rb +53 -0
  165. data/test/ft_21_cron.rb +87 -0
  166. data/test/ft_21b_cron_pause.rb +82 -0
  167. data/test/ft_22_history.rb +74 -0
  168. data/test/ft_23_when.rb +77 -0
  169. data/test/ft_23b_when.rb +70 -0
  170. data/test/ft_23c_wait.rb +80 -0
  171. data/test/ft_23d_cww.rb +58 -0
  172. data/test/ft_24_def.rb +44 -0
  173. data/test/ft_25_cancel.rb +89 -0
  174. data/test/ft_27_getflowpos.rb +147 -0
  175. data/test/ft_28_fileparticipant.rb +63 -0
  176. data/test/ft_29_httprb.rb +106 -0
  177. data/test/ft_2_concurrence.rb +135 -0
  178. data/test/ft_2b_concurrence.rb +188 -0
  179. data/test/ft_2c_concurrence.rb +64 -0
  180. data/test/ft_30_socketlistener.rb +203 -0
  181. data/test/ft_31_flowname.rb +40 -0
  182. data/test/ft_32_journal.rb +91 -0
  183. data/test/ft_32c_journal.rb +102 -0
  184. data/test/ft_32d_journal.rb +84 -0
  185. data/test/ft_33_description.rb +107 -0
  186. data/test/ft_34_cancelwfid.rb +80 -0
  187. data/test/ft_35_localdefs.rb +75 -0
  188. data/test/ft_36_subprocids.rb +97 -0
  189. data/test/ft_37_pnames.rb +70 -0
  190. data/test/ft_38_tag.rb +127 -0
  191. data/test/ft_38b_tag.rb +161 -0
  192. data/test/ft_38c_tag.rb +100 -0
  193. data/test/ft_39_reserve.rb +63 -0
  194. data/test/ft_39b_reserve.rb +84 -0
  195. data/test/ft_3_equals.rb +170 -0
  196. data/test/ft_3b_lookup_vf.rb +83 -0
  197. data/test/ft_40_defined.rb +61 -0
  198. data/test/ft_41_case.rb +110 -0
  199. data/test/ft_42_environments.rb +75 -0
  200. data/test/ft_43_pat10.rb +85 -0
  201. data/test/ft_44_save.rb +70 -0
  202. data/test/ft_44b_restore.rb +212 -0
  203. data/test/ft_45_citerator.rb +214 -0
  204. data/test/ft_46_pparams.rb +62 -0
  205. data/test/ft_47_filter.rb +160 -0
  206. data/test/ft_48_fe_filter.rb +88 -0
  207. data/test/ft_49_condition.rb +126 -0
  208. data/test/ft_4_misc.rb +237 -0
  209. data/test/ft_50_xml_attribute.rb +155 -0
  210. data/test/ft_51_stack.rb +55 -0
  211. data/test/ft_52_obs_participant.rb +123 -0
  212. data/test/ft_53_null_noop_participant.rb +62 -0
  213. data/test/ft_54_listen.rb +288 -0
  214. data/test/ft_54b_listen.rb +66 -0
  215. data/test/ft_54c_listen.rb +99 -0
  216. data/test/ft_55_ptimeout.rb +59 -0
  217. data/test/ft_56_timeout.rb +59 -0
  218. data/test/ft_57_a.rb +145 -0
  219. data/test/ft_58_ejournal.rb +151 -0
  220. data/test/ft_59_ps.rb +150 -0
  221. data/test/ft_59b_ps_for_pat.rb +58 -0
  222. data/test/ft_5_time.rb +118 -0
  223. data/test/ft_60_ecancel.rb +161 -0
  224. data/test/ft_61_elsub.rb +51 -0
  225. data/test/ft_62_procparticipant.rb +71 -0
  226. data/test/ft_63_pause.rb +124 -0
  227. data/test/ft_64_alias.rb +102 -0
  228. data/test/ft_64_clone.rb +69 -0
  229. data/test/ft_65_stringlaunch.rb +59 -0
  230. data/test/ft_66_subforget.rb +70 -0
  231. data/test/ft_67_schedlaunch.rb +116 -0
  232. data/test/ft_68_ifparticipant.rb +70 -0
  233. data/test/ft_69_cancelmissing.rb +51 -0
  234. data/test/ft_6_lambda.rb +64 -0
  235. data/test/ft_70_lookupvar.rb +55 -0
  236. data/test/ft_71_log.rb +60 -0
  237. data/test/ft_72_lookup_processes.rb +76 -0
  238. data/test/ft_73_cancel_sub.rb +139 -0
  239. data/test/ft_74_block_and_workitem_dup.rb +63 -0
  240. data/test/ft_75_ruby_attributes.rb +87 -0
  241. data/test/ft_76_merge_isolate.rb +88 -0
  242. data/test/ft_77_segments.rb +35 -0
  243. data/test/ft_78_eval.rb +150 -0
  244. data/test/ft_79_tticket.rb +187 -0
  245. data/test/ft_79b_tticket.rb +172 -0
  246. data/test/ft_79c_outcome.rb +56 -0
  247. data/test/ft_7_lose.rb +104 -0
  248. data/test/ft_7b_lose.rb +78 -0
  249. data/test/ft_80_spname.rb +91 -0
  250. data/test/ft_81_exp.rb +60 -0
  251. data/test/ft_82_trecu.rb +46 -0
  252. data/test/ft_83_badpause.rb +58 -0
  253. data/test/ft_84_updateexp.rb +198 -0
  254. data/test/ft_85_dolhash.rb +43 -0
  255. data/test/ft_86_dollar_fv.rb +68 -0
  256. data/test/ft_87_define.rb +74 -0
  257. data/test/ft_8_forget.rb +44 -0
  258. data/test/ft_9_cursor.rb +145 -0
  259. data/test/ft_9b_cursor.rb +105 -0
  260. data/test/ft_tests.rb +124 -0
  261. data/test/hash_test.rb +75 -0
  262. data/test/hparticipant_test.rb +164 -0
  263. data/test/lookup_att_test.rb +90 -0
  264. data/test/lookup_vf_test.rb +94 -0
  265. data/test/misc_test.rb +90 -0
  266. data/test/nut_0_irb.rb +20 -0
  267. data/test/obs_test.rb +142 -0
  268. data/test/orest_test.rb +251 -0
  269. data/test/param_test.rb +290 -0
  270. data/test/participant_test.rb +101 -0
  271. data/test/pending.rb +23 -0
  272. data/test/ps_representation.rb +133 -0
  273. data/test/rake_ltest.rb +38 -0
  274. data/test/rake_qtest.rb +68 -0
  275. data/test/raw_prog_test.rb +412 -0
  276. data/test/restart_cron_test.rb +136 -0
  277. data/test/restart_paused_test.rb +98 -0
  278. data/test/restart_sleep_test.rb +140 -0
  279. data/test/restart_tests.rb +18 -0
  280. data/test/restart_when_test.rb +112 -0
  281. data/test/ruby_procdef_test.rb +132 -0
  282. data/test/rutest_utils.rb +63 -0
  283. data/test/sec_test.rb +205 -0
  284. data/test/slock_test.rb +80 -0
  285. data/test/storage_test.rb +44 -0
  286. data/test/test.rb +3 -0
  287. data/test/timeout_test.rb +105 -0
  288. data/test/util_xml_test.rb +112 -0
  289. data/test/wfid_test.rb +175 -0
  290. data/test/wi_test.rb +75 -0
  291. metadata +433 -0
data/test/ft_0.rb ADDED
@@ -0,0 +1,68 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ class FlowTest0 < Test::Unit::TestCase
14
+ include FlowTestBase
15
+
16
+ #def setup
17
+ #end
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ def test_0
23
+ #log_level_to_debug
24
+ dotest(
25
+ '''<process-definition name="n" revision="0">
26
+ <print>ok</print>
27
+ </process-definition>''', "ok")
28
+ end
29
+
30
+ def test_1
31
+ dotest(
32
+ '''<process-definition name="n" revision="0">
33
+ </process-definition>''', '')
34
+ end
35
+
36
+ def test_2
37
+ #log_level_to_debug
38
+ dotest(
39
+ '''<process-definition name="n" revision="0">
40
+ <sequence>
41
+ <set variable="x" value="y" />
42
+ <print>${x} ${v:x}</print>
43
+ </sequence>
44
+ </process-definition>''', 'y y')
45
+ end
46
+
47
+ def test_3
48
+ #log_level_to_debug
49
+ dotest(
50
+ '''<process-definition name="n" revision="0">
51
+ <sequence>
52
+ <set field="x" value="y" />
53
+ <print>${f:x} ${field:x}</print>
54
+ </sequence>
55
+ </process-definition>''', 'y y')
56
+ end
57
+
58
+ def test_dollar_notation_2
59
+ dotest(
60
+ '''<process-definition name="n" revision="0">
61
+ <sequence>
62
+ <print>${f:x}X${field:x}</print>
63
+ </sequence>
64
+ </process-definition>''', 'X')
65
+ end
66
+
67
+ end
68
+
@@ -0,0 +1,36 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ class FlowTest0b < Test::Unit::TestCase
14
+ include FlowTestBase
15
+
16
+ #def setup
17
+ #end
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ def test_sequence
23
+ dotest(
24
+ '''
25
+ <process-definition name="n" revision="0">
26
+ <sequence>
27
+ <print>a</print>
28
+ <print>b</print>
29
+ </sequence>
30
+ </process-definition>
31
+ '''.strip,
32
+ "a\nb")
33
+ end
34
+
35
+ end
36
+
@@ -0,0 +1,33 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Dec 25 14:27:48 JST 2006
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ class TestTestName < Test::Unit::TestCase
14
+ include FlowTestBase
15
+
16
+ #def setup
17
+ #end
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ def test_name_of_test
23
+ dotest(
24
+ """
25
+ <process-definition name='#{name_of_test}' revision='0'>
26
+ <print>#{name_of_test}</print>
27
+ </process-definition>
28
+ """.strip,
29
+ "name_of_test")
30
+ end
31
+
32
+ end
33
+
@@ -0,0 +1,30 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ class FlowTest0d < Test::Unit::TestCase
14
+ include FlowTestBase
15
+
16
+ #def setup
17
+ #end
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ def test_participant
23
+ dotest(\
24
+ '''<process-definition name="n" revision="0">
25
+ <participant ref="test-alpha" />
26
+ </process-definition>''', "test-alpha")
27
+ end
28
+
29
+ end
30
+
@@ -0,0 +1,34 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Tue Nov 6 10:10:57 JST 2007
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ class FlowTest0e < Test::Unit::TestCase
14
+ include FlowTestBase
15
+
16
+ #def setup
17
+ #end
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ def test_multi_body
23
+
24
+ #log_level_to_debug
25
+
26
+ dotest(
27
+ '''<process-definition name="n" revision="0">
28
+ <print>ok</print>
29
+ <print>nok</print>
30
+ </process-definition>''', "ok")
31
+ end
32
+
33
+ end
34
+
@@ -0,0 +1,134 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Tue Jan 2 13:14:37 JST 2007
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ $s = (0..9).to_a.join("\n").strip
14
+
15
+
16
+ class FlowTest10 < Test::Unit::TestCase
17
+ include FlowTestBase
18
+
19
+ #def setup
20
+ #end
21
+
22
+ #def teardown
23
+ #end
24
+
25
+ def test_loop_0
26
+
27
+ #log_level_to_debug
28
+
29
+ dotest(
30
+ '<process-definition name="'+name_of_test+'''" revision="0">
31
+ <sequence>
32
+ <reval>$i = 0</reval>
33
+ <loop>
34
+ <print>${r:$i}</print>
35
+ <reval>$i = $i + 1</reval>
36
+ <if>
37
+ <equals value="${r:$i}" other-value="10" />
38
+ <break/>
39
+ </if>
40
+ </loop>
41
+ </sequence>
42
+ </process-definition>''',
43
+ $s)
44
+ end
45
+
46
+ def test_loop_1
47
+ dotest(
48
+ '<process-definition name="'+name_of_test+'''" revision="0">
49
+ <sequence>
50
+ <reval>$i = 0</reval>
51
+ <loop>
52
+ <print>${r:$i}</print>
53
+ <reval>$i = $i + 1</reval>
54
+ <if rtest="$i == 10">
55
+ <break/>
56
+ </if>
57
+ </loop>
58
+ </sequence>
59
+ </process-definition>''',
60
+ $s)
61
+ end
62
+
63
+ def test_loop_2
64
+ #log_level_to_debug
65
+ dotest(
66
+ '<process-definition name="'+name_of_test+'''" revision="0">
67
+ <sequence>
68
+ <reval>$i = 0</reval>
69
+ <loop>
70
+ <print>${r:$i}</print>
71
+ <reval>$i = $i + 1</reval>
72
+ <break if="${r:$i} == 10" />
73
+ </loop>
74
+ </sequence>
75
+ </process-definition>''',
76
+ $s)
77
+ end
78
+
79
+ def test_loop_3
80
+ dotest(
81
+ '<process-definition name="'+name_of_test+'''" revision="0">
82
+ <sequence>
83
+ <reval>$i = 0</reval>
84
+ <loop>
85
+ <print>${r:$i}</print>
86
+ <reval>$i = $i + 1</reval>
87
+ <break if="${r:$i == 10}" />
88
+ </loop>
89
+ </sequence>
90
+ </process-definition>''',
91
+ $s)
92
+ end
93
+
94
+ def test_loop_4
95
+ dotest(
96
+ '<process-definition name="'+name_of_test+'''" revision="0">
97
+ <sequence>
98
+ <reval>$i = 0</reval>
99
+ <loop>
100
+ <print>${r:$i}</print>
101
+ <reval>$i = $i + 1</reval>
102
+ <break rif="$i == 10" />
103
+ </loop>
104
+ </sequence>
105
+ </process-definition>''',
106
+ $s)
107
+ end
108
+
109
+ def test_loop_5
110
+
111
+ log_level_to_debug
112
+
113
+ dotest(
114
+ '<process-definition name="'+name_of_test+'''" revision="0">
115
+ <sequence>
116
+ <reval>$i = 0</reval>
117
+ <loop>
118
+ <!--
119
+ <reval>$i = $i + 1</reval>
120
+ <set field="f" value="${r:$i}" />
121
+ -->
122
+ <set field="f">
123
+ <reval>$i = $i + 1</reval>
124
+ </set>
125
+ <print>${r:$i}</print>
126
+ <break if="${f:f}" />
127
+ </loop>
128
+ </sequence>
129
+ </process-definition>''',
130
+ '1')
131
+ end
132
+
133
+ end
134
+
data/test/ft_11_ppd.rb ADDED
@@ -0,0 +1,415 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Tue Jan 2 13:14:37 JST 2007
8
+ #
9
+
10
+ require 'rubygems'
11
+
12
+ require 'flowtestbase'
13
+ require 'openwfe/def'
14
+
15
+
16
+ class FlowTest11 < Test::Unit::TestCase
17
+ include FlowTestBase
18
+
19
+ #def setup
20
+ #end
21
+
22
+ #def teardown
23
+ #end
24
+
25
+ #
26
+ # Test 0
27
+ #
28
+
29
+ class TestDefinition0 < OpenWFE::ProcessDefinition
30
+ def make
31
+ process_definition :name => "test0", :revision => "0" do
32
+ sequence do
33
+ _print do "a" end
34
+ _print { "b" }
35
+ _print "c"
36
+ #
37
+ # all these notations for nesting a string
38
+ # are allowed
39
+ #
40
+ # of course, the latter one is the nicest
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ def test_ppd_0
47
+
48
+ #log_level_to_debug
49
+
50
+ dotest TestDefinition0, "a\nb\nc"
51
+ end
52
+
53
+
54
+ #
55
+ # Test 1
56
+ #
57
+
58
+ class TestDefinition1 < OpenWFE::ProcessDefinition
59
+ def make
60
+ process_definition :name => "test1", :revision => "0" do
61
+ sequence do
62
+ set :variable => "toto", :value => "nada"
63
+ _print "toto:${toto}"
64
+ set :field => "ftoto" do
65
+ "_${toto}__${r:'123'.reverse}"
66
+ end
67
+ _print { "ftoto:${f:ftoto}" }
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ def test_ppd_1
74
+
75
+ dotest(
76
+ TestDefinition1,
77
+ """
78
+ toto:nada
79
+ ftoto:_nada__321
80
+ """.strip,
81
+ true)
82
+ end
83
+
84
+
85
+ #
86
+ # Test 2
87
+ #
88
+
89
+ class TestDefinition2 < OpenWFE::ProcessDefinition
90
+ def make
91
+ process_definition :name => "test2", :revision => "0" do
92
+ sequence do
93
+ set :variable => "toto", :value => "nada"
94
+ _if do
95
+ equals :variable_value => "toto", :other_value => "nada"
96
+ _print "toto:${toto}"
97
+ _print "not ok"
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ def test_ppd_2
105
+
106
+ dotest(
107
+ TestDefinition2,
108
+ "toto:nada")
109
+ #true)
110
+ end
111
+
112
+
113
+ #
114
+ # Test 3
115
+ #
116
+
117
+ class TestDefinition3 < OpenWFE::ProcessDefinition
118
+ def make
119
+ process_definition :name => "test3", :revision => "0" do
120
+ sequence do
121
+ subprocess :ref => "sub0", :var0 => "a"
122
+ sub0 :var0 => "b"
123
+ end
124
+ process_definition :name => "sub0" do
125
+ _print "var0 is '${var0}'"
126
+ end
127
+ end
128
+ end
129
+ end
130
+
131
+ def test_ppd_3
132
+
133
+ #puts
134
+ #puts TestDefinition3.do_make(ExpressionMap.new(nil, nil)).to_code_s
135
+ #puts
136
+ #puts TestDefinition3.do_make(ExpressionMap.new(nil, nil)).to_s
137
+
138
+ dotest TestDefinition3, "var0 is 'a'\nvar0 is 'b'"
139
+ end
140
+
141
+
142
+ #
143
+ # Test 4
144
+ #
145
+
146
+ class TestDefinition4 < OpenWFE::ProcessDefinition
147
+ def make
148
+ process_definition :name => "test4", :revision => "0" do
149
+ sequence do
150
+ sequence do
151
+ _print "a"
152
+ end
153
+ sequence do
154
+ _print "b"
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ CODE4 = """
162
+ process_definition :name => 'test4', :revision => '0' do
163
+ sequence do
164
+ sequence do
165
+ _print do
166
+ 'a'
167
+ end
168
+ end
169
+ sequence do
170
+ _print do
171
+ 'b'
172
+ end
173
+ end
174
+ end
175
+ end
176
+ """.strip
177
+
178
+ def test_ppd_4
179
+
180
+ s = OpenWFE::ExpressionTree.to_code_s TestDefinition4.do_make
181
+
182
+ dotest(
183
+ TestDefinition4,
184
+ "a\nb")
185
+ #0.300)
186
+
187
+ assert_equal CODE4, s, "nested sequences test failed (4)"
188
+ end
189
+
190
+
191
+ #
192
+ # Test 5
193
+ #
194
+
195
+ class TestDefinition5 < OpenWFE::ProcessDefinition
196
+ def make
197
+ process_definition :name => "test5", :revision => "0" do
198
+ sequence do
199
+ sequence do
200
+ _print { "a" }
201
+ end
202
+ sequence do
203
+ _print { "b" }
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
209
+
210
+ CODE5 = <<-EOS
211
+ process_definition :name => 'test5', :revision => '0' do
212
+ sequence do
213
+ sequence do
214
+ _print do
215
+ 'a'
216
+ end
217
+ end
218
+ sequence do
219
+ _print do
220
+ 'b'
221
+ end
222
+ end
223
+ end
224
+ end
225
+ EOS
226
+
227
+ def test_ppd_5
228
+
229
+ s = OpenWFE::ExpressionTree.to_code_s(TestDefinition5.do_make)
230
+
231
+ dotest TestDefinition5, "a\nb"
232
+
233
+ assert CODE5, s
234
+ end
235
+
236
+
237
+ #
238
+ # Test 6
239
+ #
240
+
241
+ class TestDefinition6 < OpenWFE::ProcessDefinition
242
+
243
+ def initialize (count)
244
+ super()
245
+ @count = count
246
+ end
247
+
248
+ def make
249
+ process_definition :name => "test6", :revision => "0" do
250
+ sequence do
251
+ @count.times do |i|
252
+ _print i
253
+ end
254
+ end
255
+ end
256
+ end
257
+ end
258
+
259
+ def test_ppd_6
260
+
261
+ dotest(
262
+ TestDefinition6.new(3),
263
+ %w{ 0 1 2 }.join("\n"))
264
+ end
265
+
266
+
267
+ #
268
+ # Test 7
269
+ #
270
+
271
+ class TestDefinition7 < OpenWFE::ProcessDefinition
272
+ def make
273
+ _process_definition :name => "test7", :revision => "0" do
274
+ _sequence do
275
+ _print "a"
276
+ _print "b"
277
+ end
278
+ end
279
+ end
280
+ end
281
+
282
+ def test_ppd_7
283
+
284
+ dotest(
285
+ TestDefinition7,
286
+ %w{ a b }.join("\n"))
287
+ end
288
+
289
+
290
+ #
291
+ # Test 8
292
+ #
293
+
294
+ class TestDefinition8 < OpenWFE::ProcessDefinition
295
+ def make
296
+ process_definition :name => "test8", :revision => "0" do
297
+ toto
298
+ process_definition :name => "toto" do
299
+ _print "toto"
300
+ end
301
+ end
302
+ end
303
+ end
304
+
305
+ def test_ppd_8
306
+
307
+ dotest TestDefinition8, "toto"
308
+ end
309
+
310
+
311
+ #
312
+ # Test 9
313
+ #
314
+
315
+ class TestDefinition9 < OpenWFE::ProcessDefinition
316
+ def make
317
+ process_definition :name => "test9", :revision => "0" do
318
+ _toto
319
+ process_definition :name => "toto" do
320
+ _print "toto"
321
+ end
322
+ end
323
+ end
324
+ end
325
+
326
+ def test_ppd_9
327
+
328
+ dotest TestDefinition9, "toto"
329
+ end
330
+
331
+
332
+ #
333
+ # Test 10
334
+ #
335
+
336
+ class TestDefinition10 < OpenWFE::ProcessDefinition
337
+ def make
338
+ process_definition :name => "test10", :revision => "0" do
339
+ sequence do
340
+ participant :ref => "toto_underscore"
341
+ _toto_underscore
342
+ toto_underscore
343
+ end
344
+ end
345
+ end
346
+ end
347
+
348
+ def test_ppd_10
349
+
350
+ @engine.register_participant(:toto_underscore) do |workitem|
351
+ @tracer << "toto\n"
352
+ end
353
+
354
+ dotest TestDefinition10, ([ 'toto' ] * 3).join("\n")
355
+ end
356
+
357
+
358
+ #
359
+ # Test 11
360
+ #
361
+
362
+ class TestDefinition11 < OpenWFE::ProcessDefinition
363
+ def make
364
+ sequence do
365
+ [ :b, :b, :b ].each do |p|
366
+ participant p
367
+ end
368
+ participant "b"
369
+ end
370
+ end
371
+ end
372
+
373
+ def test_ppd_11
374
+
375
+ @engine.register_participant(:b) do |workitem|
376
+ @tracer << "b\n"
377
+ end
378
+
379
+ dotest TestDefinition11, ([ 'b' ] * 4).join("\n")
380
+ end
381
+
382
+ #
383
+ # Test 12
384
+ #
385
+
386
+ class TestDefinition12 < OpenWFE::ProcessDefinition
387
+ sequence do
388
+ _print "main"
389
+ sub_x
390
+ end
391
+ process_definition :name => "sub-x" do
392
+ _print "sub"
393
+ end
394
+ end
395
+
396
+ def test_prog_12
397
+
398
+ dotest TestDefinition12, "main\nsub"
399
+ end
400
+
401
+
402
+ #
403
+ # Test 13
404
+ #
405
+
406
+ class TestDefinition13 < OpenWFE::ProcessDefinition
407
+ end
408
+
409
+ def _test_prog_13
410
+
411
+ dotest TestDefinition13, ""
412
+ end
413
+
414
+ end
415
+