openwferu 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. data/examples/mano_tracker.rb +165 -0
  2. data/examples/scheduler_cron_usage.rb +46 -0
  3. data/examples/scheduler_usage.rb +54 -0
  4. data/lib/openwfe/contextual.rb +7 -1
  5. data/lib/openwfe/engine/engine.rb +58 -15
  6. data/lib/openwfe/expool/expressionpool.rb +116 -14
  7. data/lib/openwfe/expool/expstorage.rb +12 -12
  8. data/lib/openwfe/expool/journalexpstorage.rb +1 -1
  9. data/lib/openwfe/expool/yamlexpstorage.rb +58 -22
  10. data/lib/openwfe/expressions/environment.rb +32 -2
  11. data/lib/openwfe/expressions/expressionmap.rb +17 -0
  12. data/lib/openwfe/expressions/fe_condition.rb +122 -0
  13. data/lib/openwfe/expressions/fe_cursor.rb +14 -5
  14. data/lib/openwfe/expressions/fe_participant.rb +55 -4
  15. data/lib/openwfe/expressions/fe_raw.rb +43 -12
  16. data/lib/openwfe/expressions/fe_subprocess.rb +10 -0
  17. data/lib/openwfe/expressions/fe_time.rb +117 -22
  18. data/lib/openwfe/expressions/fe_value.rb +27 -8
  19. data/lib/openwfe/expressions/flowexpression.rb +13 -6
  20. data/lib/openwfe/expressions/raw_prog.rb +13 -11
  21. data/lib/openwfe/expressions/timeout.rb +94 -0
  22. data/lib/openwfe/flowexpressionid.rb +17 -19
  23. data/lib/openwfe/logging.rb +35 -16
  24. data/lib/openwfe/participants/atomparticipants.rb +31 -7
  25. data/lib/openwfe/participants/enoparticipant.rb +43 -3
  26. data/lib/openwfe/participants/participant.rb +21 -1
  27. data/lib/openwfe/participants/participantmap.rb +4 -2
  28. data/lib/openwfe/participants/participants.rb +12 -17
  29. data/lib/openwfe/participants/soapparticipants.rb +15 -3
  30. data/lib/openwfe/rudefinitions.rb +3 -0
  31. data/lib/openwfe/service.rb +8 -0
  32. data/lib/openwfe/storage/yamlfilestorage.rb +85 -47
  33. data/lib/openwfe/{otime.rb → util/otime.rb} +0 -0
  34. data/lib/openwfe/util/scheduler.rb +415 -231
  35. data/lib/openwfe/util/schedulers.rb +11 -3
  36. data/lib/openwfe/util/stoppable.rb +69 -0
  37. data/lib/openwfe/utils.rb +14 -25
  38. data/lib/openwfe/workitem.rb +12 -6
  39. data/lib/openwfe/worklist/storeparticipant.rb +145 -0
  40. data/test/{atomtest.rb → atom_test.rb} +0 -0
  41. data/test/{crontest.rb → cron_test.rb} +7 -6
  42. data/test/cronline_test.rb +51 -0
  43. data/test/{dollartest.rb → dollar_test.rb} +0 -0
  44. data/test/{feitest.rb → fei_test.rb} +0 -0
  45. data/test/file_persistence_test.rb +15 -9
  46. data/test/flowtestbase.rb +11 -5
  47. data/test/ft_0.rb +8 -0
  48. data/test/ft_10_loop.rb +72 -10
  49. data/test/ft_11_ppd.rb +49 -0
  50. data/test/ft_17_condition.rb +83 -0
  51. data/test/ft_18_pname.rb +59 -0
  52. data/test/hparticipant_test.rb +96 -0
  53. data/test/{misctest.rb → misc_test.rb} +1 -1
  54. data/test/rake_qtest.rb +10 -4
  55. data/test/rake_test.rb +12 -1
  56. data/test/raw_prog_test.rb +1 -1
  57. data/test/restart_cron_test.rb +78 -0
  58. data/test/restart_test.rb +79 -0
  59. data/test/scheduler_test.rb +92 -0
  60. data/test/{timetest.rb → time_test.rb} +3 -38
  61. data/test/timeout_test.rb +73 -0
  62. metadata +26 -11
  63. data/lib/openwfe/worklist/worklists.rb +0 -175
File without changes
File without changes
@@ -51,38 +51,44 @@ class FilePersistenceTest < Test::Unit::TestCase
51
51
  protected
52
52
 
53
53
  def test_persistence (fes, fe=nil)
54
+
54
55
  fei = new_fei()
55
- fes.remove(fei,nil) if(fes.has_key?(fei))
56
+ fes.delete(fei) if (fes.has_key?(fei))
56
57
 
57
58
  raw =
58
59
  if fe == nil
59
- RawExpression.new(fei, 'parent', 'env', nil, nil)
60
+ RawExpression.new(fei, 'parent', 'env', nil, nil)
60
61
  else
61
- fe
62
+ fe
62
63
  end
63
- assert (not fes.has_key?(fei)), "they key is present in the file system. Maybe a previous test did not delete the "
64
+
65
+ assert \
66
+ (not fes.has_key?(fei)),
67
+ "they key is present in the file system. "+
68
+ "Maybe a previous test did not delete the "
64
69
 
65
70
  fes[fei]=raw
66
71
  assert fes.has_key?(fei)
67
72
 
68
73
  loaded = fes[fei]
69
74
 
70
- fes.remove(fei,nil)
75
+ fes.delete(fei)
71
76
  assert !(fes.has_key?(fei))
72
77
  return loaded
73
78
  end
74
79
 
75
80
  def new_fei (definition_name = nil)
81
+
76
82
  fei = OpenWFE::FlowExpressionId.new()
77
83
  fei.owfe_version = OPENWFE_VERSION
78
84
  fei.engine_id = 'this'
79
85
  fei.initial_engine_id = 'that'
80
86
  fei.workflow_definition_url = 'http://test/test.xml'
81
87
  fei.workflow_definition_name = if definition_name == nil
82
- 'test'
83
- else
84
- definition_name
85
- end
88
+ 'test'
89
+ else
90
+ definition_name
91
+ end
86
92
  fei.workflow_definition_revision = '1.0'
87
93
  fei.workflow_instance_id = '1234568'
88
94
  fei.expression_name = 'do-test'
@@ -1,4 +1,4 @@
1
- #
1
+ #_
2
2
  # Testing OpenWFE
3
3
  #
4
4
  # John Mettraux at openwfe.org
@@ -40,8 +40,9 @@ class FlowTestBase < Test::Unit::TestCase
40
40
  @engine.application_context["__tracer"] = @tracer
41
41
  end
42
42
 
43
- #def teardown
44
- #end
43
+ def teardown
44
+ @engine.stop
45
+ end
45
46
 
46
47
  def default_test ()
47
48
  assert true
@@ -66,6 +67,10 @@ class FlowTestBase < Test::Unit::TestCase
66
67
  @tracer << "\n"
67
68
  end
68
69
 
70
+ @engine.register_participant('p-toto') do |workitem|
71
+ @tracer << "toto"
72
+ end
73
+
69
74
  # @engine.register_participant(
70
75
  # 'eno',
71
76
  # EmailNotificationParticipant.new(
@@ -113,8 +118,9 @@ class FlowTestBase < Test::Unit::TestCase
113
118
  end
114
119
 
115
120
 
116
- exp_storage = \
117
- engine.application_context[S_EXPRESSION_STORAGE]
121
+ #exp_storage = \
122
+ # engine.application_context[S_EXPRESSION_STORAGE]
123
+ exp_storage = engine.get_expression_storage
118
124
 
119
125
  if allowRemainingExpressions
120
126
  exp_storage.purge
@@ -61,5 +61,13 @@ class FlowTest0 < FlowTestBase
61
61
  </process-definition>''', 'X')
62
62
  end
63
63
 
64
+ def test_empty_pool
65
+ dotest(\
66
+ '''<process-definition name="n" revision="0">
67
+ <print>ok</print>
68
+ <print>nok</print>
69
+ </process-definition>''', "ok")
70
+ end
71
+
64
72
  end
65
73
 
@@ -10,6 +10,14 @@
10
10
  require 'flowtestbase'
11
11
 
12
12
 
13
+ $s = ""
14
+ 0.upto(9) do |i|
15
+ $s << i.to_s
16
+ $s << "\n"
17
+ end
18
+ $s = $s.strip()
19
+
20
+
13
21
  class FlowTest10 < FlowTestBase
14
22
 
15
23
  #def setup
@@ -19,15 +27,7 @@ class FlowTest10 < FlowTestBase
19
27
  #end
20
28
 
21
29
  def test_loop_0
22
-
23
- s = ""
24
- 0.upto(9) do |i|
25
- s << i.to_s
26
- s << "\n"
27
- end
28
- s = s.strip()
29
-
30
- dotest(\
30
+ dotest(
31
31
  '<process-definition name="'+test_name+'''" revision="0">
32
32
  <sequence>
33
33
  <reval>$i = 0</reval>
@@ -41,7 +41,69 @@ class FlowTest10 < FlowTestBase
41
41
  </loop>
42
42
  </sequence>
43
43
  </process-definition>''',
44
- s)
44
+ $s)
45
+ end
46
+
47
+ def test_loop_1
48
+ dotest(
49
+ '<process-definition name="'+test_name+'''" revision="0">
50
+ <sequence>
51
+ <reval>$i = 0</reval>
52
+ <loop>
53
+ <print>${r:$i}</print>
54
+ <reval>$i = $i + 1</reval>
55
+ <if rtest="$i == 10">
56
+ <break/>
57
+ </if>
58
+ </loop>
59
+ </sequence>
60
+ </process-definition>''',
61
+ $s)
62
+ end
63
+
64
+ def test_loop_2
65
+ dotest(
66
+ '<process-definition name="'+test_name+'''" 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="'+test_name+'''" 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="'+test_name+'''" 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)
45
107
  end
46
108
 
47
109
  end
@@ -288,5 +288,54 @@ b""")
288
288
  2""")
289
289
  end
290
290
 
291
+
292
+ #
293
+ # Test 7
294
+ #
295
+
296
+ class TestDefinition7 < ProcessDefinition
297
+ def make
298
+ _process_definition :name => "test7", :revision => "0" do
299
+ _sequence do
300
+ _print "a"
301
+ _print "b"
302
+ end
303
+ end
304
+ end
305
+ end
306
+
307
+ def test_ppd_7
308
+ #def xxxx_ppd_7
309
+
310
+ dotest(
311
+ TestDefinition7,
312
+ """a
313
+ b""")
314
+ end
315
+
316
+
317
+ #
318
+ # Test 8
319
+ #
320
+
321
+ class TestDefinition8 < ProcessDefinition
322
+ def make
323
+ process_definition :name => "test8", :revision => "0" do
324
+ toto
325
+ process_definition :name => "toto" do
326
+ _print "toto"
327
+ end
328
+ end
329
+ end
330
+ end
331
+
332
+ def test_ppd_8
333
+ #def xxxx_ppd_8
334
+
335
+ dotest(
336
+ TestDefinition8,
337
+ "toto")
338
+ end
339
+
291
340
  end
292
341
 
@@ -0,0 +1,83 @@
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 FlowTest17 < FlowTestBase
14
+
15
+ #def setup
16
+ #end
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ def test_condition_0
22
+ dotest(\
23
+ '''<process-definition name="con" revision="0">
24
+ <if test="a == a">
25
+ <print>ok</print>
26
+ </if>
27
+ </process-definition>''', "ok")
28
+ end
29
+
30
+ def test_condition_1
31
+ dotest(\
32
+ '''<process-definition name="con" revision="0">
33
+ <if test="a == b">
34
+ <print>ok</print>
35
+ </if>
36
+ </process-definition>''', "")
37
+ end
38
+
39
+ def test_condition_2
40
+ dotest(\
41
+ '''<process-definition name="con" revision="0">
42
+ <sequence>
43
+ <set field="toto" value="nada" />
44
+ <if test="${f:toto} == nada">
45
+ <print>ok</print>
46
+ </if>
47
+ </sequence>
48
+ </process-definition>''', "ok")
49
+ end
50
+
51
+ def test_condition_3
52
+ dotest(\
53
+ '''<process-definition name="con" revision="0">
54
+ <sequence>
55
+ <set field="toto" value="true" />
56
+ <if test="${f:toto}">
57
+ <print>ok</print>
58
+ </if>
59
+ </sequence>
60
+ </process-definition>''', "ok")
61
+ end
62
+
63
+ def test_condition_4
64
+ dotest(\
65
+ '''<process-definition name="con" revision="0">
66
+ <if rtest="1+2 == 3">
67
+ <print>ok</print>
68
+ </if>
69
+ </process-definition>''', "ok")
70
+ end
71
+
72
+ def test_condition_5
73
+ dotest(\
74
+ '''<process-definition name="con" revision="0">
75
+ <if test="1+2 == 3">
76
+ <print>ok</print>
77
+ <print>nok</print>
78
+ </if>
79
+ </process-definition>''', "nok")
80
+ end
81
+
82
+ end
83
+
@@ -0,0 +1,59 @@
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
+ require 'openwfe/expressions/raw_prog'
12
+
13
+ include OpenWFE
14
+
15
+
16
+ class FlowTest18 < FlowTestBase
17
+
18
+ #def setup
19
+ #end
20
+
21
+ #def teardown
22
+ #end
23
+
24
+ #
25
+ # Test 0
26
+ #
27
+
28
+ class TestDefinition0 < ProcessDefinition
29
+ def make
30
+ _process_definition :name => "test0", :revision => "0" do
31
+ p_toto
32
+ end
33
+ end
34
+ end
35
+
36
+ def test_0
37
+ #def xxxx__0
38
+
39
+ dotest(
40
+ TestDefinition0,
41
+ "toto")
42
+ end
43
+
44
+
45
+ #
46
+ # Test 1
47
+ #
48
+
49
+ def test_1
50
+ #def xxxx_1
51
+
52
+ dotest(\
53
+ """<process-definition name='test1' revision='0'>
54
+ <p-toto/>
55
+ </process-definition>""", "toto")
56
+ end
57
+
58
+ end
59
+
@@ -0,0 +1,96 @@
1
+ #
2
+ # Testing OpenWFE
3
+ #
4
+ # John Mettraux at openwfe.org
5
+ #
6
+ # Sun Oct 29 15:41:44 JST 2006
7
+ #
8
+ # Kita Yokohama
9
+ #
10
+
11
+ require 'test/unit'
12
+
13
+ #require 'openwfe/workitem'
14
+ require 'openwfe/flowexpressionid'
15
+ require 'openwfe/engine/engine'
16
+ require 'openwfe/expressions/raw_prog'
17
+ require 'openwfe/worklist/storeparticipant'
18
+
19
+ include OpenWFE
20
+
21
+
22
+ class HParticipantTest < Test::Unit::TestCase
23
+
24
+ def setup
25
+ @engine = Engine.new()
26
+ end
27
+
28
+ #def teardown
29
+ #end
30
+
31
+ class HpDefinition0 < ProcessDefinition
32
+ def make
33
+ process_definition :name => "hp0", :revision => "0" do
34
+ sequence do
35
+ participant :alice
36
+ participant :bob
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ def test_hp_0
43
+
44
+ hpAlice = HashParticipant.new
45
+ hpBob = HashParticipant.new
46
+
47
+ @engine.register_participant(:alice, hpAlice)
48
+ @engine.register_participant(:bob, hpBob)
49
+
50
+ id = @engine.launch(HpDefinition0)
51
+
52
+ assert \
53
+ (id.kind_of? FlowExpressionId),
54
+ "engine.launch() doesn't return an instance of FlowExpressionId "+
55
+ "but of #{id.class}"
56
+
57
+ #puts id.to_s
58
+
59
+ assert \
60
+ hpBob.size == 0
61
+ assert \
62
+ hpAlice.size == 1
63
+
64
+ wi = hpAlice.list_workitems(id.workflow_instance_id)[0]
65
+
66
+ assert \
67
+ wi != nil,
68
+ "didn't find wi for flow #{id.workflow_instance_id}"
69
+
70
+ wi.message = "Hello bob !"
71
+
72
+ hpAlice.forward(wi)
73
+
74
+ assert \
75
+ hpAlice.size == 0
76
+ assert \
77
+ hpBob.size == 1
78
+
79
+ wi = hpBob.list_workitems(id.workflow_instance_id)[0]
80
+
81
+ assert \
82
+ wi.message == "Hello bob !"
83
+
84
+ hpBob.proceed(wi)
85
+
86
+ assert \
87
+ hpAlice.size == 0
88
+ assert \
89
+ hpBob.size == 0
90
+
91
+ assert \
92
+ @engine.get_expression_storage.size == 1
93
+ end
94
+
95
+ end
96
+