openwferu 0.9.15 → 0.9.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/README.txt +4 -2
  2. data/lib/openwfe/engine/engine.rb +143 -25
  3. data/lib/openwfe/engine/file_persisted_engine.rb +3 -3
  4. data/lib/openwfe/expool/errorjournal.rb +48 -25
  5. data/lib/openwfe/expool/expressionpool.rb +77 -106
  6. data/lib/openwfe/expool/expstorage.rb +6 -5
  7. data/lib/openwfe/expool/threadedexpstorage.rb +190 -0
  8. data/lib/openwfe/expool/yamlexpstorage.rb +5 -150
  9. data/lib/openwfe/expressions/condition.rb +6 -6
  10. data/lib/openwfe/expressions/environment.rb +7 -2
  11. data/lib/openwfe/expressions/expressionmap.rb +14 -0
  12. data/lib/openwfe/expressions/fe_command.rb +2 -1
  13. data/lib/openwfe/expressions/fe_concurrence.rb +40 -18
  14. data/lib/openwfe/expressions/fe_cron.rb +14 -11
  15. data/lib/openwfe/expressions/fe_cursor.rb +2 -3
  16. data/lib/openwfe/expressions/fe_define.rb +34 -31
  17. data/lib/openwfe/expressions/fe_equals.rb +11 -21
  18. data/lib/openwfe/expressions/fe_filter_definition.rb +0 -2
  19. data/lib/openwfe/expressions/fe_fqv.rb +1 -3
  20. data/lib/openwfe/expressions/fe_if.rb +37 -12
  21. data/lib/openwfe/expressions/fe_iterator.rb +1 -1
  22. data/lib/openwfe/expressions/fe_listen.rb +147 -28
  23. data/lib/openwfe/expressions/fe_losfor.rb +13 -1
  24. data/lib/openwfe/expressions/fe_misc.rb +70 -11
  25. data/lib/openwfe/expressions/fe_participant.rb +3 -3
  26. data/lib/openwfe/expressions/fe_reserve.rb +1 -1
  27. data/lib/openwfe/expressions/fe_save.rb +11 -12
  28. data/lib/openwfe/expressions/fe_sequence.rb +22 -29
  29. data/lib/openwfe/expressions/fe_sleep.rb +11 -7
  30. data/lib/openwfe/expressions/fe_subprocess.rb +24 -10
  31. data/lib/openwfe/expressions/fe_value.rb +35 -15
  32. data/lib/openwfe/expressions/fe_when.rb +2 -4
  33. data/lib/openwfe/expressions/flowexpression.rb +73 -37
  34. data/lib/openwfe/expressions/merge.rb +2 -4
  35. data/lib/openwfe/expressions/raw.rb +40 -31
  36. data/lib/openwfe/expressions/raw_prog.rb +18 -9
  37. data/lib/openwfe/expressions/raw_xml.rb +1 -8
  38. data/lib/openwfe/expressions/simplerep.rb +27 -5
  39. data/lib/openwfe/expressions/time.rb +45 -15
  40. data/lib/openwfe/expressions/timeout.rb +2 -1
  41. data/lib/openwfe/expressions/wtemplate.rb +2 -2
  42. data/lib/openwfe/flowexpressionid.rb +62 -16
  43. data/lib/openwfe/listeners/listener.rb +28 -37
  44. data/lib/openwfe/listeners/listeners.rb +1 -1
  45. data/lib/openwfe/listeners/socketlisteners.rb +7 -15
  46. data/lib/openwfe/logging.rb +5 -4
  47. data/lib/openwfe/{rest → orest}/controlclient.rb +3 -5
  48. data/lib/openwfe/{rest → orest}/definitions.rb +0 -2
  49. data/lib/openwfe/{rest → orest}/exception.rb +0 -0
  50. data/lib/openwfe/{rest → orest}/oldrestservlet.rb +1 -1
  51. data/lib/openwfe/{rest → orest}/osocket.rb +1 -1
  52. data/lib/openwfe/{rest → orest}/restclient.rb +0 -2
  53. data/lib/openwfe/orest/workitem.rb +206 -0
  54. data/lib/openwfe/{rest → orest}/worklistclient.rb +15 -5
  55. data/lib/openwfe/{rest → orest}/xmlcodec.rb +4 -1
  56. data/lib/openwfe/participants/enoparticipants.rb +4 -14
  57. data/lib/openwfe/participants/participantmap.rb +16 -12
  58. data/lib/openwfe/participants/participants.rb +46 -1
  59. data/lib/openwfe/participants/socketparticipants.rb +1 -6
  60. data/lib/openwfe/service.rb +15 -6
  61. data/lib/openwfe/storage/yamlcustom.rb +3 -0
  62. data/lib/openwfe/storage/yamlfilestorage.rb +3 -1
  63. data/lib/openwfe/util/dollar.rb +21 -14
  64. data/lib/openwfe/util/lru.rb +29 -10
  65. data/lib/openwfe/util/observable.rb +4 -1
  66. data/lib/openwfe/util/otime.rb +3 -0
  67. data/lib/openwfe/util/scheduler.rb +346 -114
  68. data/lib/openwfe/utils.rb +67 -13
  69. data/lib/openwfe/version.rb +1 -1
  70. data/lib/openwfe/workitem.rb +22 -165
  71. data/lib/openwfe/worklist/oldrest.rb +2 -2
  72. data/test/bm/bm_1_xml_vs_prog.rb +56 -0
  73. data/test/{ft_26_load.rb → bm/ft_26_load.rb} +0 -0
  74. data/test/{ft_26b_load.rb → bm/ft_26b_load.rb} +0 -0
  75. data/test/{ft_26c_load.rb → bm/ft_26c_load.rb} +16 -4
  76. data/test/clone_test.rb +62 -0
  77. data/test/cron_test.rb +56 -1
  78. data/test/cronline_test.rb +17 -8
  79. data/test/description_test.rb +57 -0
  80. data/test/dollar_test.rb +17 -6
  81. data/test/eno_test.rb +22 -9
  82. data/test/fe_lookup_att_test.rb +50 -0
  83. data/test/fei_test.rb +18 -9
  84. data/test/flowtestbase.rb +24 -2
  85. data/test/ft_0.rb +10 -12
  86. data/test/ft_0e_multibody.rb +34 -0
  87. data/test/ft_10_loop.rb +4 -6
  88. data/test/ft_11_ppd.rb +5 -20
  89. data/test/ft_14b_subprocess.rb +2 -2
  90. data/test/ft_15_iterator.rb +56 -4
  91. data/test/ft_15b_iterator.rb +48 -0
  92. data/test/ft_16_fqv.rb +18 -3
  93. data/test/ft_23c_wait.rb +7 -5
  94. data/test/ft_25_cancel.rb +5 -3
  95. data/test/ft_27_getflowpos.rb +14 -11
  96. data/test/ft_28_fileparticipant.rb +3 -4
  97. data/test/ft_2_concurrence.rb +8 -12
  98. data/test/ft_2b_concurrence.rb +3 -2
  99. data/test/ft_30_socketlistener.rb +5 -6
  100. data/test/ft_32c_journal.rb +2 -2
  101. data/test/ft_32d_journal.rb +5 -6
  102. data/test/ft_33_description.rb +8 -3
  103. data/test/ft_34_cancelwfid.rb +3 -3
  104. data/test/ft_38_tag.rb +7 -10
  105. data/test/ft_39_reserve.rb +4 -2
  106. data/test/ft_3_equals.rb +18 -13
  107. data/test/ft_44b_restore.rb +2 -6
  108. data/test/ft_49_condition.rb +16 -12
  109. data/test/ft_4_misc.rb +51 -12
  110. data/test/ft_50_xml_attribute.rb +1 -1
  111. data/test/ft_54_listen.rb +96 -10
  112. data/test/ft_54b_listen.rb +68 -0
  113. data/test/ft_55_ptimeout.rb +1 -2
  114. data/test/ft_58_ejournal.rb +8 -33
  115. data/test/ft_59_ps.rb +2 -3
  116. data/test/ft_59b_ps_for_pat.rb +59 -0
  117. data/test/ft_5_time.rb +45 -4
  118. data/test/ft_60_ecancel.rb +7 -7
  119. data/test/ft_61_elsub.rb +1 -1
  120. data/test/ft_64_alias.rb +1 -1
  121. data/test/ft_67_schedlaunch.rb +29 -16
  122. data/test/ft_69_cancelmissing.rb +1 -1
  123. data/test/ft_6_lambda.rb +8 -6
  124. data/test/ft_70_lookupvar.rb +2 -2
  125. data/test/ft_71_log.rb +60 -0
  126. data/test/ft_72_lookup_processes.rb +79 -0
  127. data/test/ft_73_cancel_sub.rb +144 -0
  128. data/test/ft_74_block_and_workitem_dup.rb +63 -0
  129. data/test/ft_75_ruby_attributes.rb +87 -0
  130. data/test/ft_76_merge_isolate.rb +90 -0
  131. data/test/ft_7_lose.rb +2 -1
  132. data/test/ft_tests.rb +9 -0
  133. data/test/lookup_att_test.rb +90 -0
  134. data/test/misc_test.rb +33 -50
  135. data/test/orest_test.rb +1 -1
  136. data/test/participant_test.rb +32 -8
  137. data/test/pending.rb +6 -7
  138. data/test/rake_ltest.rb +3 -0
  139. data/test/rake_qtest.rb +4 -1
  140. data/test/raw_prog_test.rb +1 -1
  141. data/test/restart_cron_test.rb +6 -6
  142. data/test/restart_sleep_test.rb +8 -8
  143. data/test/ruby_procdef_test.rb +2 -2
  144. data/test/rutest_utils.rb +9 -3
  145. data/test/scheduler_1_test.rb +88 -0
  146. data/test/scheduler_test.rb +49 -4
  147. data/test/sec_test.rb +18 -11
  148. metadata +51 -34
  149. data/test/cron_test_2.rb +0 -50
data/test/ft_5_time.rb CHANGED
@@ -20,7 +20,6 @@ class FlowTest5 < Test::Unit::TestCase
20
20
  #end
21
21
 
22
22
  def test_sleep_0
23
- #def xxxx_sleep_0
24
23
  dotest(
25
24
  '''<process-definition name="sleep_0" revision="0">
26
25
  <sequence>
@@ -33,7 +32,6 @@ class FlowTest5 < Test::Unit::TestCase
33
32
  end
34
33
 
35
34
  def test_sleep_1
36
- #def xxxx_sleep_1
37
35
  dotest(
38
36
  '''<process-definition name="sleep_1" revision="0">
39
37
  <concurrence>
@@ -50,7 +48,6 @@ alpha""",
50
48
  end
51
49
 
52
50
  def test_sleep_2
53
- #def xxxx_sleep_2
54
51
  dotest(
55
52
  '''<process-definition name="sleep_2" revision="0">
56
53
  <sequence>
@@ -63,7 +60,6 @@ alpha""",
63
60
  end
64
61
 
65
62
  def test_sleep_3
66
- #def xxxx_sleep_3
67
63
  dotest(
68
64
  '''<process-definition name="sleep_3" revision="0">
69
65
  <sequence>
@@ -73,5 +69,50 @@ alpha""",
73
69
  </process-definition>''', "alpha", true)
74
70
  end
75
71
 
72
+ #
73
+ # Test 4
74
+ #
75
+
76
+ class Test4 < OpenWFE::ProcessDefinition
77
+ _sleep "10s"
78
+ end
79
+
80
+ def test_sleep_4
81
+
82
+ fei = @engine.launch Test4
83
+
84
+ sleep 0.250
85
+
86
+ jobs = @engine.get_scheduler.find_jobs SleepExpression.name
87
+
88
+ assert_equal 1, jobs.size
89
+
90
+ @engine.cancel_process fei
91
+
92
+ sleep 0.300
93
+ end
94
+
95
+ #
96
+ # Test 5
97
+ #
98
+
99
+ class Test5 < OpenWFE::ProcessDefinition
100
+ _sleep "10s", :scheduler_tags => "a, b"
101
+ end
102
+
103
+ def test_sleep_5
104
+
105
+ fei = @engine.launch Test5
106
+
107
+ sleep 0.250
108
+
109
+ assert_equal 1, @engine.get_scheduler.find_jobs("a").size
110
+ assert_equal 1, @engine.get_scheduler.find_jobs("b").size
111
+
112
+ @engine.cancel_process fei
113
+
114
+ sleep 0.300
115
+ end
116
+
76
117
  end
77
118
 
@@ -41,7 +41,7 @@ class FlowTest60 < Test::Unit::TestCase
41
41
 
42
42
  fei = @engine.launch TestDefinition0
43
43
 
44
- sleep 0.200
44
+ sleep 0.300
45
45
 
46
46
  #puts
47
47
  #puts @engine.get_process_stack fei.wfid
@@ -51,11 +51,11 @@ class FlowTest60 < Test::Unit::TestCase
51
51
  fei.expression_name = "sequence"
52
52
  @engine.cancel_expression fei
53
53
 
54
- sleep 0.200
54
+ sleep 0.300
55
55
 
56
- assert_equal @tracer.to_s, "a\nb.0\nc"
56
+ assert_equal "a\nb.0\nc", @tracer.to_s
57
57
 
58
- assert_equal @engine.get_process_stack(fei.wfid).size, 0
58
+ assert_equal 0, @engine.get_process_stack(fei.wfid).size
59
59
 
60
60
  #$OWFE_LOG.level = Logger::INFO
61
61
  end
@@ -66,7 +66,7 @@ class FlowTest60 < Test::Unit::TestCase
66
66
 
67
67
  fei = @engine.launch TestDefinition0
68
68
 
69
- sleep 0.200
69
+ sleep 0.300
70
70
 
71
71
  fei.expression_id = "0.0.1.2"
72
72
  fei.expression_name = "print"
@@ -74,9 +74,9 @@ class FlowTest60 < Test::Unit::TestCase
74
74
 
75
75
  @engine.wait_for(fei.wfid)
76
76
 
77
- assert_equal @tracer.to_s, "a\nb.0\nc"
77
+ assert_equal "a\nb.0\nc", @tracer.to_s
78
78
 
79
- assert_equal @engine.get_process_stack(fei.wfid).size, 0
79
+ assert_equal 0, @engine.get_process_stack(fei.wfid).size
80
80
 
81
81
  #$OWFE_LOG.level = Logger::INFO
82
82
  end
data/test/ft_61_elsub.rb CHANGED
@@ -38,7 +38,7 @@ class FlowTest61 < Test::Unit::TestCase
38
38
 
39
39
  def test_0
40
40
 
41
- log_level_to_debug
41
+ #log_level_to_debug
42
42
 
43
43
  engine.launch EngineLevelProcessDefinition
44
44
  sleep 0.700
data/test/ft_64_alias.rb CHANGED
@@ -95,7 +95,7 @@ class FlowTest64a < Test::Unit::TestCase
95
95
  @tracer << "\n"
96
96
  end
97
97
 
98
- dotest(Test2, "0.2.0\n0.2.1")
98
+ dotest Test2, "0.2.0\n0.2.1"
99
99
  end
100
100
 
101
101
  end
@@ -32,70 +32,83 @@ class FlowTest67 < Test::Unit::TestCase
32
32
 
33
33
  #log_level_to_debug
34
34
 
35
- @engine.launch(Test0, :in => "2s")
35
+ @engine.launch Test0, :in => "2s"
36
36
 
37
37
  sleep 0.200
38
38
 
39
- assert_equal @tracer.to_s, ""
39
+ assert_equal(
40
+ 1,
41
+ @engine.get_scheduler.find_jobs("scheduled-launch").size)
42
+
43
+ assert_trace ""
40
44
 
41
45
  sleep 2.500
42
46
 
43
- assert_equal @tracer.to_s, "hell0"
47
+ assert_trace "hell0"
44
48
  end
45
49
 
46
50
  #
47
51
  # TEST 1
48
52
 
49
- #def xxxx_1
50
53
  def test_1
51
54
 
52
55
  #log_level_to_debug
53
56
 
54
57
  t = Time.now
55
58
 
56
- @engine.launch(Test0, :at => (t + 2).to_s)
59
+ @engine.launch Test0, :at => (t + 2).to_s
57
60
 
58
61
  sleep 0.200
59
62
 
60
- assert_equal @tracer.to_s, ""
63
+ assert_equal(
64
+ 1,
65
+ @engine.get_scheduler.find_jobs("scheduled-launch").size)
66
+
67
+ assert_trace ""
61
68
 
62
69
  sleep 2.500
63
70
 
64
- assert_equal @tracer.to_s, "hell0"
71
+ assert_trace "hell0"
65
72
  end
66
73
 
67
74
  #
68
75
  # TEST 2
69
76
 
70
- #def xxxx_2
71
77
  def test_2
72
78
 
73
- log_level_to_debug
79
+ #log_level_to_debug
74
80
 
75
- @engine.launch(Test0, :cron => "* * * * *")
81
+ @engine.launch Test0, :cron => "* * * * *"
76
82
 
77
- assert_equal @tracer.to_s, ""
83
+ assert_trace ""
78
84
 
79
85
  sleep 130
80
86
 
81
- assert_equal @tracer.to_s, "hell0\nhell0"
87
+ assert_trace "hell0\nhell0"
88
+
89
+ assert_equal(
90
+ 1,
91
+ @engine.get_scheduler.find_jobs("scheduled-launch").size)
82
92
  end
83
93
 
84
94
  #
85
95
  # TEST 3
86
96
 
87
- #def xxxx_3
88
97
  def test_3
89
98
 
90
99
  log_level_to_debug
91
100
 
92
- @engine.launch(Test0, :every => "2s")
101
+ @engine.launch Test0, :every => "2s"
93
102
 
94
- assert_equal @tracer.to_s, ""
103
+ assert_trace ""
95
104
 
96
105
  sleep 5
97
106
 
98
- assert_equal @tracer.to_s, "hell0\nhell0"
107
+ assert_trace "hell0\nhell0"
108
+
109
+ assert_equal(
110
+ 1,
111
+ @engine.get_scheduler.find_jobs("scheduled-launch").size)
99
112
  end
100
113
 
101
114
  end
@@ -35,7 +35,7 @@ class FlowTest69 < Test::Unit::TestCase
35
35
 
36
36
  fei = @engine.launch(Test0)
37
37
 
38
- sleep 0.200
38
+ sleep 0.300
39
39
 
40
40
  assert @engine.process_status(fei.wfid).errors.size > 0
41
41
 
data/test/ft_6_lambda.rb CHANGED
@@ -25,17 +25,17 @@ class FlowTest6 < Test::Unit::TestCase
25
25
  dotest(
26
26
  '''<process-definition name="lambda_0" revision="0">
27
27
  <sequence>
28
- <set variable="inside1">
28
+ <set variable="inside1x">
29
29
  <process-definition>
30
30
  <print>bonjour ${name}</print>
31
31
  </process-definition>
32
32
  </set>
33
33
 
34
- <inside1 name="world" />
34
+ <inside1x name="world" />
35
35
  <print>over</print>
36
36
  </sequence>
37
- </process-definition>''', """bonjour world
38
- over""")
37
+ </process-definition>''',
38
+ "bonjour world\nover")
39
39
  end
40
40
 
41
41
  #
@@ -43,18 +43,20 @@ over""")
43
43
 
44
44
  class Test1 < OpenWFE::ProcessDefinition
45
45
  sequence do
46
- _set :v => "inside1" do
46
+ _set :v => "inside1r" do
47
47
  process_definition do
48
48
  _print "hello ${name}"
49
49
  end
50
50
  end
51
- inside1 :name => "mundo"
51
+ inside1r :name => "mundo"
52
52
  _print "done."
53
53
  end
54
54
  end
55
55
 
56
56
  def test_1
57
57
 
58
+ log_level_to_debug
59
+
58
60
  dotest(Test1, "hello mundo\ndone.")
59
61
  end
60
62
 
@@ -40,7 +40,7 @@ class FlowTest70 < Test::Unit::TestCase
40
40
 
41
41
  fei = @engine.launch(Test0)
42
42
 
43
- sleep 0.100
43
+ sleep 0.200
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.100
51
+ sleep 0.200
52
52
  end
53
53
 
54
54
  end
data/test/ft_71_log.rb ADDED
@@ -0,0 +1,60 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Thu Sep 13 17:46:20 JST 2007
8
+ #
9
+
10
+ require 'openwfe/def'
11
+
12
+ require 'flowtestbase'
13
+
14
+
15
+ class FlowTest71 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ #def setup
22
+ #end
23
+
24
+ #
25
+ # TEST 0
26
+
27
+ class Test0 < ProcessDefinition
28
+ sequence do
29
+ log "log:0"
30
+ log do
31
+ "log:1"
32
+ end
33
+ log :message => "log:2"
34
+ log :message => "log:3", :level => "info"
35
+ end
36
+ end
37
+
38
+ def test_0
39
+
40
+ log_level_to_debug
41
+ # required for the test ;)
42
+
43
+ File.open "logs/openwferu.log", "w" do
44
+ print ""
45
+ end
46
+
47
+ dotest Test0, ""
48
+
49
+ #assert_equal 1, OpenWFE.grep("DEBUG .*log:0", "logs/openwferu.log").size
50
+ assert_equal 1, OpenWFE.grep("log:0", "logs/openwferu.log").size
51
+
52
+ assert_equal 1, OpenWFE.grep("log:1", "logs/openwferu.log").size
53
+ assert_equal 4, OpenWFE.grep("log:.$", "logs/openwferu.log").size
54
+
55
+ #assert_equal 1, OpenWFE.grep("INFO .*log:3", "logs/openwferu.log").size
56
+ assert_equal 1, OpenWFE.grep("log:3", "logs/openwferu.log").size
57
+ end
58
+
59
+ end
60
+
@@ -0,0 +1,79 @@
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 FlowTest72 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def setup
19
+ #end
20
+
21
+ #def teardown
22
+ #end
23
+
24
+
25
+ #
26
+ # Test 0
27
+ #
28
+
29
+ class Test0 < ProcessDefinition
30
+ sequence do
31
+ _set :variable => "/toto", :value => "${f:toto}"
32
+ participant :alpha
33
+ end
34
+ end
35
+
36
+ #def xxxx_0
37
+ def test_0
38
+
39
+ #log_level_to_debug
40
+
41
+ sa = @engine.register_participant :alpha, OpenWFE::HashParticipant
42
+
43
+ li = LaunchItem.new Test0
44
+ li.toto = 'toto_zero'
45
+ fei0 = @engine.launch li
46
+
47
+ li = LaunchItem.new Test0
48
+ li.toto = 'toto_one'
49
+ fei1 = @engine.launch li
50
+
51
+ sleep 0.300
52
+
53
+ wfids = @engine.lookup_processes('nada')
54
+ assert_equal 0, wfids.size
55
+
56
+ wfids = @engine.lookup_processes('toto')
57
+ assert_equal 2, wfids.size
58
+ assert wfids.include?(fei0.wfid)
59
+ assert wfids.include?(fei1.wfid)
60
+
61
+ wfids = @engine.lookup_processes('toto', 'smurf')
62
+ assert_equal 0, wfids.size
63
+
64
+ wfids = @engine.lookup_processes('toto', 'toto_.*')
65
+ assert_equal 2, wfids.size
66
+
67
+ wfids = @engine.lookup_processes('toto', Regexp.compile('toto_one'))
68
+ assert_equal wfids, [ fei1.wfid ]
69
+
70
+ # over.
71
+
72
+ @engine.cancel_process fei0
73
+ @engine.cancel_process fei1
74
+
75
+ sleep 0.300
76
+ end
77
+
78
+ end
79
+
@@ -0,0 +1,144 @@
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 FlowTest73 < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def setup
19
+ #end
20
+
21
+ #def teardown
22
+ #end
23
+
24
+
25
+ #
26
+ # Test 0
27
+ #
28
+
29
+ class Test0 < ProcessDefinition
30
+ sequence do
31
+ sub0
32
+ end
33
+ process_definition :name => "sub0" do
34
+ p0
35
+ end
36
+ end
37
+
38
+ def test_0
39
+
40
+ #log_level_to_debug
41
+
42
+ p0 = @engine.register_participant :p0, OpenWFE::HashParticipant
43
+
44
+ fei = @engine.launch Test0
45
+ #puts "launched : " + fei.to_s
46
+
47
+ sleep 0.300
48
+
49
+ assert_equal 1, p0.size
50
+ #puts "in store : " + p0.first_workitem.fei.to_s
51
+
52
+ wi = p0.first_workitem
53
+ assert_equal wi.fei.wfid, fei.wfid + ".0"
54
+
55
+ @engine.cancel_process fei
56
+
57
+ sleep 0.300
58
+
59
+ assert_equal 0, p0.size
60
+ end
61
+
62
+
63
+ #
64
+ # Test 1
65
+ #
66
+
67
+ class Test1 < ProcessDefinition
68
+ sequence do
69
+ sub1 :forget => true
70
+ _sleep :for => "5m"
71
+ end
72
+ process_definition :name => "sub1" do
73
+ p1
74
+ end
75
+ end
76
+
77
+ def test_1
78
+
79
+ #log_level_to_debug
80
+
81
+ p1 = @engine.register_participant :p1, OpenWFE::HashParticipant
82
+
83
+ fei = @engine.launch Test1
84
+ #puts
85
+ #puts "launched : " + fei.to_s
86
+
87
+ sleep 0.300
88
+
89
+ assert_equal 1, p1.size
90
+ #puts "in store : " + p1.first_workitem.fei.to_s
91
+
92
+ wi = p1.first_workitem
93
+ assert_equal wi.fei.wfid, fei.wfid + ".0"
94
+
95
+ @engine.cancel_process fei
96
+
97
+ sleep 0.300
98
+
99
+ assert_equal 1, p1.size
100
+
101
+ @engine.cancel_process p1.first_workitem.fei
102
+
103
+ sleep 0.400
104
+
105
+ assert_equal 0, p1.size
106
+ end
107
+
108
+
109
+ #
110
+ # Test 2
111
+ #
112
+
113
+ class Test2 < ProcessDefinition
114
+ sequence do
115
+ sub2 :forget => true
116
+ p2
117
+ end
118
+ process_definition :name => "sub2" do
119
+ p20
120
+ end
121
+ end
122
+
123
+ def test_2
124
+
125
+ #log_level_to_debug
126
+
127
+ p2 = @engine.register_participant :p2, OpenWFE::HashParticipant
128
+ p20 = @engine.register_participant :p20, OpenWFE::HashParticipant
129
+
130
+ fei = @engine.launch Test2
131
+
132
+ sleep 0.400
133
+
134
+ assert_equal 1, p2.size
135
+ assert_equal 1, p20.size
136
+
137
+ @engine.cancel_process p20.first_workitem.fei
138
+ sleep 0.300
139
+ @engine.cancel_process p2.first_workitem.fei
140
+ sleep 0.300
141
+ end
142
+
143
+ end
144
+
@@ -0,0 +1,63 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # Original bug report by Maarten Oelering
6
+ # John Mettraux at openwfe.org
7
+ #
8
+ # Thu Sep 13 17:46:20 JST 2007
9
+ #
10
+
11
+ require 'flowtestbase'
12
+
13
+
14
+ class FlowTest74 < Test::Unit::TestCase
15
+ include FlowTestBase
16
+
17
+ #def teardown
18
+ #end
19
+
20
+ #def setup
21
+ #end
22
+
23
+ #
24
+ # TEST 0
25
+
26
+ def test_0
27
+
28
+ engine.register_participant("part1") do |workitem|
29
+ @tracer << "part1\n"
30
+ # the last expression of the block evaluates to the workitem
31
+ # remove this line or replace it with nil and it works again
32
+ workitem
33
+ end
34
+
35
+ engine.register_participant("part3") do |workitem|
36
+ @tracer << "part3\n"
37
+ end
38
+
39
+ engine.register_participant("part4") do |workitem|
40
+ @tracer << "part4\n"
41
+ end
42
+
43
+ process = <<THE_END
44
+ <process-definition name="test" revision="0.1">
45
+ <sequence>
46
+ <part1/>
47
+ <concurrence>
48
+ <part3/>
49
+ <part4/>
50
+ </concurrence>
51
+ </sequence>
52
+ </process-definition>
53
+ THE_END
54
+
55
+ #log_level_to_debug
56
+
57
+ dotest(
58
+ process.strip,
59
+ [ "part1\npart3\npart4", "part1\npart4\npart3" ])
60
+ end
61
+
62
+ end
63
+