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
@@ -6,30 +6,31 @@
6
6
  # Mon Oct 9 22:19:44 JST 2006
7
7
  #
8
8
 
9
+ require 'rubygems'
10
+
11
+
9
12
  require 'fei_test'
10
13
  require 'wfid_test'
11
14
  require 'wi_test'
12
15
  require 'lookup_att_test'
13
16
  require 'filter_test'
14
- require 'dollar_test'
15
17
  require 'misc_test'
18
+ require 'condition_test'
16
19
  require 'hash_test'
17
- require 'lru_test'
18
- require 'time_test'
19
20
  require 'raw_prog_test'
20
21
  require 'file_persistence_test'
21
- require 'cronline_test'
22
- require 'safely_test'
23
- require 'kotoba_test'
24
22
  require 'expmap_test'
25
23
  require 'obs_test'
26
24
  require 'clone_test'
25
+ require 'lookup_vf_test'
27
26
  require 'fe_lookup_att_test'
28
27
 
29
28
  require 'sec_test'
30
29
  require 'param_test'
31
30
 
31
+ require 'storage_test'
32
32
  require 'file_persisted_engine_test'
33
+ require 'filep_cancel_test'
33
34
  require 'ruby_procdef_test'
34
35
  require 'description_test'
35
36
 
@@ -8,27 +8,25 @@
8
8
  #
9
9
 
10
10
  require 'test/unit'
11
- require 'openwfe/expressions/raw_prog'
11
+ require 'openwfe/def'
12
+ require 'openwfe/expool/parser'
12
13
 
13
14
 
14
15
  class RawProgTest < Test::Unit::TestCase
15
16
 
16
- DEBUG = false
17
-
18
17
  #def setup
19
18
  #end
20
19
 
21
20
  #def teardown
22
21
  #end
23
22
 
24
- XML_DEF = """
25
- <process-definition name='test0' revision='0'>
26
- <sequence>
27
- <participant ref='a'/>
28
- <participant ref='b'/>
29
- </sequence>
30
- </process-definition>""".strip
31
-
23
+ XML_DEF =
24
+ "<process-definition name='test0' revision='0'>"+
25
+ "<sequence>"+
26
+ "<participant ref='a'/>"+
27
+ "<participant ref='b'/>"+
28
+ "</sequence>"+
29
+ "</process-definition>"
32
30
 
33
31
  #
34
32
  # TEST 0
@@ -47,24 +45,17 @@ class RawProgTest < Test::Unit::TestCase
47
45
 
48
46
  def test_prog_0
49
47
 
50
- s = TestDefinition.new().make.to_s
48
+ s = OpenWFE::ExpressionTree.to_s(TestDefinition.new.make)
51
49
 
52
- puts s if DEBUG
53
-
54
- assert \
55
- s == XML_DEF,
56
- "parsing failed (0)"
50
+ assert_equal XML_DEF, s
57
51
  end
58
52
 
59
53
  def test_prog_0b
60
54
 
61
- s = TestDefinition.do_make.to_s
62
-
63
- puts s if DEBUG
55
+ #s = TestDefinition.do_make.to_s
56
+ s = OpenWFE::ExpressionTree.to_s(TestDefinition.do_make)
64
57
 
65
- assert \
66
- s == XML_DEF,
67
- "parsing failed (0b)"
58
+ assert_equal XML_DEF, s
68
59
  end
69
60
 
70
61
 
@@ -74,7 +65,7 @@ class RawProgTest < Test::Unit::TestCase
74
65
 
75
66
  def test_prog_1
76
67
 
77
- pg = OpenWFE::ProcessDefinition.new()
68
+ pg = OpenWFE::ProcessDefinition.new
78
69
 
79
70
  class << pg
80
71
  def my_proc
@@ -89,11 +80,7 @@ class RawProgTest < Test::Unit::TestCase
89
80
  pdef = pg.my_proc
90
81
  s = pdef.to_s
91
82
 
92
- puts s if DEBUG
93
-
94
- assert \
95
- s == XML_DEF,
96
- "parsing failed (1)"
83
+ assert XML_DEF, s
97
84
  end
98
85
 
99
86
 
@@ -114,23 +101,21 @@ class RawProgTest < Test::Unit::TestCase
114
101
  end
115
102
  end
116
103
 
117
- XML_DEF2 = """
118
- <process-definition name='test2' revision='0'>
119
- <sequence>
120
- <set field='toto'>nada</set>
121
- <participant ref='b'/>
122
- </sequence>
123
- </process-definition>""".strip
104
+ XML_DEF2 =
105
+ "<process-definition name='test2' revision='0'>"+
106
+ "<sequence>"+
107
+ "<set field='toto'>"+
108
+ "nada"+
109
+ "</set>"+
110
+ "<participant ref='b'/>"+
111
+ "</sequence>"+
112
+ "</process-definition>"
124
113
 
125
114
  def test_prog_2
126
115
 
127
- s = TestDefinition2.do_make.to_s
128
-
129
- puts s if DEBUG
116
+ s = OpenWFE::ExpressionTree.to_s(TestDefinition2.do_make)
130
117
 
131
- assert \
132
- s == XML_DEF2,
133
- "parsing failed (2)"
118
+ assert_equal XML_DEF2, s
134
119
 
135
120
  #puts
136
121
  #puts TestDefinition2.do_make.to_code_s
@@ -152,13 +137,13 @@ class RawProgTest < Test::Unit::TestCase
152
137
  end
153
138
  end
154
139
 
155
- XML_DEF3 = """
156
- <process-definition name='test3' revision='0'>
157
- <if>
158
- <equals field-value='nada' other-value='surf'/>
159
- <participant ref='b'/>
160
- </if>
161
- </process-definition>""".strip
140
+ XML_DEF3 =
141
+ "<process-definition name='test3' revision='0'>"+
142
+ "<if>"+
143
+ "<equals field-value='nada' other-value='surf'/>"+
144
+ "<participant ref='b'/>"+
145
+ "</if>"+
146
+ "</process-definition>"
162
147
 
163
148
  CODE_DEF3 = """
164
149
  process_definition :name => 'test3', :revision => '0' do
@@ -170,26 +155,18 @@ end""".strip
170
155
 
171
156
  def test_prog_3
172
157
 
173
- s = TestDefinition3.do_make.to_s
174
-
175
- puts s if DEBUG
176
-
177
- assert \
178
- s == XML_DEF3,
179
- "parsing failed (3)"
158
+ s = OpenWFE::ExpressionTree.to_s(TestDefinition3.do_make)
180
159
 
181
- #puts
182
- #puts TestDefinition3.do_make.to_code_s
160
+ assert_equal XML_DEF3, s
183
161
 
184
- assert \
185
- TestDefinition3.do_make.to_code_s == CODE_DEF3,
186
- "to_code_s() not working properly (3)"
162
+ assert_equal(
163
+ CODE_DEF3,
164
+ OpenWFE::ExpressionTree.to_code_s(TestDefinition3.do_make))
187
165
 
188
- r = OpenWFE::SimpleExpRepresentation.from_xml(s)
189
- #puts r.class.name
190
- #puts r.to_code_s
166
+ #r = OpenWFE::SimpleExpRepresentation.from_xml(s)
167
+ r = OpenWFE::DefParser.parse_xml s
191
168
 
192
- assert_equal r.to_code_s, CODE_DEF3
169
+ assert_equal CODE_DEF3, OpenWFE::ExpressionTree.to_code_s(r)
193
170
  end
194
171
 
195
172
 
@@ -223,9 +200,9 @@ end""".strip
223
200
  #puts
224
201
  #puts TestDefinition4.do_make.to_code_s
225
202
 
226
- assert \
227
- TestDefinition4.do_make.to_code_s == CODE_DEF4,
228
- "to_code_s() not working properly (4)"
203
+ assert_equal(
204
+ CODE_DEF4,
205
+ OpenWFE::ExpressionTree.to_code_s(TestDefinition4.do_make))
229
206
  end
230
207
 
231
208
 
@@ -244,7 +221,7 @@ end""".strip
244
221
  end
245
222
 
246
223
  CODE_DEF4b = """
247
- process_definition :name => 'TestDefinition4b', :revision => '0' do
224
+ process_definition :name => 'Test', :revision => '4b' do
248
225
  sequence do
249
226
  participant do
250
227
  'b'
@@ -260,14 +237,9 @@ end""".strip
260
237
 
261
238
  def test_prog_4b
262
239
 
263
- #puts
264
- #puts TestDefinition4.do_make.to_s
265
- #puts
266
- #puts TestDefinition4b.do_make.to_code_s
267
-
268
- assert \
269
- TestDefinition4b.do_make.to_code_s == CODE_DEF4b,
270
- "to_code_s() not working properly (4b)"
240
+ assert_equal(
241
+ CODE_DEF4b,
242
+ OpenWFE::ExpressionTree.to_code_s(TestDefinition4b.do_make))
271
243
  end
272
244
 
273
245
 
@@ -300,14 +272,9 @@ end""".strip
300
272
 
301
273
  def test_prog_5
302
274
 
303
- #puts
304
- #puts TestDefinition5.do_make.to_s
305
- #puts
306
- #puts TestDefinition5.do_make.to_code_s
307
-
308
- assert \
309
- TestDefinition5.do_make.to_code_s == CODE_DEF5,
310
- "to_code_s() not working properly (5)"
275
+ assert_equal(
276
+ CODE_DEF5,
277
+ OpenWFE::ExpressionTree.to_code_s(TestDefinition5.do_make))
311
278
  end
312
279
 
313
280
 
@@ -334,14 +301,9 @@ end""".strip
334
301
 
335
302
  def test_prog_6
336
303
 
337
- #puts
338
- #puts TestDefinition60.do_make.to_s
339
- #puts
340
- #puts TestDefinition60.do_make.to_code_s
341
-
342
- assert \
343
- TestDefinition60.do_make.to_code_s == CODE_DEF6,
344
- "to_code_s() not working properly (6)"
304
+ assert_equal(
305
+ CODE_DEF6,
306
+ OpenWFE::ExpressionTree.to_code_s(TestDefinition60.do_make))
345
307
  end
346
308
 
347
309
 
@@ -362,29 +324,29 @@ end""".strip
362
324
 
363
325
  A_DEF7 = [
364
326
  "process-definition",
365
- {"name"=>"TestDefinitionSeven", "revision"=>"0"},
366
- [
367
- ["participant", {"ref"=>:toto}, []]
368
- ]
327
+ { "name"=>"TestDefinitionSeven", "revision"=>"0" },
328
+ [ [ "participant", { "ref" => :toto }, [] ] ]
369
329
  ]
370
330
 
371
331
  def test_prog_7
372
332
 
373
- #puts
374
- #puts TestDefinition7.do_make.to_s
375
- #puts
376
- #puts TestDefinition7.do_make.to_code_s
377
-
378
- assert_equal TestDefinitionSeven.do_make.to_code_s, CODE_DEF7
333
+ assert_equal(
334
+ CODE_DEF7,
335
+ OpenWFE::ExpressionTree.to_code_s(TestDefinitionSeven.do_make))
379
336
 
380
- assert_equal TestDefinitionSeven.do_make.to_a, A_DEF7
337
+ assert_equal(
338
+ A_DEF7,
339
+ TestDefinitionSeven.do_make)
381
340
  end
382
341
 
383
342
  #
384
343
  # TEST 8
385
344
  #
386
345
 
387
- def do_test(class_name, pdef)
346
+ def do_test (class_name, pdef)
347
+ #
348
+ # losing my time with an eval
349
+ #
388
350
  result = eval """
389
351
  class #{class_name} < OpenWFE::ProcessDefinition
390
352
  def make
@@ -393,15 +355,29 @@ end""".strip
393
355
  end
394
356
  #{class_name}.do_make
395
357
  """
396
- assert_equal result.attributes['name'], pdef[0]
397
- assert_equal result.attributes['revision'], pdef[1]
358
+ assert_equal result[1]['name'], pdef[0]
359
+ assert_equal result[1]['revision'], pdef[1]
398
360
  end
399
361
 
400
362
  def test_process_names
401
- do_test("MyProcessDefinition_10", ["MyProcess", "10"])
402
- do_test("MyProcessDefinition10", ["MyProcess", "10"])
403
- do_test("MyProcessDefinition1_0", ["MyProcess", "1.0"])
404
- do_test("MyProcessThing_1_0", ["MyProcessThing", "1.0"])
363
+
364
+ do_test "MyProcessDefinition_10", ["MyProcess", "10"]
365
+ do_test "MyProcessDefinition10", ["MyProcess", "10"]
366
+ do_test "MyProcessDefinition1_0", ["MyProcess", "1.0"]
367
+ do_test "MyProcessThing_1_0", ["MyProcessThing", "1.0"]
368
+ end
369
+
370
+ def do_test_2 (raw_name, expected)
371
+
372
+ assert_equal(
373
+ expected,
374
+ OpenWFE::ProcessDefinition.extract_name_and_revision(raw_name))
375
+ end
376
+
377
+ def test_process_names_2
378
+
379
+ do_test_2 "MyProcessDefinition_10", ["MyProcess", "10"]
380
+ do_test_2 "MyProcessDefinition5b", ["MyProcess", "5b"]
405
381
  end
406
382
 
407
383
 
@@ -427,17 +403,9 @@ process_definition :name => 'Test', :revision => '60' do
427
403
  end
428
404
  end""".strip
429
405
 
430
- def xxxx_prog_9
431
- #def test_prog_9
432
-
433
- #puts
434
- #puts TestDefinition60.do_make.to_s
435
- puts
436
- puts TestDefinition9.do_make.to_code_s
406
+ def _test_prog_9
437
407
 
438
- assert \
439
- TestDefinition9.do_make.to_code_s == CODE_DEF9,
440
- "to_code_s() not working properly (9)"
408
+ assert CODE_DEF9, TestDefinition9.do_make.to_code_s
441
409
  end
442
410
 
443
411
  end
@@ -6,11 +6,15 @@
6
6
  # Sun Oct 29 15:41:44 JST 2006
7
7
  #
8
8
 
9
+ require 'rubygems'
10
+
9
11
  require 'test/unit'
10
12
 
13
+ require 'fileutils'
14
+
11
15
  require 'openwfe/workitem'
12
16
  require 'openwfe/engine/file_persisted_engine'
13
- require 'openwfe/expressions/raw_prog'
17
+ require 'openwfe/def'
14
18
 
15
19
  require 'rutest_utils'
16
20
 
@@ -23,60 +27,104 @@ class RestartCronTest < Test::Unit::TestCase
23
27
  # @engine = $WORKFLOW_ENGINE_CLASS.new()
24
28
  #end
25
29
 
26
- #def teardown
27
- #end
30
+ def teardown
31
+ FileUtils.rm_rf 'work'
32
+ end
33
+
34
+ # test 0
28
35
 
29
36
  class RestartDefinition0 < ProcessDefinition
30
- #def make
31
- # process_definition :name => "rs0", :revision => "0" do
32
- cron :tab => "* * * * *", :name => "//cron" do
33
- #participant :cron_event_restart
34
- cron_event_restart
35
- end
36
- # end
37
- #end
37
+ cron :tab => "* * * * *", :name => "//mycron" do
38
+ cron_event_restart
39
+ end
38
40
  end
39
41
 
40
- def test_restart_0
42
+ def test_0
43
+
44
+ dotest RestartDefinition0
41
45
 
42
- engine = FilePersistedEngine.new
46
+ assert_equal(
47
+ 1, @engine.get_expression_storage.size,
48
+ "\n\n" + @engine.get_expression_storage.to_s)
49
+ end
43
50
 
44
- count = 0
51
+ # test 1
45
52
 
46
- participant = lambda do
47
- #puts "______________________ :cron_event_restart"
48
- count = count + 1
53
+ class RestartDefinition1 < ProcessDefinition
54
+ concurrence do
55
+ cron :tab => "* * * * *", :name => "mycron" do
56
+ cron_event_restart
57
+ end
58
+ participant :ref => "nada"
49
59
  end
50
- engine.register_participant(:cron_event_restart, &participant)
60
+ end
51
61
 
52
- engine.launch(RestartDefinition0)
62
+ def test_1
53
63
 
54
- sleep(60)
64
+ dotest RestartDefinition1
55
65
 
56
- engine.stop()
66
+ assert_equal(
67
+ 6, @engine.get_expression_storage.size,
68
+ "\n\n" + @engine.get_expression_storage.to_s)
69
+ end
57
70
 
58
- #puts "___restarting to new engine"
71
+ protected
59
72
 
60
- old_engine = engine
61
- engine = FilePersistedEngine.new
73
+ def dotest (definition)
62
74
 
63
- engine.register_participant(:cron_event_restart, &participant)
75
+ @engine = new_engine
64
76
 
65
- engine.reload
66
- #
67
- # very important
77
+ feis = []
68
78
 
69
- sleep(60)
79
+ participant = lambda do |wi|
80
+ feis << wi.fei.dup
81
+ end
82
+ @engine.register_participant :cron_event_restart, &participant
83
+ @engine.register_participant :nada, NullParticipant
70
84
 
71
- engine.stop()
85
+ @engine.launch definition
72
86
 
73
- #puts "_count : #{count}"
87
+ sleep 60
74
88
 
75
- assert \
76
- count == 2,
77
- "the cron expression should have counted to 2, "+
78
- "but it counted to #{count}"
79
- end
89
+ @engine.stop
90
+
91
+ assert_equal 1, @engine.get_scheduler.cron_job_count
92
+ assert_equal 1, feis.size
93
+
94
+ assert_equal ".0", feis[0].wfid[-2, 2]
95
+
96
+ #puts "___restarting to new engine"
97
+
98
+ #old_engine = @engine
99
+ new_engine
100
+
101
+ @engine.register_participant :cron_event_restart, &participant
102
+ @engine.register_participant :nada, NullParticipant
103
+
104
+ @engine.reload
105
+ #
106
+ # very important
107
+
108
+ sleep 60
109
+
110
+ assert_equal(
111
+ 1, @engine.get_scheduler.cron_job_count, "wrong cron job count")
112
+
113
+ @engine.stop
114
+
115
+ assert_equal 2, feis.size
116
+ assert_not_equal feis[0].wfid, feis[1].wfid
117
+
118
+ assert feis[0].wfid[-1, 1].to_i < feis[1].wfid[-1, 1].to_i
119
+ end
120
+
121
+ def new_engine
122
+
123
+ @engine = FilePersistedEngine.new
124
+ #engine = CachedFilePersistedEngine.new
125
+
126
+ #$OWFE_LOG.level = Logger::DEBUG
127
+ end
80
128
 
81
129
  end
82
130