openwferu 0.9.1 → 0.9.2

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 (104) hide show
  1. data/{README → README.txt} +16 -13
  2. data/bin/validate-workflow.rb +46 -22
  3. data/examples/README.txt +8 -0
  4. data/examples/homeworkreview.rb +66 -0
  5. data/examples/quotereporter.rb +154 -0
  6. data/lib/{openwferu.rb → openwfe.rb} +6 -8
  7. data/lib/{ru → openwfe}/contextual.rb +11 -3
  8. data/lib/{ru → openwfe/engine}/engine.rb +50 -36
  9. data/lib/{ru/participant.rb → openwfe/engine/file_persisted_engine.rb} +21 -22
  10. data/lib/openwfe/expool/expressionpool.rb +534 -0
  11. data/lib/openwfe/expool/expstorage.rb +184 -0
  12. data/lib/openwfe/expool/journalexpstorage.rb +312 -0
  13. data/lib/openwfe/expool/yamlexpstorage.rb +127 -0
  14. data/lib/{ru → openwfe/expressions}/environment.rb +19 -14
  15. data/lib/{ru → openwfe/expressions}/expressionmap.rb +48 -21
  16. data/lib/{ru → openwfe/expressions}/fe_concurrence.rb +111 -35
  17. data/lib/openwfe/expressions/fe_cursor.rb +236 -0
  18. data/lib/{ru → openwfe/expressions}/fe_define.rb +5 -5
  19. data/lib/openwfe/expressions/fe_fqv.rb +99 -0
  20. data/lib/openwfe/expressions/fe_iterator.rb +182 -0
  21. data/lib/{ru/fe_misc.rb → openwfe/expressions/fe_losfor.rb} +14 -56
  22. data/lib/openwfe/expressions/fe_misc.rb +102 -0
  23. data/lib/{ru → openwfe/expressions}/fe_participant.rb +25 -14
  24. data/lib/{ru → openwfe/expressions}/fe_raw.rb +39 -75
  25. data/lib/{ru/fe_base.rb → openwfe/expressions/fe_sequence.rb} +40 -35
  26. data/lib/{ru → openwfe/expressions}/fe_subprocess.rb +30 -14
  27. data/lib/{ru → openwfe/expressions}/fe_time.rb +59 -31
  28. data/lib/{ru → openwfe/expressions}/fe_utils.rb +42 -26
  29. data/lib/{ru → openwfe/expressions}/fe_value.rb +20 -14
  30. data/lib/openwfe/expressions/flowexpression.rb +434 -0
  31. data/lib/openwfe/expressions/raw_prog.rb +391 -0
  32. data/lib/openwfe/expressions/raw_xml.rb +128 -0
  33. data/lib/openwfe/flowexpressionid.rb +148 -0
  34. data/lib/{ru → openwfe}/logging.rb +10 -6
  35. data/lib/{osocket.rb → openwfe/osocket.rb} +36 -35
  36. data/lib/{otime.rb → openwfe/otime.rb} +71 -21
  37. data/lib/openwfe/participants/atomparticipants.rb +144 -0
  38. data/lib/openwfe/participants/enoparticipant.rb +73 -0
  39. data/lib/openwfe/participants/participant.rb +85 -0
  40. data/lib/{ru → openwfe/participants}/participantmap.rb +40 -12
  41. data/lib/{ru → openwfe/participants}/participants.rb +41 -12
  42. data/lib/openwfe/participants/soapparticipants.rb +96 -0
  43. data/lib/{controlclient.rb → openwfe/rest/controlclient.rb} +12 -13
  44. data/lib/{definitions.rb → openwfe/rest/definitions.rb} +3 -3
  45. data/lib/{exception.rb → openwfe/rest/exception.rb} +3 -3
  46. data/lib/{restclient.rb → openwfe/rest/restclient.rb} +13 -22
  47. data/lib/{worklistclient.rb → openwfe/rest/worklistclient.rb} +33 -46
  48. data/lib/openwfe/rest/xmlcodec.rb +575 -0
  49. data/lib/{ru → openwfe}/rudefinitions.rb +32 -4
  50. data/lib/{ru → openwfe}/service.rb +20 -8
  51. data/lib/openwfe/storage/yamlfilestorage.rb +159 -0
  52. data/lib/{ru → openwfe/util}/dollar.rb +10 -8
  53. data/lib/openwfe/util/lru_cache.rb +149 -0
  54. data/lib/{ru → openwfe/util}/scheduler.rb +18 -10
  55. data/lib/{ru → openwfe/util}/schedulers.rb +7 -7
  56. data/lib/{utils.rb → openwfe/utils.rb} +93 -9
  57. data/lib/openwfe/workitem.rb +366 -0
  58. data/lib/openwfe/worklist/worklists.rb +175 -0
  59. data/test/README.txt +27 -0
  60. data/test/atomtest.rb +99 -0
  61. data/test/crontest.rb +58 -0
  62. data/test/dollartest.rb +3 -3
  63. data/test/feitest.rb +42 -14
  64. data/test/file_persistence_test.rb +93 -0
  65. data/test/flowtestbase.rb +72 -26
  66. data/test/ft_0.rb +1 -97
  67. data/test/ft_0b_sequence.rb +33 -0
  68. data/test/ft_0c_testname.rb +29 -0
  69. data/test/ft_10_loop.rb +48 -0
  70. data/test/ft_11_ppd.rb +292 -0
  71. data/test/ft_12_blockparticipant.rb +45 -0
  72. data/test/ft_13_eno.rb +51 -0
  73. data/test/ft_14_subprocess.rb +90 -0
  74. data/test/ft_14b_subprocess.rb +40 -0
  75. data/test/ft_15_iterator.rb +70 -0
  76. data/test/ft_16_fqv.rb +57 -0
  77. data/test/ft_1_unset.rb +25 -1
  78. data/test/ft_2_concurrence.rb +10 -5
  79. data/test/ft_3_equals.rb +35 -1
  80. data/test/ft_4_misc.rb +16 -1
  81. data/test/ft_5_time.rb +26 -1
  82. data/test/ft_6_lambda.rb +2 -1
  83. data/test/{ft_7_losfor.rb → ft_7_lose.rb} +41 -35
  84. data/test/ft_8_forget.rb +46 -0
  85. data/test/ft_9_cursor.rb +94 -0
  86. data/test/journal_persistence_test.rb +147 -0
  87. data/test/misctest.rb +13 -9
  88. data/test/rake_ptest.rb +18 -0
  89. data/test/rake_qtest.rb +43 -0
  90. data/test/{fulltest.rb → rake_test.rb} +2 -2
  91. data/test/raw_prog_test.rb +236 -0
  92. data/test/rest_test.rb +189 -0
  93. data/test/rutest_utils.rb +1 -1
  94. data/test/timetest.rb +42 -34
  95. metadata +125 -82
  96. data/lib/codec.rb +0 -573
  97. data/lib/flowexpressionid.rb +0 -139
  98. data/lib/ru/expressionpool.rb +0 -382
  99. data/lib/ru/expressionstorage.rb +0 -99
  100. data/lib/ru/flowexpression.rb +0 -272
  101. data/lib/ru/ruutils.rb +0 -70
  102. data/lib/test.rb +0 -222
  103. data/lib/workitem.rb +0 -249
  104. data/test/quicktest.rb +0 -21
@@ -0,0 +1,46 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Dec 25 14:27:48 JST 2006
8
+ #
9
+
10
+ require 'flowtestbase'
11
+
12
+
13
+ class FlowTest8 < FlowTestBase
14
+
15
+ #def setup
16
+ #end
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ def test_forget_0
22
+ dotest(\
23
+ '<process-definition name="'+test_name+'''" revision="0">
24
+ <sequence>
25
+ <concurrence
26
+ count="1"
27
+ >
28
+ <forget>
29
+ <print>a</print>
30
+ </forget>
31
+ <sequence>
32
+ <sleep for="500" />
33
+ <print>b</print>
34
+ </sequence>
35
+ </concurrence>
36
+ <print>c</print>
37
+ </sequence>
38
+ </process-definition>''',
39
+ """a
40
+ c""",
41
+ 0.1,
42
+ false)
43
+ end
44
+
45
+ end
46
+
@@ -0,0 +1,94 @@
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
+
12
+
13
+ class FlowTest9 < FlowTestBase
14
+
15
+ #def setup
16
+ #end
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ def test_cursor_0
22
+ dotest(\
23
+ '<process-definition name="'+test_name+'''" revision="0">
24
+ <cursor>
25
+ <print>a</print>
26
+ <print>b</print>
27
+ </cursor>
28
+ </process-definition>''',
29
+ """a
30
+ b""")
31
+ end
32
+
33
+ def test_cursor_1
34
+ dotest(\
35
+ '<process-definition name="'+test_name+'''" revision="0">
36
+ <cursor>
37
+ <print>a</print>
38
+ <print>b</print>
39
+ <cancel />
40
+ <print>c</print>
41
+ </cursor>
42
+ </process-definition>''',
43
+ """a
44
+ b""")
45
+ end
46
+
47
+ def test_cursor_2
48
+ dotest(\
49
+ '<process-definition name="'+test_name+'''" revision="0">
50
+ <cursor>
51
+ <print>a</print>
52
+ <print>b</print>
53
+ <skip step="2" />
54
+ <print>c</print>
55
+ </cursor>
56
+ </process-definition>''',
57
+ """a
58
+ b""")
59
+ end
60
+
61
+ def test_cursor_3
62
+ dotest(\
63
+ '<process-definition name="'+test_name+'''" revision="0">
64
+ <cursor>
65
+ <print>a</print>
66
+ <skip step="2" />
67
+ <print>b</print>
68
+ <print>c</print>
69
+ </cursor>
70
+ </process-definition>''',
71
+ """a
72
+ c""")
73
+ end
74
+
75
+ def test_cursor_4
76
+ dotest(\
77
+ '<process-definition name="'+test_name+'''" revision="0">
78
+ <sequence>
79
+ <cursor>
80
+ <print>a</print>
81
+ <set field="__cursor_command__" value="skip 2" />
82
+ <print>b</print>
83
+ <print>c</print>
84
+ </cursor>
85
+ <print>d</print>
86
+ </sequence>
87
+ </process-definition>''',
88
+ """a
89
+ c
90
+ d""")
91
+ end
92
+
93
+ end
94
+
@@ -0,0 +1,147 @@
1
+ require 'test/unit'
2
+ #require 'yaml'
3
+
4
+ require 'openwfe/flowexpressionid'
5
+ require 'openwfe/expool/journalexpstorage'
6
+ require 'openwfe/expressions/expressionmap'
7
+
8
+ include OpenWFE
9
+
10
+
11
+ class JournalPersistenceTest < Test::Unit::TestCase
12
+
13
+ #
14
+ # test journalling and appending to journal including:
15
+ # - inserting :put and :del entries in the journal
16
+ # - formatting for easy reading
17
+ # - replay
18
+ #
19
+ def test_journalling_persistence
20
+ fei = new_fei()
21
+ feip = fei.parent_workflow_instance_id
22
+
23
+ fes = JournalizedExpressionStorage.new("journal",nil)
24
+ fes.clean(feip)
25
+
26
+ fes[fei] = SequenceExpression.new(fei, nil, nil, nil, nil)
27
+ fes.remove(fei, nil)
28
+
29
+ assert fes.size(feip) == 2, "expected 2 entries in the journal"
30
+
31
+ fes.to_human_s(feip)
32
+
33
+ # prepare replay
34
+ backup_journal = fes.backup(feip)
35
+ fes.clean(fei)
36
+ assert fes.size(feip) == 0, "storage is not empty"
37
+
38
+ # replay
39
+ replayer = JournalReplay.new(fes)
40
+ replayer.replay(backup_journal)
41
+ assert fes.size(feip) == 2, "2 entries have not been replayed"
42
+ end
43
+
44
+ def test_journal_truncate
45
+ fes = JournalizedExpressionStorage.new("journal",nil)
46
+ fei = new_fei()
47
+ fei.workflow_instance_id = '789129'
48
+ feip = fei.parent_workflow_instance_id
49
+ fes.clean(feip)
50
+
51
+ assert fes.size(feip) == 0
52
+
53
+ fe = SequenceExpression.new(fei, nil, nil, nil, nil)
54
+
55
+ 24.times { |e|
56
+ time = Time.gm(2007,01,17,e,00,00,00)
57
+ entry = JournalEntry.new(:put, fei, fe, time)
58
+ fes.write_to_journal(entry)
59
+ }
60
+ assert fes.size(feip) == 24
61
+
62
+ # truncate by number of lines
63
+ assert fes.truncate!(feip, 10) == 10
64
+ assert fes.size(feip) == 10
65
+
66
+ # truncate by date
67
+ date_limit = 5
68
+ assert fes.truncate!(feip, nil, Time.gm(2007,01,17,date_limit,00,00,00)) == 5
69
+ assert fes.size(feip) == 5
70
+
71
+ end
72
+
73
+ #
74
+ # no persistence, just test the journal entry class with a put
75
+ def test_journal_entry_put
76
+ fei = new_fei()
77
+
78
+ fe = SequenceExpression.new(fei, nil, nil, nil, nil)
79
+ journal_entry = JournalEntry.new(:put,fei,fe)
80
+
81
+ journal_string = journal_entry.to_s
82
+ journal_entry_read = JournalEntry.parse_from_string(journal_string)
83
+
84
+ assert journal_entry_read.action == journal_entry.action
85
+ assert journal_entry_read.action == :put
86
+ assert journal_entry_read.fei.to_s == journal_entry.fei.to_s
87
+
88
+ yamldump = YAML.dump(journal_entry_read.fe)
89
+
90
+ assert journal_entry_read.fe != nil, "retrieved journal entry had a null expression"
91
+ assert journal_entry_read.fe.to_s == journal_entry.fe.to_s, "string comparison failed for flow expression"
92
+ assert yamldump.index("SequenceExpression") != nil
93
+ end
94
+
95
+ #
96
+ # no persistence, just test the journal entry class with a del
97
+ def test_journal_entry_del
98
+ fei = new_fei()
99
+
100
+ fe = SequenceExpression.new(fei, nil, nil, nil, nil)
101
+ journal_entry = JournalEntry.new(:del,fei,fe)
102
+
103
+ journal_string = journal_entry.to_s
104
+ journal_entry_read = JournalEntry.parse_from_string(journal_string)
105
+
106
+ assert journal_entry_read.action.to_s == journal_entry.action.to_s
107
+ assert journal_entry_read.fei.to_s == journal_entry.fei.to_s
108
+ assert journal_entry_read.fe == nil
109
+
110
+ end
111
+
112
+ #
113
+ # this actually test the yaml output is expanded and readable, after the journal entry has been parsed
114
+ def test_human_readable_journal_entry
115
+ fei = new_fei()
116
+ fe = SequenceExpression.new(fei, nil, nil, nil, nil)
117
+ journal_entry = JournalEntry.new(:put,fei,fe)
118
+
119
+ # test on a freshly made journal entry
120
+ assert journal_entry_assert(journal_entry)
121
+
122
+ # test on a re-parsed journal entry
123
+ assert journal_entry_assert(JournalEntry.parse_from_string(journal_entry.to_s))
124
+ end
125
+
126
+ protected
127
+
128
+ def journal_entry_assert (journal_entry)
129
+ human = journal_entry.to_human_s
130
+ human.index("SequenceExpression") != nil
131
+ end
132
+
133
+ def new_fei ()
134
+ fei = OpenWFE::FlowExpressionId.new()
135
+ fei.owfe_version = OPENWFE_VERSION
136
+ fei.engine_id = 'this'
137
+ fei.initial_engine_id = 'that'
138
+ fei.workflow_definition_url = 'http://test/test.xml'
139
+ fei.workflow_definition_name = 'test'
140
+ fei.workflow_definition_revision = '1.0'
141
+ fei.workflow_instance_id = '123456'
142
+ fei.expression_name = 'do-test'
143
+ fei.expression_id = '0.0'
144
+ return fei
145
+ end
146
+
147
+ end
@@ -1,6 +1,6 @@
1
1
 
2
2
  #
3
- # Testing OpenWFEru
3
+ # Testing OpenWFE
4
4
  #
5
5
  # John Mettraux at openwfe.org
6
6
  #
@@ -8,10 +8,9 @@
8
8
  #
9
9
 
10
10
  require 'test/unit'
11
- require 'utils'
12
- require 'ru/ruutils'
13
- require 'ru/expressionmap'
14
- require 'ru/fe_define'
11
+ require 'openwfe/utils'
12
+ require 'openwfe/expressions/fe_define'
13
+ require 'openwfe/expressions/expressionmap'
15
14
 
16
15
  #
17
16
  # testing misc things
@@ -27,17 +26,22 @@ class MiscTest < Test::Unit::TestCase
27
26
 
28
27
  def test_starts_with
29
28
  assert \
30
- OpenWFEru::starts_with("//a", "//")
29
+ OpenWFE::starts_with("//a", "//")
31
30
  assert \
32
- (not OpenWFEru::starts_with("/a", "//"))
31
+ (not OpenWFE::starts_with("/a", "//"))
32
+ end
33
+
34
+ def test_ends_with
35
+ assert \
36
+ OpenWFE::ends_with("c'est la fin", "fin")
33
37
  end
34
38
 
35
39
  def test_expression_map
36
40
 
37
- em = OpenWFEru::ExpressionMap.new('expressionmap', {})
41
+ em = OpenWFE::ExpressionMap.new('expressionmap', {})
38
42
 
39
43
  assert \
40
- em.get_class('process-definition') == OpenWFEru::DefineExpression,
44
+ em.get_class('process-definition') == OpenWFE::DefineExpression,
41
45
  "class of 'process-definition' should be DefineExpression"
42
46
  assert \
43
47
  em.is_definition?('process-definition'),
@@ -0,0 +1,18 @@
1
+ #
2
+ # Testing OpenWFE
3
+ #
4
+ # John Mettraux at openwfe.org
5
+ #
6
+ # Mon Oct 9 22:19:44 JST 2006
7
+ #
8
+
9
+ #require 'test/unit'
10
+
11
+ require 'fileutils'
12
+ FileUtils.remove_dir "work" if File.exist? "work"
13
+
14
+ require 'openwfe/engine/file_persisted_engine'
15
+ $WORKFLOW_ENGINE_CLASS = OpenWFE::FilePersistedEngine
16
+
17
+ require 'rake_qtest'
18
+
@@ -0,0 +1,43 @@
1
+ #
2
+ # Testing OpenWFE
3
+ #
4
+ # John Mettraux at openwfe.org
5
+ #
6
+ # Mon Oct 9 22:19:44 JST 2006
7
+ #
8
+
9
+ #require 'test/unit'
10
+
11
+ File.delete('engine.log') \
12
+ if File.exist? 'engine.log'
13
+
14
+ require 'feitest'
15
+ require 'dollartest'
16
+ require 'misctest'
17
+ require 'timetest'
18
+ require 'raw_prog_test'
19
+ require 'file_persistence_test'
20
+
21
+ #require 'journal_persistence_test'
22
+ #
23
+ # disabled for now, as journal persistence will undergo a redesign soon
24
+
25
+ require 'ft_0'
26
+ require 'ft_0b_sequence'
27
+ require 'ft_0c_testname'
28
+ require 'ft_1_unset'
29
+ require 'ft_2_concurrence'
30
+ require 'ft_3_equals'
31
+ require 'ft_4_misc'
32
+ require 'ft_6_lambda'
33
+ require 'ft_7_lose'
34
+ require 'ft_8_forget'
35
+ require 'ft_9_cursor'
36
+ require 'ft_10_loop'
37
+ require 'ft_11_ppd'
38
+ require 'ft_12_blockparticipant'
39
+ require 'ft_14_subprocess'
40
+ require 'ft_14b_subprocess'
41
+ require 'ft_15_iterator'
42
+ require 'ft_16_fqv'
43
+
@@ -1,5 +1,5 @@
1
1
  #
2
- # Testing OpenWFEru
2
+ # Testing OpenWFE
3
3
  #
4
4
  # John Mettraux at openwfe.org
5
5
  #
@@ -8,7 +8,7 @@
8
8
 
9
9
  #require 'test/unit'
10
10
 
11
- require 'quicktest'
12
11
  require 'ft_5_time'
13
12
  require 'timetest'
13
+ require 'rake_qtest'
14
14
 
@@ -0,0 +1,236 @@
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 'test/unit'
11
+ require 'openwfe/expressions/raw_prog'
12
+
13
+
14
+ class RawProgTest < Test::Unit::TestCase
15
+
16
+ #def setup
17
+ #end
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ $EXPRESSION_NAMES = [
23
+ "process-definition",
24
+ "sequence",
25
+ "participant",
26
+ "set",
27
+ "if",
28
+ "equals",
29
+ "print"
30
+ ]
31
+
32
+ XML_DEF = """
33
+ <process-definition name='test0' revision='0'>
34
+ <sequence>
35
+ <participant ref='a'/>
36
+ <participant ref='b'/>
37
+ </sequence>
38
+ </process-definition>""".strip
39
+
40
+
41
+ #
42
+ # TEST 0
43
+ #
44
+
45
+ class TestDefinition < OpenWFE::ProcessDefinition
46
+ def make
47
+ process_definition :name => "test0", :revision => "0" do
48
+ sequence do
49
+ participant :ref => "a"
50
+ participant :ref => "b"
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ def test_prog_0
57
+
58
+ #s = TestDefinition.new($EXPRESSION_NAMES).make.to_s
59
+ s = TestDefinition.new().make.to_s
60
+
61
+ #puts
62
+ #puts s
63
+
64
+ assert \
65
+ s == XML_DEF,
66
+ "parsing failed (0)"
67
+ end
68
+
69
+ def test_prog_0b
70
+
71
+ #s = TestDefinition.new($EXPRESSION_NAMES).make.to_s
72
+ s = TestDefinition.do_make.to_s
73
+
74
+ #puts
75
+ #puts s
76
+
77
+ assert \
78
+ s == XML_DEF,
79
+ "parsing failed (0b)"
80
+ end
81
+
82
+
83
+ #
84
+ # TEST 1
85
+ #
86
+
87
+ def test_prog_1
88
+
89
+ #pg = OpenWFE::ProcessDefinition.new($EXPRESSION_NAMES)
90
+ pg = OpenWFE::ProcessDefinition.new()
91
+
92
+ class << pg
93
+ def my_proc
94
+ process_definition :name => "test0", :revision => "0" do
95
+ sequence do
96
+ participant :ref => "a"
97
+ participant :ref => "b"
98
+ end
99
+ end
100
+ end
101
+ end
102
+ pdef = pg.my_proc
103
+ s = pdef.to_s
104
+
105
+ #puts s
106
+
107
+ assert \
108
+ s == XML_DEF,
109
+ "parsing failed (1)"
110
+ end
111
+
112
+
113
+ #
114
+ # TEST 2
115
+ #
116
+
117
+ class TestDefinition2 < OpenWFE::ProcessDefinition
118
+ def make
119
+ process_definition :name => "test2", :revision => "0" do
120
+ sequence do
121
+ set :field => "toto" do
122
+ "nada"
123
+ end
124
+ participant :ref => "b"
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ XML_DEF2 = """
131
+ <process-definition name='test2' revision='0'>
132
+ <sequence>
133
+ <set field='toto'>nada</set>
134
+ <participant ref='b'/>
135
+ </sequence>
136
+ </process-definition>""".strip
137
+
138
+ def test_prog_2
139
+
140
+ s = TestDefinition2.do_make.to_s
141
+ #puts s
142
+
143
+ assert \
144
+ s == XML_DEF2,
145
+ "parsing failed (2)"
146
+
147
+ #puts
148
+ #puts TestDefinition2.do_make.to_code_s
149
+ end
150
+
151
+
152
+ #
153
+ # TEST 3
154
+ #
155
+
156
+ class TestDefinition3 < OpenWFE::ProcessDefinition
157
+ def make
158
+ process_definition :name => "test3", :revision => "0" do
159
+ _if do
160
+ equals :field_value => "nada", :other_value => "surf"
161
+ participant :ref => "b"
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ XML_DEF3 = """
168
+ <process-definition name='test3' revision='0'>
169
+ <if>
170
+ <equals field-value='nada' other-value='surf'/>
171
+ <participant ref='b'/>
172
+ </if>
173
+ </process-definition>""".strip
174
+
175
+ CODE_DEF3 = """
176
+ process_definition :name => 'test3', :revision => '0' do
177
+ _if do
178
+ equals :field-value => 'nada', :other-value => 'surf'
179
+ participant :ref => 'b'
180
+ end
181
+ end""".strip
182
+
183
+ def test_prog_3
184
+
185
+ s = TestDefinition3.do_make.to_s
186
+ #puts s
187
+
188
+ assert \
189
+ s == XML_DEF3,
190
+ "parsing failed (3)"
191
+
192
+ #puts
193
+ #puts TestDefinition3.do_make.to_code_s
194
+
195
+ assert \
196
+ TestDefinition3.do_make.to_code_s == CODE_DEF3,
197
+ "to_code_s() not working properly (3)"
198
+ end
199
+
200
+ #
201
+ # TEST 4
202
+ #
203
+
204
+ class TestDefinition4 < OpenWFE::ProcessDefinition
205
+ def make
206
+ process_definition :name => "test4", :revision => "0" do
207
+ sequence do
208
+ 3.times { participant :ref => "b" }
209
+ end
210
+ end
211
+ end
212
+ end
213
+
214
+ CODE_DEF4 = """
215
+ process_definition :name => 'test4', :revision => '0' do
216
+ sequence do
217
+ participant :ref => 'b'
218
+ participant :ref => 'b'
219
+ participant :ref => 'b'
220
+ end
221
+ end""".strip
222
+
223
+ def test_prog_4
224
+
225
+ #puts
226
+ #puts TestDefinition4.do_make.to_s
227
+ #puts
228
+ #puts TestDefinition4.do_make.to_code_s
229
+
230
+ assert \
231
+ TestDefinition4.do_make.to_code_s == CODE_DEF4,
232
+ "to_code_s() not working properly (4)"
233
+ end
234
+
235
+ end
236
+