openwferu 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
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,93 @@
1
+
2
+ require 'test/unit'
3
+
4
+ require 'openwfe/expressions/expressionmap'
5
+ require 'openwfe/expool/expstorage'
6
+ require 'openwfe/expool/yamlexpstorage'
7
+ require 'openwfe/flowexpressionid'
8
+
9
+ include OpenWFE
10
+
11
+
12
+ class FilePersistenceTest < Test::Unit::TestCase
13
+
14
+ #
15
+ # test persistence using yaml
16
+ def test_yaml_persistence
17
+ fes = YamlFileExpressionStorage.new("yaml", nil)
18
+ test_persistence(fes)
19
+ end
20
+
21
+ #
22
+ # test cache persistence
23
+ def test_cache_persistence
24
+ fes = LruCachedExpressionStorage.new("lru", nil)
25
+ test_persistence(fes)
26
+ end
27
+
28
+ #
29
+ # flow expression check
30
+ def test_flow_expression
31
+ fei = new_fei()
32
+ fes = YamlFileExpressionStorage.new("yaml", nil)
33
+ fe = SequenceExpression.new(fei, nil, nil, nil, nil)
34
+ test_persistence(fes,fe)
35
+ end
36
+
37
+ #
38
+ # test UTF-8 data persistence
39
+ def test_utf8_with_file
40
+ workflow_definition_name = "みんなにARIGATOU★☆に関する最新の情報公開"
41
+ fei = new_fei(workflow_definition_name)
42
+ fe = SequenceExpression.new(fei, nil, nil, nil, nil)
43
+ fes = YamlFileExpressionStorage.new("yaml", nil)
44
+
45
+ loaded = test_persistence(fes,fe)
46
+ #puts loaded.fei.workflow_definition_name
47
+ assert loaded.fei.workflow_definition_name == fei.workflow_definition_name
48
+ end
49
+
50
+
51
+ protected
52
+
53
+ def test_persistence (fes, fe=nil)
54
+ fei = new_fei()
55
+ fes.remove(fei,nil) if(fes.has_key?(fei))
56
+
57
+ raw =
58
+ if fe == nil
59
+ RawExpression.new(fei, 'parent', 'env', nil, nil)
60
+ else
61
+ fe
62
+ 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
+ fes[fei]=raw
66
+ assert fes.has_key?(fei)
67
+
68
+ loaded = fes[fei]
69
+
70
+ fes.remove(fei,nil)
71
+ assert !(fes.has_key?(fei))
72
+ return loaded
73
+ end
74
+
75
+ def new_fei (definition_name = nil)
76
+ fei = OpenWFE::FlowExpressionId.new()
77
+ fei.owfe_version = OPENWFE_VERSION
78
+ fei.engine_id = 'this'
79
+ fei.initial_engine_id = 'that'
80
+ fei.workflow_definition_url = 'http://test/test.xml'
81
+ fei.workflow_definition_name = if definition_name == nil
82
+ 'test'
83
+ else
84
+ definition_name
85
+ end
86
+ fei.workflow_definition_revision = '1.0'
87
+ fei.workflow_instance_id = '1234568'
88
+ fei.expression_name = 'do-test'
89
+ fei.expression_id = '0.0'
90
+ return fei
91
+ end
92
+
93
+ end
@@ -1,6 +1,5 @@
1
-
2
1
  #
3
- # Testing OpenWFEru
2
+ # Testing OpenWFE
4
3
  #
5
4
  # John Mettraux at openwfe.org
6
5
  #
@@ -10,21 +9,40 @@
10
9
  #
11
10
 
12
11
  require 'test/unit'
13
- require 'workitem'
14
- require 'ru/engine'
15
- require 'ru/rudefinitions'
16
- require 'ru/participants'
12
+
13
+ require 'openwfe/workitem'
14
+ require 'openwfe/engine/engine'
15
+ require 'openwfe/rudefinitions'
16
+ require 'openwfe/participants/participants'
17
+
17
18
  require 'rutest_utils'
18
19
 
20
+ include OpenWFE
21
+
22
+
23
+ $WORKFLOW_ENGINE_CLASS = Engine \
24
+ if not $WORKFLOW_ENGINE_CLASS
25
+
26
+ puts
27
+ puts "testing with engine of class " + $WORKFLOW_ENGINE_CLASS.to_s
28
+ puts
19
29
 
20
30
  class FlowTestBase < Test::Unit::TestCase
21
31
 
22
- #def setup
23
- #end
32
+ attr_reader \
33
+ :engine, :tracer
34
+
35
+ def setup
36
+
37
+ @engine = $WORKFLOW_ENGINE_CLASS.new()
38
+
39
+ @tracer = Tracer.new
40
+ @engine.application_context["__tracer"] = @tracer
41
+ end
24
42
 
25
43
  #def teardown
26
44
  #end
27
-
45
+
28
46
  def default_test ()
29
47
  assert true
30
48
  end
@@ -34,37 +52,49 @@ class FlowTestBase < Test::Unit::TestCase
34
52
  def test_name
35
53
  s = caller(1)[0]
36
54
  i = s.index('`')
37
- s = s[i+1..s.length-2]
55
+ #s = s[i+1..s.length-2]
56
+ s = s[i+6..s.length-2]
38
57
  return s
39
58
  end
40
59
 
41
- def dotest (flowDef, expectedTrace, sleepTime=0)
60
+ def dotest (flowDef, expectedTrace, sleepTime=0, allowRemainingExpressions=false)
42
61
 
43
- engine = OpenWFEru::Engine.new()
62
+ @engine.register_participant('test-.*', PrintParticipant.new())
44
63
 
45
- engine.application_context["__tracer"] = Tracer.new
64
+ @engine.register_participant('block-participant') do |workitem|
65
+ @tracer << "the block participant received a workitem"
66
+ @tracer << "\n"
67
+ end
46
68
 
47
- engine.register_participant('test-.*', OpenWFEru::PrintParticipant.new())
69
+ # @engine.register_participant(
70
+ # 'eno',
71
+ # EmailNotificationParticipant.new(
72
+ # "googlemail.l.google.com",
73
+ # 25,
74
+ # "eno@outoftheblue.co.jp",
75
+ # """Subject: test 0
76
+ #
77
+ #0 : ${r:Time.new}
78
+ #1 : ${f:customer_name}
79
+ # """))
48
80
 
49
81
  # register unique tracing participant
50
82
 
51
- li = OpenWFE::LaunchItem.new()
83
+ li = OpenWFE::LaunchItem.new(flowDef)
52
84
 
53
- li.workflowDefinitionUrl = "field:__definition"
54
-
55
- li.attributes['__definition'] = flowDef
56
- engine.launch(li)
85
+ @engine.launch(li)
57
86
 
58
87
  sleep(sleepTime)
59
88
 
60
- trace = engine.application_context["__tracer"].to_s
89
+ trace = @tracer.to_s
61
90
 
62
91
  #puts "...'#{trace}' ?= '#{expectedTrace}'"
63
92
 
64
- if expectedTrace.kind_of?([].class)
65
- result = true
93
+ if expectedTrace.kind_of? [].class
94
+
95
+ result = false
66
96
  expectedTrace.each do |etrace|
67
- result = result and trace == etrace
97
+ result = (result or (trace == etrace))
68
98
  end
69
99
  assert \
70
100
  result,
@@ -72,13 +102,28 @@ class FlowTestBase < Test::Unit::TestCase
72
102
  else
73
103
  assert \
74
104
  trace == expectedTrace, \
75
- "flow failed : '#{trace}' != '#{expectedTrace}'"
105
+ """flow failed :
106
+
107
+ '#{trace}'
108
+
109
+ !=
110
+
111
+ '#{expectedTrace}'
112
+ """
76
113
  end
77
114
 
115
+
78
116
  exp_storage = \
79
- engine.application_context[OpenWFEru::S_EXPRESSION_STORAGE]
117
+ engine.application_context[S_EXPRESSION_STORAGE]
118
+
119
+ if allowRemainingExpressions
120
+ exp_storage.purge
121
+ return
122
+ end
80
123
 
81
124
  if exp_storage.length != 1
125
+ puts
126
+ puts " remaining expressions : #{exp_storage.length}"
82
127
  puts
83
128
  puts exp_storage.to_s
84
129
  puts
@@ -86,7 +131,8 @@ class FlowTestBase < Test::Unit::TestCase
86
131
 
87
132
  assert \
88
133
  exp_storage.length == 1,
89
- "there are expressions remaining in the expression pool"
134
+ "there are expressions remaining in the expression pool " +
135
+ "(#{exp_storage.length})"
90
136
  end
91
137
 
92
138
  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
  #
@@ -32,17 +32,6 @@ class FlowTest0 < FlowTestBase
32
32
  </process-definition>''', "test-alpha")
33
33
  end
34
34
 
35
- def test_sequence
36
- dotest(\
37
- '''<process-definition name="n" revision="0">
38
- <sequence>
39
- <print>a</print>
40
- <print>b</print>
41
- </sequence>
42
- </process-definition>''', '''a
43
- b''')
44
- end
45
-
46
35
  def test_dollar_notation_0
47
36
  dotest(\
48
37
  '''<process-definition name="n" revision="0">
@@ -72,90 +61,5 @@ b''')
72
61
  </process-definition>''', 'X')
73
62
  end
74
63
 
75
- def test_subprocess_ref_0
76
- dotest(\
77
- '''<process-definition name="subtest0" revision="0">
78
-
79
- <subprocess ref="sub0" />
80
-
81
- <process-definition name="sub0">
82
- <print>ok</print>
83
- </process-definition>
84
-
85
- </process-definition>''', 'ok')
86
- end
87
-
88
- def test_subprocess_ref_1
89
- dotest(\
90
- '''<process-definition name="subtest0" revision="0">
91
-
92
- <sequence>
93
- <subprocess ref="sub0" />
94
- <subprocess ref="sub0" />
95
- </sequence>
96
-
97
- <process-definition name="sub0">
98
- <print>ok</print>
99
- </process-definition>
100
-
101
- </process-definition>''', '''ok
102
- ok''')
103
- end
104
-
105
- def test_subprocess_ref_2
106
- dotest(\
107
- '''<process-definition name="subtest0" revision="0">
108
-
109
- <sequence>
110
- <sub0 />
111
- <print>after</print>
112
- </sequence>
113
-
114
- <process-definition name="sub0">
115
- <print>ok</print>
116
- </process-definition>
117
-
118
- </process-definition>''', '''ok
119
- after''')
120
- end
121
-
122
- def test_subprocess_ref_3
123
- dotest(\
124
- '''<process-definition name="subtest0" revision="0">
125
-
126
- <sequence>
127
- <set variable="v" value="out" />
128
- <sub0 />
129
- <print>after : ${v}</print>
130
- </sequence>
131
-
132
- <process-definition name="sub0">
133
- <sequence>
134
- <set variable="v" value="in" />
135
- <print>ok : ${v}</print>
136
- </sequence>
137
- </process-definition>
138
-
139
- </process-definition>''', '''ok : in
140
- after : out''')
141
- end
142
-
143
- def test_subprocess_ref_4
144
- dotest(\
145
- '''<process-definition name="subtest0" revision="0">
146
-
147
- <sequence>
148
- <subprocess ref="sub0" a="A" b="B" c="C" />
149
- <sub0 a="A" b="B" c="C" />
150
- </sequence>
151
-
152
- <process-definition name="sub0">
153
- <print>${a}${b}${c}</print>
154
- </process-definition>
155
-
156
- </process-definition>''', '''ABC
157
- ABC''')
158
- end
159
-
160
64
  end
161
65
 
@@ -0,0 +1,33 @@
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 FlowTest0 < FlowTestBase
14
+
15
+ #def setup
16
+ #end
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ def test_sequence
22
+ dotest(\
23
+ '''<process-definition name="n" revision="0">
24
+ <sequence>
25
+ <print>a</print>
26
+ <print>b</print>
27
+ </sequence>
28
+ </process-definition>''', '''a
29
+ b''')
30
+ end
31
+
32
+ end
33
+
@@ -0,0 +1,29 @@
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 TestTestName < FlowTestBase
14
+
15
+ #def setup
16
+ #end
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ def test_test_name
22
+ dotest(\
23
+ """<process-definition name='#{test_name}' revision='0'>
24
+ <print>#{test_name}</print>
25
+ </process-definition>""", "test_name")
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,48 @@
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 FlowTest10 < FlowTestBase
14
+
15
+ #def setup
16
+ #end
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ 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(\
31
+ '<process-definition name="'+test_name+'''" revision="0">
32
+ <sequence>
33
+ <reval>$i = 0</reval>
34
+ <loop>
35
+ <print>${r:$i}</print>
36
+ <reval>$i = $i + 1</reval>
37
+ <if>
38
+ <equals value="${r:$i}" other-value="10" />
39
+ <break/>
40
+ </if>
41
+ </loop>
42
+ </sequence>
43
+ </process-definition>''',
44
+ s)
45
+ end
46
+
47
+ end
48
+