openwferu 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/examples/about_state.rb +81 -0
  2. data/examples/engine_template.rb +7 -0
  3. data/lib/openwfe/contextual.rb +2 -2
  4. data/lib/openwfe/def.rb +2 -3
  5. data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
  6. data/lib/openwfe/engine/engine.rb +202 -251
  7. data/lib/openwfe/engine/process_status.rb +359 -0
  8. data/lib/openwfe/expool/errorjournal.rb +6 -6
  9. data/lib/openwfe/expool/expressionpool.rb +161 -239
  10. data/lib/openwfe/expool/expstorage.rb +185 -55
  11. data/lib/openwfe/expool/journal.rb +1 -2
  12. data/lib/openwfe/expool/parser.rb +233 -0
  13. data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
  14. data/lib/openwfe/expool/wfidgen.rb +25 -7
  15. data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
  16. data/lib/openwfe/expressions/condition.rb +49 -12
  17. data/lib/openwfe/expressions/environment.rb +45 -15
  18. data/lib/openwfe/expressions/expressionmap.rb +39 -19
  19. data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
  20. data/lib/openwfe/expressions/fe_cron.rb +19 -18
  21. data/lib/openwfe/expressions/fe_cursor.rb +69 -28
  22. data/lib/openwfe/expressions/fe_define.rb +4 -1
  23. data/lib/openwfe/expressions/fe_do.rb +1 -3
  24. data/lib/openwfe/expressions/fe_equals.rb +131 -20
  25. data/lib/openwfe/expressions/fe_fqv.rb +27 -3
  26. data/lib/openwfe/expressions/fe_iterator.rb +14 -7
  27. data/lib/openwfe/expressions/fe_listen.rb +7 -2
  28. data/lib/openwfe/expressions/fe_misc.rb +187 -20
  29. data/lib/openwfe/expressions/fe_participant.rb +8 -7
  30. data/lib/openwfe/expressions/fe_reserve.rb +105 -33
  31. data/lib/openwfe/expressions/fe_save.rb +55 -5
  32. data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
  33. data/lib/openwfe/expressions/fe_sleep.rb +25 -15
  34. data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
  35. data/lib/openwfe/expressions/fe_wait.rb +3 -2
  36. data/lib/openwfe/expressions/fe_when.rb +7 -15
  37. data/lib/openwfe/expressions/flowexpression.rb +90 -49
  38. data/lib/openwfe/expressions/merge.rb +7 -1
  39. data/lib/openwfe/expressions/raw.rb +261 -63
  40. data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
  41. data/lib/openwfe/expressions/time.rb +36 -12
  42. data/lib/openwfe/expressions/timeout.rb +9 -7
  43. data/lib/openwfe/expressions/value.rb +126 -0
  44. data/lib/openwfe/flowexpressionid.rb +52 -22
  45. data/lib/openwfe/listeners/listeners.rb +3 -3
  46. data/lib/openwfe/listeners/socketlisteners.rb +8 -5
  47. data/lib/openwfe/logging.rb +6 -3
  48. data/lib/openwfe/omixins.rb +8 -6
  49. data/lib/openwfe/orest/xmlcodec.rb +16 -12
  50. data/lib/openwfe/participants.rb +38 -0
  51. data/lib/openwfe/participants/participant.rb +1 -1
  52. data/lib/openwfe/participants/participantmap.rb +24 -10
  53. data/lib/openwfe/participants/participants.rb +4 -3
  54. data/lib/openwfe/participants/soapparticipants.rb +1 -1
  55. data/lib/openwfe/participants/socketparticipants.rb +1 -1
  56. data/lib/openwfe/rudefinitions.rb +7 -5
  57. data/lib/openwfe/storage/yamlcustom.rb +10 -10
  58. data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
  59. data/lib/openwfe/tools/flowtracer.rb +6 -5
  60. data/lib/openwfe/util/dollar.rb +42 -85
  61. data/lib/openwfe/util/ometa.rb +1 -3
  62. data/lib/openwfe/util/workqueue.rb +1 -1
  63. data/lib/openwfe/utils.rb +33 -11
  64. data/lib/openwfe/version.rb +2 -2
  65. data/lib/openwfe/workitem.rb +76 -14
  66. data/lib/openwfe/worklist/storelocks.rb +9 -4
  67. data/lib/openwfe/worklist/storeparticipant.rb +1 -1
  68. data/test/back_0916_test.rb +101 -0
  69. data/test/bm/ft_26_load.rb +1 -1
  70. data/test/bm/ft_26b_load.rb +1 -1
  71. data/test/bm/ft_26c_load.rb +3 -2
  72. data/test/bm/ft_26d_load.rb +97 -0
  73. data/test/bm/ft_recu.rb +71 -0
  74. data/test/concurrence_test.rb +1 -1
  75. data/test/condition_test.rb +152 -0
  76. data/test/description_test.rb +12 -7
  77. data/test/eno_test.rb +1 -1
  78. data/test/expool_20031219_0916.tgz +0 -0
  79. data/test/fe_lookup_att_test.rb +1 -1
  80. data/test/fei_test.rb +16 -0
  81. data/test/file_persistence_test.rb +8 -12
  82. data/test/filep_cancel_test.rb +116 -0
  83. data/test/flowtestbase.rb +47 -25
  84. data/test/ft_0.rb +1 -1
  85. data/test/ft_10_loop.rb +29 -14
  86. data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
  87. data/test/ft_11_ppd.rb +6 -17
  88. data/test/ft_11b_ppd.rb +1 -4
  89. data/test/ft_12_blockparticipant.rb +1 -1
  90. data/test/ft_13_eno.rb +1 -1
  91. data/test/ft_15_iterator.rb +1 -1
  92. data/test/ft_15b_iterator.rb +1 -1
  93. data/test/ft_17_condition.rb +6 -6
  94. data/test/ft_18_pname.rb +1 -1
  95. data/test/ft_20_cron.rb +1 -1
  96. data/test/ft_21_cron.rb +6 -4
  97. data/test/ft_22_history.rb +1 -1
  98. data/test/ft_23_when.rb +1 -1
  99. data/test/ft_23b_when.rb +18 -6
  100. data/test/ft_23c_wait.rb +8 -6
  101. data/test/ft_25_cancel.rb +7 -5
  102. data/test/ft_27_getflowpos.rb +22 -17
  103. data/test/ft_28_fileparticipant.rb +1 -2
  104. data/test/ft_2_concurrence.rb +1 -1
  105. data/test/ft_2b_concurrence.rb +25 -20
  106. data/test/ft_30_socketlistener.rb +0 -3
  107. data/test/ft_34_cancelwfid.rb +9 -9
  108. data/test/ft_35_localdefs.rb +0 -1
  109. data/test/ft_36_subprocids.rb +6 -6
  110. data/test/ft_38_tag.rb +3 -2
  111. data/test/ft_38b_tag.rb +229 -0
  112. data/test/ft_39_reserve.rb +3 -18
  113. data/test/ft_39b_reserve.rb +34 -5
  114. data/test/ft_3b_lookup_vf.rb +83 -0
  115. data/test/ft_40_defined.rb +2 -11
  116. data/test/ft_42_environments.rb +4 -6
  117. data/test/ft_44b_restore.rb +88 -22
  118. data/test/ft_45_citerator.rb +57 -11
  119. data/test/ft_49_condition.rb +4 -2
  120. data/test/ft_4_misc.rb +24 -3
  121. data/test/ft_50_xml_attribute.rb +17 -20
  122. data/test/ft_54_listen.rb +1 -1
  123. data/test/ft_54b_listen.rb +2 -2
  124. data/test/ft_56_timeout.rb +8 -1
  125. data/test/ft_57_a.rb +10 -10
  126. data/test/ft_59_ps.rb +49 -16
  127. data/test/ft_60_ecancel.rb +52 -10
  128. data/test/ft_63_pause.rb +8 -8
  129. data/test/ft_65_stringlaunch.rb +4 -6
  130. data/test/ft_67_schedlaunch.rb +4 -4
  131. data/test/ft_69_cancelmissing.rb +4 -2
  132. data/test/ft_70_lookupvar.rb +2 -2
  133. data/test/ft_72_lookup_processes.rb +2 -2
  134. data/test/ft_73_cancel_sub.rb +8 -8
  135. data/test/ft_77_segments.rb +38 -0
  136. data/test/ft_78_eval.rb +154 -0
  137. data/test/ft_79_tticket.rb +185 -0
  138. data/test/ft_80_spname.rb +95 -0
  139. data/test/ft_81_exp.rb +64 -0
  140. data/test/ft_82_trecu.rb +48 -0
  141. data/test/ft_83_badpause.rb +62 -0
  142. data/test/ft_84_updateexp.rb +125 -0
  143. data/test/ft_9b_cursor.rb +105 -0
  144. data/test/ft_tests.rb +14 -1
  145. data/test/hash_test.rb +7 -7
  146. data/test/hparticipant_test.rb +4 -4
  147. data/test/lookup_vf_test.rb +94 -0
  148. data/test/misc_test.rb +5 -3
  149. data/test/orest_test.rb +4 -3
  150. data/test/param_test.rb +12 -16
  151. data/test/participant_test.rb +36 -0
  152. data/test/pending.rb +10 -10
  153. data/test/rake_ltest.rb +1 -10
  154. data/test/rake_qtest.rb +7 -6
  155. data/test/raw_prog_test.rb +89 -121
  156. data/test/restart_cron_test.rb +84 -36
  157. data/test/restart_paused_test.rb +100 -0
  158. data/test/restart_sleep_test.rb +1 -1
  159. data/test/restart_tests.rb +1 -0
  160. data/test/restart_when_test.rb +33 -22
  161. data/test/ruby_procdef_test.rb +19 -18
  162. data/test/sec_test.rb +74 -35
  163. data/test/storage_test.rb +44 -0
  164. data/test/test.rb +3 -0
  165. data/test/timeout_test.rb +7 -18
  166. data/test/wfid_test.rb +2 -1
  167. data/test/wi_test.rb +29 -18
  168. metadata +121 -57
  169. data/lib/openwfe/expressions/raw_xml.rb +0 -176
  170. data/lib/openwfe/expressions/simplerep.rb +0 -266
  171. data/lib/openwfe/util/kotoba.rb +0 -236
  172. data/lib/openwfe/util/lru.rb +0 -171
  173. data/lib/openwfe/util/otime.rb +0 -246
  174. data/lib/openwfe/util/safe.rb +0 -160
  175. data/lib/openwfe/util/scheduler.rb +0 -1158
  176. data/test/cron_test.rb +0 -113
  177. data/test/cronline_test.rb +0 -60
  178. data/test/dollar_test.rb +0 -90
  179. data/test/kotoba_test.rb +0 -72
  180. data/test/lru_test.rb +0 -79
  181. data/test/safely_test.rb +0 -84
  182. data/test/scheduler_1_test.rb +0 -88
  183. data/test/scheduler_test.rb +0 -363
  184. data/test/time_test.rb +0 -84
@@ -33,7 +33,6 @@ class FlowTest63 < Test::Unit::TestCase
33
33
  end
34
34
  end
35
35
 
36
- #def xxxx_0
37
36
  def test_0
38
37
 
39
38
  #log_level_to_debug
@@ -42,7 +41,7 @@ class FlowTest63 < Test::Unit::TestCase
42
41
 
43
42
  fei = @engine.launch Test0
44
43
 
45
- sleep 0.200
44
+ sleep 0.350
46
45
 
47
46
  assert_equal(
48
47
  @engine.process_status(fei.wfid).expressions[0].fei.wfid,
@@ -51,16 +50,18 @@ class FlowTest63 < Test::Unit::TestCase
51
50
  #puts @engine.list_process_status
52
51
 
53
52
  assert ! @engine.process_status(fei.wfid).paused?
53
+ assert ! @engine.is_paused?(fei.wfid)
54
54
 
55
55
  @engine.pause_process fei.workflow_instance_id
56
56
 
57
57
  assert @engine.process_status(fei.wfid).paused?
58
+ assert @engine.is_paused?(fei.wfid)
58
59
 
59
60
  hp = @engine.get_participant :alpha
60
61
  wi = hp.first_workitem
61
62
  hp.forward wi
62
63
 
63
- sleep 0.200
64
+ sleep 0.350
64
65
 
65
66
  assert_equal @engine.process_status(fei.wfid).errors.size, 1
66
67
  assert_equal @tracer.to_s, ""
@@ -72,7 +73,7 @@ class FlowTest63 < Test::Unit::TestCase
72
73
  assert_equal ps.errors.size, 0
73
74
  assert ! ps.paused?
74
75
 
75
- sleep 0.200
76
+ sleep 0.350
76
77
 
77
78
  assert_nil @engine.process_status(fei.wfid)
78
79
  assert_equal @tracer.to_s, "done."
@@ -90,7 +91,6 @@ class FlowTest63 < Test::Unit::TestCase
90
91
  end
91
92
  end
92
93
 
93
- #def xxxx_1
94
94
  def test_1
95
95
 
96
96
  #log_level_to_debug
@@ -99,13 +99,13 @@ class FlowTest63 < Test::Unit::TestCase
99
99
 
100
100
  fei = @engine.launch Test1
101
101
 
102
- sleep 0.200
102
+ sleep 0.350
103
103
 
104
104
  assert ! @engine.process_status(fei.wfid).paused?
105
105
 
106
106
  @engine.pause_process fei.wfid
107
107
 
108
- sleep 0.200
108
+ sleep 0.350
109
109
 
110
110
  assert @engine.process_status(fei.wfid).paused?
111
111
 
@@ -115,7 +115,7 @@ class FlowTest63 < Test::Unit::TestCase
115
115
 
116
116
  @engine.cancel_process fei.wfid
117
117
 
118
- sleep 0.200
118
+ sleep 0.350
119
119
  end
120
120
 
121
121
  end
@@ -31,10 +31,9 @@ class FlowTest65 < Test::Unit::TestCase
31
31
  end
32
32
  """.strip
33
33
 
34
- #def xxxx_0
35
34
  def test_0
36
- @engine.launch(TEST0)
37
- sleep 0.200
35
+ @engine.launch TEST0
36
+ sleep 0.350
38
37
  assert_equal @tracer.to_s, "ok."
39
38
  end
40
39
 
@@ -49,11 +48,10 @@ class FlowTest65 < Test::Unit::TestCase
49
48
  </process-definition>
50
49
  """.strip
51
50
 
52
- #def xxxx_1
53
51
  def test_1
54
52
 
55
- @engine.launch(TEST1)
56
- sleep 0.200
53
+ @engine.launch TEST1
54
+ sleep 0.350
57
55
  assert_equal @tracer.to_s, "ok."
58
56
  end
59
57
 
@@ -34,7 +34,7 @@ class FlowTest67 < Test::Unit::TestCase
34
34
 
35
35
  @engine.launch Test0, :in => "2s"
36
36
 
37
- sleep 0.200
37
+ sleep 0.400
38
38
 
39
39
  assert_equal(
40
40
  1,
@@ -58,7 +58,7 @@ class FlowTest67 < Test::Unit::TestCase
58
58
 
59
59
  @engine.launch Test0, :at => (t + 2).to_s
60
60
 
61
- sleep 0.200
61
+ sleep 0.400
62
62
 
63
63
  assert_equal(
64
64
  1,
@@ -82,7 +82,7 @@ class FlowTest67 < Test::Unit::TestCase
82
82
 
83
83
  assert_trace ""
84
84
 
85
- sleep 130
85
+ sleep 121
86
86
 
87
87
  assert_trace "hell0\nhell0"
88
88
 
@@ -96,7 +96,7 @@ class FlowTest67 < Test::Unit::TestCase
96
96
 
97
97
  def test_3
98
98
 
99
- log_level_to_debug
99
+ #log_level_to_debug
100
100
 
101
101
  @engine.launch Test0, :every => "2s"
102
102
 
@@ -35,14 +35,16 @@ class FlowTest69 < Test::Unit::TestCase
35
35
 
36
36
  fei = @engine.launch(Test0)
37
37
 
38
- sleep 0.300
38
+ sleep 0.350
39
39
 
40
40
  assert @engine.process_status(fei.wfid).errors.size > 0
41
41
 
42
42
  @engine.cancel_process fei
43
43
 
44
+ sleep 0.100
45
+
44
46
  assert_nil @engine.process_status(fei.wfid)
45
- assert_equal @engine.list_process_status, {}
47
+ assert_equal ({}), @engine.list_process_status
46
48
  end
47
49
 
48
50
  end
@@ -40,7 +40,7 @@ class FlowTest70 < Test::Unit::TestCase
40
40
 
41
41
  fei = @engine.launch(Test0)
42
42
 
43
- sleep 0.200
43
+ sleep 0.350
44
44
 
45
45
  assert_equal @engine.lookup_variable("topvar"), "top"
46
46
  assert_equal @engine.lookup_variable("topvar", fei.wfid), "top"
@@ -48,7 +48,7 @@ class FlowTest70 < Test::Unit::TestCase
48
48
 
49
49
  @engine.cancel_process(fei.wfid)
50
50
 
51
- sleep 0.200
51
+ sleep 0.350
52
52
  end
53
53
 
54
54
  end
@@ -48,7 +48,7 @@ class FlowTest72 < Test::Unit::TestCase
48
48
  li.toto = 'toto_one'
49
49
  fei1 = @engine.launch li
50
50
 
51
- sleep 0.300
51
+ sleep 0.350
52
52
 
53
53
  wfids = @engine.lookup_processes('nada')
54
54
  assert_equal 0, wfids.size
@@ -72,7 +72,7 @@ class FlowTest72 < Test::Unit::TestCase
72
72
  @engine.cancel_process fei0
73
73
  @engine.cancel_process fei1
74
74
 
75
- sleep 0.300
75
+ sleep 0.350
76
76
  end
77
77
 
78
78
  end
@@ -44,7 +44,7 @@ class FlowTest73 < Test::Unit::TestCase
44
44
  fei = @engine.launch Test0
45
45
  #puts "launched : " + fei.to_s
46
46
 
47
- sleep 0.300
47
+ sleep 0.350
48
48
 
49
49
  assert_equal 1, p0.size
50
50
  #puts "in store : " + p0.first_workitem.fei.to_s
@@ -54,7 +54,7 @@ class FlowTest73 < Test::Unit::TestCase
54
54
 
55
55
  @engine.cancel_process fei
56
56
 
57
- sleep 0.300
57
+ sleep 0.350
58
58
 
59
59
  assert_equal 0, p0.size
60
60
  end
@@ -84,7 +84,7 @@ class FlowTest73 < Test::Unit::TestCase
84
84
  #puts
85
85
  #puts "launched : " + fei.to_s
86
86
 
87
- sleep 0.300
87
+ sleep 0.350
88
88
 
89
89
  assert_equal 1, p1.size
90
90
  #puts "in store : " + p1.first_workitem.fei.to_s
@@ -92,13 +92,13 @@ class FlowTest73 < Test::Unit::TestCase
92
92
  wi = p1.first_workitem
93
93
  assert_equal wi.fei.wfid, fei.wfid + ".0"
94
94
 
95
- @engine.cancel_process fei
95
+ @engine.cancel_process(fei)
96
96
 
97
- sleep 0.300
97
+ sleep 0.350
98
98
 
99
99
  assert_equal 1, p1.size
100
100
 
101
- @engine.cancel_process p1.first_workitem.fei
101
+ @engine.cancel_process(p1.first_workitem.fei)
102
102
 
103
103
  sleep 0.400
104
104
 
@@ -135,9 +135,9 @@ class FlowTest73 < Test::Unit::TestCase
135
135
  assert_equal 1, p20.size
136
136
 
137
137
  @engine.cancel_process p20.first_workitem.fei
138
- sleep 0.300
138
+ sleep 0.350
139
139
  @engine.cancel_process p2.first_workitem.fei
140
- sleep 0.300
140
+ sleep 0.350
141
141
  end
142
142
 
143
143
  end
@@ -0,0 +1,38 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'flowtestbase'
9
+ #require 'openwfe/def'
10
+ #require 'openwfe/worklist/storeparticipant'
11
+
12
+ include OpenWFE
13
+
14
+
15
+ class FlowTest77 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def setup
19
+ #end
20
+
21
+ #def teardown
22
+ #end
23
+
24
+ TEST0 = "<print>nada</print>"
25
+
26
+ def test_0
27
+ dotest TEST0, "nada"
28
+ end
29
+
30
+
31
+ TEST1 = "_print 'nada'"
32
+
33
+ def test_1
34
+ dotest TEST1, "nada"
35
+ end
36
+
37
+ end
38
+
@@ -0,0 +1,154 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Tue Nov 20 21:46:30 JST 2007
8
+ #
9
+
10
+ require 'flowtestbase'
11
+ #require 'openwfe/def'
12
+ #require 'openwfe/worklist/storeparticipant'
13
+
14
+ include OpenWFE
15
+
16
+
17
+ class FlowTest78 < Test::Unit::TestCase
18
+ include FlowTestBase
19
+
20
+ #def setup
21
+ #end
22
+
23
+ #def teardown
24
+ #end
25
+
26
+ #
27
+ # TEST 0
28
+ #
29
+
30
+ TEST0 = %{
31
+ <sequence>
32
+ <print>0</print>
33
+ <eval>
34
+ <![CDATA[
35
+ <print>1</print>
36
+ ]]>
37
+ </eval>
38
+ <print>2</print>
39
+ </sequence>
40
+ }.strip
41
+
42
+ def test_0
43
+
44
+ @engine.ac[:dynamic_eval_allowed] = true
45
+
46
+ dotest TEST0, "0\n1\n2"
47
+ end
48
+
49
+ #
50
+ # TEST 1
51
+ #
52
+
53
+ class Test1 < ProcessDefinition
54
+ sequence do
55
+
56
+ set :var => "v0", :val => "val0"
57
+
58
+ set :field => "code", :value => "<print>hello 0</print>"
59
+ _eval :field_def => "code"
60
+ set :field => "code", :value => "_print 'hello 1'"
61
+ _eval :field_def => "code"
62
+ set :variable => "code", :value => "_print 'hello 1'"
63
+ _eval :variable_def => "code"
64
+
65
+ set :field => "code", :value => "_print '${v0}'"
66
+ _eval :field_def => "code"
67
+
68
+ set :field => "code", :value => "_print '${v0}'", :escape => true
69
+ set :var => "v0", :val => "val0b"
70
+ _eval :field_def => "code"
71
+ end
72
+ end
73
+
74
+ def test_1
75
+
76
+ @engine.ac[:dynamic_eval_allowed] = true
77
+
78
+ dotest Test1, "hello 0\nhello 1\nhello 1\nval0\nval0b"
79
+ end
80
+
81
+
82
+ #
83
+ # TEST 2
84
+ #
85
+
86
+ class Test2 < ProcessDefinition
87
+ sequence do
88
+ _eval ""
89
+ _print "ok"
90
+ end
91
+ end
92
+
93
+ def test_2
94
+
95
+ @engine.ac[:dynamic_eval_allowed] = true
96
+
97
+ dotest Test2, "ok"
98
+ end
99
+
100
+
101
+ #
102
+ # TEST 3
103
+ #
104
+
105
+ class Test3 < ProcessDefinition
106
+ sequence do
107
+ _eval "launcher"
108
+ _print "ok"
109
+ end
110
+ end
111
+
112
+ def test_3
113
+
114
+ @engine.ac[:dynamic_eval_allowed] = true
115
+
116
+ @engine.register_participant :launcher do |fexp, wi|
117
+ @tracer << "launcher\n"
118
+ #puts fexp.get_expression_storage.to_s
119
+ end
120
+
121
+ dotest Test3, "launcher\nok"
122
+ end
123
+
124
+
125
+ #
126
+ # TEST 4
127
+ #
128
+
129
+ class Test4 < ProcessDefinition
130
+ _loop do
131
+ _print "before"
132
+ _eval :def => "launcher"
133
+ #launcher
134
+ _print "after"
135
+ _break
136
+ end
137
+ end
138
+
139
+ def test_4
140
+
141
+ @engine.ac[:dynamic_eval_allowed] = true
142
+
143
+ @engine.register_participant :launcher do |fexp, wi|
144
+ @tracer << "launcher\n"
145
+ #@tracer << "#{fexp.get_expression_storage.size}\n"
146
+ #puts fexp.get_expression_storage.to_s
147
+ #puts fexp.to_s
148
+ end
149
+
150
+ dotest Test4, "before\nlauncher\nafter"
151
+ end
152
+
153
+ end
154
+
@@ -0,0 +1,185 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Thu Jan 3 23:05:37 JST 2008
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ #
14
+ # The process definition under test
15
+ #
16
+ class TroubleTicket01 < OpenWFE::ProcessDefinition
17
+
18
+ #
19
+ # The root of the process
20
+ #
21
+ sequence do
22
+
23
+ #
24
+ # the first activity, customer support
25
+ #
26
+ cs :activity => "enter details"
27
+
28
+ #
29
+ # initiating the first step
30
+ #
31
+ step :part => "qa", :desc => "reproduce problem"
32
+ end
33
+
34
+ #
35
+ # At the core of the process,
36
+ # the 'step' subprocess
37
+ #
38
+ process_definition :name => "step" do
39
+ sequence do
40
+
41
+ # participant performs activity
42
+ participant(
43
+ :ref => "${part}", :activity => "${desc}")
44
+
45
+ # then, call next step (via a subprocess)
46
+ subprocess :ref => "${f:next}"
47
+
48
+ end
49
+ end
50
+
51
+ #
52
+ # The 'outputs' of the activities
53
+ #
54
+
55
+ # QA 'reproduce problem' outputs
56
+
57
+ process_definition :name => "out:cannot_reproduce" do
58
+ step :part => "cs", :desc => "correct report"
59
+ end
60
+ process_definition :name => "out:known_solution" do
61
+ finalsteps
62
+ end
63
+ process_definition :name => "out:duplicate" do
64
+ step :part => "qa", :desc => "verify"
65
+ end
66
+ process_definition :name => "out:reproduced" do
67
+ step :part => "dev", :desc => "resolution"
68
+ end
69
+
70
+ # Customer Support 'correct report' outputs
71
+
72
+ process_definition :name => "out:submit" do
73
+ step :part => "qa", :desc => "reproduce problem"
74
+ end
75
+ process_definition :name => "out:give_up" do
76
+ finalsteps
77
+ end
78
+
79
+ # QA 'verify' outputs
80
+
81
+ process_definition :name => "out:qa_fixed" do
82
+ finalsteps
83
+ end
84
+ process_definition :name => "out:not_fixed" do
85
+ step :part => "dev", :desc => "resolution"
86
+ end
87
+
88
+ # dev 'resolution' outputs
89
+
90
+ process_definition :name => "out:dev_fixed" do
91
+ step :part => "qa", :desc => "verify"
92
+ end
93
+
94
+ set :var => "out:not_a_bug", :variable_value => "out:dev_fixed"
95
+ # "not_a_bug" is an alias to "dev_fixed"
96
+
97
+ # the final steps
98
+
99
+ process_definition :name => "finalsteps" do
100
+ concurrence do
101
+ cs :activity => "communicate results"
102
+ qa :activity => "audit"
103
+ end
104
+ end
105
+
106
+ end
107
+
108
+
109
+
110
+ class FlowTest79 < Test::Unit::TestCase
111
+ include FlowTestBase
112
+
113
+ def test_0
114
+
115
+ dotest(
116
+ [ "", "known_solution" ], # path
117
+ [ "cs", "qa", "cs", "qa" ]) # expected trace
118
+ end
119
+
120
+ def test_1
121
+
122
+ dotest(
123
+ [ "", "cannot_reproduce", "give_up" ], # path
124
+ [ "cs", "qa", "cs", "cs", "qa" ]) # expected trace
125
+ end
126
+
127
+ def test_2
128
+
129
+ dotest(
130
+ [ "", "reproduced", "dev_fixed", "qa_fixed" ], # path
131
+ [ "cs", "qa", "dev", "qa", "cs", "qa" ]) # expected trace
132
+ end
133
+
134
+ def test_3
135
+
136
+ dotest(
137
+ [ "", "reproduced", "not_a_bug", "qa_fixed" ], # path
138
+ [ "cs", "qa", "dev", "qa", "cs", "qa" ]) # expected trace
139
+ end
140
+
141
+ class TestParticipant
142
+ include LocalParticipant
143
+
144
+ attr_reader :trace
145
+
146
+ def initialize (path)
147
+
148
+ @path = path
149
+ @trace = []
150
+ end
151
+
152
+ def consume (workitem)
153
+
154
+ @trace << workitem.participant_name
155
+ # Kilroy was here
156
+
157
+ workitem.next = "out:#{@path.delete_at(0)}" if @path.size > 0
158
+ # stating what should happen next (activity conclusion)
159
+
160
+ reply_to_engine workitem
161
+ # handing back the workitem to the engine
162
+ # (please resume the process)
163
+ end
164
+ end
165
+
166
+ def dotest (path, expected_trace)
167
+
168
+ p = TestParticipant.new path
169
+
170
+ @engine.register_participant :cs, p
171
+ @engine.register_participant :qa, p
172
+ @engine.register_participant :dev, p
173
+
174
+ fei = @engine.launch TroubleTicket01
175
+
176
+ @engine.wait_for fei
177
+
178
+ assert_equal expected_trace, p.trace
179
+
180
+ assert(
181
+ (@engine.process_status(fei) == nil),
182
+ "process not over, check the [error] log")
183
+ end
184
+ end
185
+