openwferu 0.9.10.653 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/README.txt +65 -33
  2. data/examples/README.txt +4 -0
  3. data/examples/flowtracing.rb +2 -0
  4. data/examples/homeworkreview.rb +2 -0
  5. data/examples/mano_tracker.rb +2 -0
  6. data/examples/openwferu.rb +3 -1
  7. data/examples/quotereporter.rb +2 -0
  8. data/examples/scheduler_cron_usage.rb +3 -1
  9. data/examples/scheduler_usage.rb +3 -1
  10. data/lib/openwfe/engine/engine.rb +15 -5
  11. data/lib/openwfe/expool/expressionpool.rb +30 -4
  12. data/lib/openwfe/expool/journal.rb +16 -18
  13. data/lib/openwfe/expool/journal_replay.rb +56 -8
  14. data/lib/openwfe/expool/wfidgen.rb +17 -8
  15. data/lib/openwfe/expressions/condition.rb +41 -26
  16. data/lib/openwfe/expressions/expressionmap.rb +7 -0
  17. data/lib/openwfe/expressions/fe_cancel.rb +1 -1
  18. data/lib/openwfe/expressions/fe_concurrence.rb +14 -5
  19. data/lib/openwfe/expressions/fe_cron.rb +3 -1
  20. data/lib/openwfe/expressions/fe_cursor.rb +1 -1
  21. data/lib/openwfe/expressions/fe_fqv.rb +58 -0
  22. data/lib/openwfe/expressions/fe_if.rb +1 -1
  23. data/lib/openwfe/expressions/fe_iterator.rb +5 -0
  24. data/lib/openwfe/expressions/fe_listen.rb +224 -0
  25. data/lib/openwfe/expressions/fe_misc.rb +32 -9
  26. data/lib/openwfe/expressions/fe_participant.rb +26 -6
  27. data/lib/openwfe/expressions/fe_sleep.rb +5 -7
  28. data/lib/openwfe/expressions/fe_timeout.rb +127 -0
  29. data/lib/openwfe/expressions/fe_when.rb +13 -1
  30. data/lib/openwfe/expressions/flowexpression.rb +4 -1
  31. data/lib/openwfe/expressions/time.rb +10 -27
  32. data/lib/openwfe/expressions/timeout.rb +23 -6
  33. data/lib/openwfe/flowexpressionid.rb +7 -6
  34. data/lib/openwfe/listeners/socketlisteners.rb +1 -1
  35. data/lib/openwfe/participants/enoparticipants.rb +103 -47
  36. data/lib/openwfe/participants/participant.rb +29 -3
  37. data/lib/openwfe/participants/participantmap.rb +10 -2
  38. data/lib/openwfe/participants/participants.rb +31 -19
  39. data/lib/openwfe/participants/socketparticipants.rb +3 -1
  40. data/lib/openwfe/rest/controlclient.rb +5 -18
  41. data/lib/openwfe/rest/oldrestservlet.rb +279 -0
  42. data/lib/openwfe/rest/restclient.rb +55 -25
  43. data/lib/openwfe/rest/worklistclient.rb +35 -44
  44. data/lib/openwfe/rest/xmlcodec.rb +79 -69
  45. data/lib/openwfe/rudefinitions.rb +15 -7
  46. data/lib/openwfe/storage/yamlextras.rb +3 -3
  47. data/lib/openwfe/util/observable.rb +64 -7
  48. data/lib/openwfe/util/scheduler.rb +107 -77
  49. data/lib/openwfe/util/workqueue.rb +5 -11
  50. data/lib/openwfe/utils.rb +3 -3
  51. data/lib/openwfe/version.rb +1 -2
  52. data/lib/openwfe/workitem.rb +3 -4
  53. data/lib/openwfe/worklist/oldrest.rb +244 -0
  54. data/lib/openwfe/worklist/storelocks.rb +288 -0
  55. data/lib/openwfe/worklist/storeparticipant.rb +4 -2
  56. data/lib/openwfe/worklist/worklist.rb +297 -0
  57. data/test/cron_test.rb +8 -9
  58. data/test/eno_test.rb +10 -13
  59. data/test/flowtestbase.rb +26 -17
  60. data/test/ft_15_iterator.rb +19 -0
  61. data/test/ft_23c_wait.rb +2 -2
  62. data/test/ft_2b_concurrence.rb +2 -2
  63. data/test/ft_30_socketlistener.rb +5 -1
  64. data/test/ft_32_journal.rb +1 -1
  65. data/test/ft_32c_journal.rb +102 -0
  66. data/test/ft_32d_journal.rb +85 -0
  67. data/test/ft_45_citerator.rb +25 -0
  68. data/test/ft_49_condition.rb +60 -2
  69. data/test/ft_4_misc.rb +15 -0
  70. data/test/ft_50_xml_attribute.rb +4 -4
  71. data/test/ft_53_null_noop_participant.rb +66 -0
  72. data/test/ft_54_listen.rb +223 -0
  73. data/test/ft_55_ptimeout.rb +64 -0
  74. data/test/ft_56_timeout.rb +55 -0
  75. data/test/ft_57_a.rb +109 -0
  76. data/test/ft_tests.rb +7 -0
  77. data/test/hparticipant_test.rb +3 -3
  78. data/test/obs_test.rb +115 -0
  79. data/test/orest_test.rb +224 -0
  80. data/test/pending.rb +24 -0
  81. data/test/rake_qtest.rb +5 -1
  82. data/test/rake_test.rb +4 -0
  83. data/test/scheduler_test.rb +31 -2
  84. data/test/sec_test.rb +7 -3
  85. data/test/slock_test.rb +82 -0
  86. metadata +19 -3
  87. data/test/ft_32b_journal.rb +0 -76
@@ -0,0 +1,223 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'flowtestbase'
9
+ require 'openwfe/def'
10
+ require 'openwfe/participants/participants'
11
+
12
+ include OpenWFE
13
+
14
+
15
+ class FlowTest54 < 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
+ concurrence do
31
+
32
+ listen :to => "^channel_.$" do
33
+ _print "ok"
34
+ end
35
+
36
+ sequence do
37
+
38
+ _sleep "500"
39
+ #
40
+ # just making sure that the participant is evaluated
41
+ # after the listen [registration]
42
+
43
+ participant :ref => "channel_z"
44
+ end
45
+ end
46
+ end
47
+
48
+ #def xxxx_0
49
+ def test_0
50
+
51
+ @engine.register_participant :channel_z, NoOperationParticipant
52
+
53
+ dotest(Test0, "ok")
54
+ end
55
+
56
+
57
+ #
58
+ # Test 1
59
+ #
60
+
61
+ class Test1 < ProcessDefinition
62
+ concurrence do
63
+
64
+ listen :to => "^channel_.$", :where => "${f:f0} == alpha" do
65
+ _print "alpha"
66
+ end
67
+
68
+ sequence do
69
+
70
+ _sleep "500"
71
+ #
72
+ # just making sure that the participant is evaluated
73
+ # after the listen [registration]
74
+
75
+ participant :ref => "channel_z"
76
+ set :field => "f0", :value => "alpha"
77
+ participant :ref => "channel_z"
78
+ end
79
+ end
80
+ end
81
+
82
+ #def xxxx_1
83
+ def test_1
84
+
85
+ @engine.register_participant :channel_z, NoOperationParticipant
86
+
87
+ dotest(Test1, "alpha")
88
+ end
89
+
90
+
91
+ #
92
+ # Test 2
93
+ #
94
+
95
+ class Test2 < ProcessDefinition
96
+ concurrence do
97
+
98
+ listen :to => "^channel_.$" do
99
+ #
100
+ # upon apply by default
101
+
102
+ _print "apply"
103
+ end
104
+ listen :to => "^channel_.$", :upon => "reply" do
105
+ _print "reply"
106
+ end
107
+
108
+ sequence do
109
+
110
+ _sleep "500"
111
+
112
+ participant :ref => "channel_z"
113
+
114
+ participant :ref => "channel_z"
115
+ #
116
+ # listeners are 'once' by default, check that
117
+ end
118
+ end
119
+ end
120
+
121
+ #def xxxx_2
122
+ def test_2
123
+
124
+ @engine.register_participant :channel_z, NoOperationParticipant
125
+
126
+ dotest(Test2, "apply\nreply")
127
+ end
128
+
129
+
130
+ #
131
+ # Test 3
132
+ #
133
+
134
+ class Test3 < ProcessDefinition
135
+ concurrence do
136
+
137
+ listen :to => "^channel_.$", :once => false do
138
+ _print "apply"
139
+ end
140
+
141
+ sequence do
142
+ _sleep "500"
143
+ participant :ref => "channel_z"
144
+ participant :ref => "channel_z"
145
+ end
146
+ end
147
+ end
148
+
149
+ #def xxxx_3
150
+ def test_3
151
+
152
+ @engine.register_participant :channel_z do
153
+ @tracer << "z\n"
154
+ end
155
+
156
+ dotest(Test3, "z\napply\nz\napply", 2, true)
157
+ end
158
+
159
+
160
+ #
161
+ # Test 4
162
+ #
163
+
164
+ class Test4 < ProcessDefinition
165
+ concurrence do
166
+
167
+ #listen :to => "^channel_.$", :rwhere => "self.fei.wfid == '${r:workitem.fei.wfid}'" do
168
+ listen :to => "^channel_.$", :where => "${r:fei.wfid} == ${r:workitem.fei.wfid}" do
169
+ _print "ok"
170
+ end
171
+
172
+ sequence do
173
+ _sleep "500"
174
+ participant :ref => "channel_z"
175
+ end
176
+ end
177
+ end
178
+
179
+ #def xxxx_4
180
+ def test_4
181
+
182
+ @engine.register_participant :channel_z do
183
+ @tracer << "z\n"
184
+ end
185
+
186
+ dotest(Test4, "z\nok")
187
+ end
188
+
189
+
190
+ #
191
+ # Test 5
192
+ #
193
+
194
+ class Test5 < ProcessDefinition
195
+ concurrence do
196
+
197
+ listen :to => :channel_z do
198
+ _print "ok"
199
+ end
200
+
201
+ sequence do
202
+ _sleep "500"
203
+ channel_zz
204
+ channel_z
205
+ end
206
+ end
207
+ end
208
+
209
+ #def xxxx_5
210
+ def test_5
211
+
212
+ @engine.register_participant :channel_z do
213
+ @tracer << "z\n"
214
+ end
215
+ @engine.register_participant :channel_zz do
216
+ @tracer << "zz\n"
217
+ end
218
+
219
+ dotest(Test5, "zz\nok\nz")
220
+ end
221
+
222
+ end
223
+
@@ -0,0 +1,64 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'flowtestbase'
9
+ require 'pending'
10
+ require 'openwfe/def'
11
+ #require 'openwfe/participants/participants'
12
+
13
+ include OpenWFE
14
+
15
+
16
+ class FlowTest55 < Test::Unit::TestCase
17
+ include FlowTestBase
18
+ include PendingJobsMixin
19
+
20
+ #def setup
21
+ #end
22
+
23
+ #def teardown
24
+ #end
25
+
26
+
27
+ #
28
+ # Test 0
29
+ #
30
+
31
+ class Test0 < ProcessDefinition
32
+ sequence do
33
+ concurrence :count => 1 do
34
+ sequence do
35
+ participant :ref => "channel_z", :timeout => "1s"
36
+ _print "cancelled?"
37
+ end
38
+ _print "concurrence done"
39
+ end
40
+ end
41
+ end
42
+
43
+ #def xxxx_0
44
+ def test_0
45
+
46
+ @engine.register_participant :channel_z, NullParticipant
47
+
48
+ #class << @engine.get_scheduler
49
+ # attr_reader :pending_jobs
50
+ #end
51
+ #
52
+ # having a look into the scheduler
53
+
54
+ #require 'pp'; pp @engine.get_scheduler.pending_jobs
55
+ assert_no_jobs_left
56
+
57
+ dotest(Test0, "concurrence done")
58
+
59
+ #require 'pp'; pp @engine.get_scheduler.pending_jobs
60
+ assert_no_jobs_left
61
+ end
62
+
63
+ end
64
+
@@ -0,0 +1,55 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'flowtestbase'
9
+ require 'pending'
10
+ require 'openwfe/def'
11
+ #require 'openwfe/participants/participants'
12
+
13
+ include OpenWFE
14
+
15
+
16
+ class FlowTest56 < Test::Unit::TestCase
17
+ include FlowTestBase
18
+ include PendingJobsMixin
19
+
20
+ #def setup
21
+ #end
22
+
23
+ #def teardown
24
+ #end
25
+
26
+
27
+ #
28
+ # Test 0
29
+ #
30
+
31
+ class Test0 < ProcessDefinition
32
+ sequence do
33
+ _timeout :after => "1s" do
34
+ sequence do
35
+ _print "ok"
36
+ _sleep "2s"
37
+ _print "not ok"
38
+ end
39
+ end
40
+ _print "done"
41
+ end
42
+ end
43
+
44
+ #def xxxx_0
45
+ def test_0
46
+
47
+ assert_no_jobs_left
48
+
49
+ dotest Test0, "ok\ndone"
50
+
51
+ assert_no_jobs_left
52
+ end
53
+
54
+ end
55
+
data/test/ft_57_a.rb ADDED
@@ -0,0 +1,109 @@
1
+
2
+ #
3
+ # Testing OpenWFEru
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'flowtestbase'
9
+ require 'pending'
10
+ require 'openwfe/def'
11
+ #require 'openwfe/participants/participants'
12
+
13
+ include OpenWFE
14
+
15
+
16
+ class FlowTest57 < Test::Unit::TestCase
17
+ include FlowTestBase
18
+
19
+ #def setup
20
+ #end
21
+
22
+ #def teardown
23
+ #end
24
+
25
+
26
+ #
27
+ # Test 0
28
+ #
29
+
30
+ class Test0 < ProcessDefinition
31
+ sequence do
32
+ _set :field => "list" do
33
+ _a """
34
+ <list>
35
+ <string>a</string>
36
+ <string>b</string>
37
+ <string>c</string>
38
+ </list>
39
+ """
40
+ end
41
+ _print "${r:wi.list.join('|')}"
42
+ _print "-"
43
+ _set :field => "list" do
44
+ _attribute """
45
+ ---
46
+ - a
47
+ - b
48
+ - 3
49
+ """
50
+ end
51
+ _print "${r:wi.list.join('|')}"
52
+ end
53
+ end
54
+
55
+ #def xxxx_0
56
+ def test_0
57
+ dotest(
58
+ Test0,
59
+ """
60
+ a|b|c
61
+ -
62
+ a|b|3
63
+ """.strip)
64
+ end
65
+
66
+ #def xxxx_1
67
+ def test_1
68
+ dotest(
69
+ """
70
+ <process-definition name='57_a' revision='1'>
71
+ <sequence>
72
+ <set field='list'>
73
+ <a>
74
+ ---
75
+ - c
76
+ - d
77
+ - e
78
+ </a>
79
+ </set>
80
+ <print>${r:wi.list.join('|')}</print>
81
+ </sequence>
82
+ </process-definition>
83
+ """.strip,
84
+ "c|d|e")
85
+ end
86
+
87
+ #def xxxx_2
88
+ def test_2
89
+ dotest(
90
+ """
91
+ <process-definition name='57_a' revision='2'>
92
+ <sequence>
93
+ <set field='list'>
94
+ <a>
95
+ <list>
96
+ <string>a</string>
97
+ <string>2</string>
98
+ <string>c</string>
99
+ </list>
100
+ </a>
101
+ </set>
102
+ <print>${r:wi.list.join('|')}</print>
103
+ </sequence>
104
+ </process-definition>
105
+ """.strip,
106
+ "a|2|c")
107
+ end
108
+ end
109
+
data/test/ft_tests.rb CHANGED
@@ -66,6 +66,13 @@ require 'ft_49_condition'
66
66
  require 'ft_50_xml_attribute'
67
67
  #require 'ft_51_stack'
68
68
  require 'ft_52_obs_participant'
69
+ require 'ft_53_null_noop_participant'
70
+ require 'ft_54_listen'
71
+ require 'ft_55_ptimeout'
72
+ require 'ft_56_timeout'
73
+ require 'ft_57_a'
69
74
 
70
75
  require 'ft_32_journal'
76
+ require 'ft_32c_journal'
77
+ require 'ft_32d_journal'
71
78
 
@@ -124,7 +124,7 @@ class HParticipantTest < Test::Unit::TestCase
124
124
 
125
125
  id = @engine.launch(HpDefinition0)
126
126
 
127
- sleep 0.100
127
+ sleep 0.300
128
128
 
129
129
  assert_equal @hpAlice.size, 1
130
130
  assert_equal @hpBob.size, 0
@@ -140,7 +140,7 @@ class HParticipantTest < Test::Unit::TestCase
140
140
 
141
141
  @hpBob.proceed wi
142
142
 
143
- sleep 0.100
143
+ sleep 0.300
144
144
 
145
145
  assert_equal @hpAlice.size, 0
146
146
  assert_equal @hpBob.size, 1
@@ -156,7 +156,7 @@ class HParticipantTest < Test::Unit::TestCase
156
156
 
157
157
  @hpAlice.forward wi
158
158
 
159
- sleep 0.100
159
+ sleep 0.300
160
160
 
161
161
  assert_equal @hpAlice.size, 0
162
162
  assert_equal @hpBob.size, 0
data/test/obs_test.rb ADDED
@@ -0,0 +1,115 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Sun Oct 29 16:18:25 JST 2006
8
+ #
9
+
10
+ require 'test/unit'
11
+
12
+ require 'openwfe/util/observable'
13
+
14
+
15
+ #
16
+ # testing the observer module (mixin)
17
+ #
18
+
19
+ class ObsTest < Test::Unit::TestCase
20
+
21
+ #def setup
22
+ #end
23
+
24
+ #def teardown
25
+ #end
26
+
27
+ class Observed
28
+ include OpenWFE::Observable
29
+
30
+ def initialize
31
+ super
32
+ @observers = {}
33
+ end
34
+
35
+ public :onotify
36
+ end
37
+
38
+ def test_0
39
+
40
+ $s = nil
41
+
42
+ observed = Observed.new
43
+
44
+ observed.add_observer :channel0 do
45
+ $s = 0
46
+ end
47
+
48
+ observer1 = Object.new
49
+ class << observer1
50
+ def call channel, *args
51
+ $s = 1
52
+ end
53
+ end
54
+ observed.add_observer :channel1, observer1
55
+
56
+ observer2 = lambda do |channel, args|
57
+ $s = 2
58
+ end
59
+ observed.add_observer :channel2, observer2
60
+
61
+ observed.onotify :channel0, :nothing
62
+ assert_equal $s, 0
63
+
64
+ observed.onotify :channel1, :nothing
65
+ assert_equal $s, 1
66
+
67
+ observed.onotify :channel2, :nothing
68
+ assert_equal $s, 2
69
+
70
+ $s = nil
71
+
72
+ observed.remove_observer observer2, :channel99
73
+
74
+ observed.onotify :channel2, :nothing
75
+ assert_equal $s, 2
76
+
77
+ $s = nil
78
+
79
+ observed.remove_observer observer2
80
+
81
+ observed.onotify :channel2, :nothing
82
+ assert_nil $s
83
+
84
+ $s = nil
85
+
86
+ observed.remove_observer observer1, :channel1
87
+
88
+ observed.onotify :channel1, :nothing
89
+ assert_nil $s
90
+ end
91
+
92
+
93
+ def test_1
94
+
95
+ $s = nil
96
+
97
+ observed = Observed.new
98
+
99
+ observed.add_observer :channel0 do
100
+ $s = 0
101
+ end
102
+ observed.add_observer "channel[0-9]+" do
103
+ $s = 9
104
+ end
105
+
106
+ $s = nil
107
+ observed.onotify "channel2", :nothing
108
+ assert_equal $s, 9
109
+
110
+ $s = nil
111
+ observed.onotify "channelZ", :nothing
112
+ assert_nil $s
113
+ end
114
+
115
+ end