openwferu 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/examples/mano_tracker.rb +11 -13
  2. data/lib/openwfe.rb +2 -4
  3. data/lib/openwfe/contextual.rb +8 -2
  4. data/lib/openwfe/engine/engine.rb +118 -2
  5. data/lib/openwfe/expool/expressionpool.rb +148 -53
  6. data/lib/openwfe/expool/expstorage.rb +36 -4
  7. data/lib/openwfe/expool/yamlexpstorage.rb +18 -0
  8. data/lib/openwfe/expressions/environment.rb +1 -1
  9. data/lib/openwfe/expressions/fe_misc.rb +14 -2
  10. data/lib/openwfe/expressions/fe_raw.rb +27 -11
  11. data/lib/openwfe/expressions/fe_subprocess.rb +45 -12
  12. data/lib/openwfe/expressions/fe_utils.rb +1 -1
  13. data/lib/openwfe/expressions/flowexpression.rb +5 -1
  14. data/lib/openwfe/expressions/raw_prog.rb +80 -32
  15. data/lib/openwfe/expressions/raw_xml.rb +10 -0
  16. data/lib/openwfe/flowexpressionid.rb +28 -7
  17. data/lib/openwfe/listeners/listener.rb +106 -0
  18. data/lib/openwfe/listeners/listeners.rb +140 -0
  19. data/lib/openwfe/listeners/socketlisteners.rb +239 -0
  20. data/lib/openwfe/listeners/sqslisteners.rb +145 -0
  21. data/lib/openwfe/participants/{csvparticipant.rb → csvparticipants.rb} +0 -0
  22. data/lib/openwfe/participants/{enoparticipant.rb → enoparticipants.rb} +1 -1
  23. data/lib/openwfe/participants/participantmap.rb +33 -1
  24. data/lib/openwfe/participants/participants.rb +99 -11
  25. data/lib/openwfe/participants/soapparticipants.rb +28 -8
  26. data/lib/openwfe/participants/socketparticipants.rb +172 -0
  27. data/lib/openwfe/participants/sqsparticipants.rb +121 -0
  28. data/lib/openwfe/rest/definitions.rb +1 -1
  29. data/lib/openwfe/{osocket.rb → rest/osocket.rb} +16 -8
  30. data/lib/openwfe/rest/xmlcodec.rb +41 -5
  31. data/lib/openwfe/storage/yamlfilestorage.rb +10 -13
  32. data/lib/openwfe/util/dollar.rb +23 -2
  33. data/lib/openwfe/util/otime.rb +1 -1
  34. data/lib/openwfe/util/safe.rb +149 -0
  35. data/lib/openwfe/util/scheduler.rb +47 -5
  36. data/lib/openwfe/util/sqs.rb +582 -0
  37. data/lib/openwfe/utils.rb +23 -0
  38. data/lib/openwfe/version.rb +1 -1
  39. data/lib/openwfe/workitem.rb +86 -3
  40. data/lib/openwfe/worklist/storeparticipant.rb +44 -4
  41. data/test/csv_test.rb +1 -1
  42. data/test/eno_test.rb +1 -1
  43. data/test/fei_test.rb +2 -15
  44. data/test/flowtestbase.rb +6 -2
  45. data/test/ft_11_ppd.rb +31 -0
  46. data/test/ft_13_eno.rb +1 -1
  47. data/test/ft_14b_subprocess.rb +74 -0
  48. data/test/ft_15_iterator.rb +0 -1
  49. data/test/ft_19_csv.rb +1 -1
  50. data/test/ft_20_cron.rb +1 -1
  51. data/test/ft_21_cron.rb +1 -1
  52. data/test/ft_27_getflowpos.rb +89 -0
  53. data/test/ft_28_fileparticipant.rb +65 -0
  54. data/test/ft_29_httprb.rb +95 -0
  55. data/test/ft_30_socketlistener.rb +197 -0
  56. data/test/ft_4_misc.rb +2 -1
  57. data/test/hash_test.rb +75 -0
  58. data/test/rake_qtest.rb +5 -4
  59. data/test/raw_prog_test.rb +205 -0
  60. data/test/rutest_utils.rb +16 -0
  61. data/test/safely_test.rb +89 -0
  62. data/test/scheduler_test.rb +71 -0
  63. data/test/sqs_test.rb +103 -0
  64. metadata +21 -6
  65. data/test/journal_persistence_test.rb +0 -147
@@ -117,8 +117,9 @@ class FlowTest4 < Test::Unit::TestCase
117
117
  <set variable="v">
118
118
  <!--
119
119
  <reval>self.lookup_variable("w") * 3</reval>
120
- -->
121
120
  <reval>lookup_variable("w") * 3</reval>
121
+ -->
122
+ <reval>"W" * 3</reval>
122
123
  </set>
123
124
  <print>${v}</print>
124
125
  </sequence>
@@ -0,0 +1,75 @@
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/workitem'
13
+ require 'openwfe/flowexpressionid'
14
+
15
+ require 'rutest_utils'
16
+
17
+
18
+ #
19
+ # testing fei.to_h and wi.to_h
20
+ #
21
+
22
+ class HashTest < Test::Unit::TestCase
23
+
24
+ #def setup
25
+ #end
26
+
27
+ #def teardown
28
+ #end
29
+
30
+ def test_fei_to_h
31
+
32
+ fei0 = new_fei
33
+ h = fei0.to_h
34
+ fei1 = OpenWFE::FlowExpressionId.from_h(h)
35
+
36
+ assert_equal fei0, fei1
37
+ end
38
+
39
+ def test_wi_to_h
40
+
41
+ wi0 = OpenWFE::InFlowWorkItem.new
42
+ wi0.fei = new_fei
43
+
44
+ h = wi0.to_h
45
+ #require 'pp'; pp h
46
+
47
+ wi1 = OpenWFE::InFlowWorkItem.from_h(h)
48
+
49
+ assert_equal wi0.fei, wi1.fei
50
+ assert_equal wi0.attributes.length, wi1.attributes.length
51
+
52
+ wi2 = OpenWFE::workitem_from_h(h)
53
+
54
+ assert_equal wi0.fei, wi2.fei
55
+ assert_equal wi0.attributes.length, wi2.attributes.length
56
+ end
57
+
58
+ def test_any_from_h
59
+
60
+ li = OpenWFE::LaunchItem.new()
61
+ li.workflow_definition_url = "http://www.openwfe.org/nada"
62
+ li.price = "USD 12"
63
+ li.customer = "Captain Nemo"
64
+
65
+ h = li.to_h
66
+ #require 'pp'; pp h
67
+
68
+ li1 = OpenWFE::workitem_from_h(h)
69
+
70
+ assert li1.is_a?(OpenWFE::LaunchItem)
71
+ assert_equal li1.price, "USD 12"
72
+ assert_equal li1.attributes.size, 3
73
+ end
74
+
75
+ end
@@ -16,16 +16,14 @@ require 'wfid_test'
16
16
  require 'wi_test'
17
17
  require 'dollar_test'
18
18
  require 'misc_test'
19
+ require 'hash_test'
19
20
  require 'lru_test'
20
21
  require 'time_test'
21
22
  require 'raw_prog_test'
22
23
  require 'file_persistence_test'
23
24
  require 'cronline_test'
24
25
  require 'csv_test'
25
-
26
- #require 'journal_persistence_test'
27
- #
28
- # disabled for now, as journal persistence will undergo a redesign soon
26
+ require 'safely_test'
29
27
 
30
28
  require 'ft_0'
31
29
  require 'ft_0b_sequence'
@@ -57,6 +55,9 @@ require 'ft_22_history'
57
55
  require 'ft_23_when'
58
56
  require 'ft_24_def'
59
57
  require 'ft_25_cancel'
58
+ require 'ft_27_getflowpos'
59
+ require 'ft_28_fileparticipant'
60
+ require 'ft_30_socketlistener'
60
61
 
61
62
  require 'hparticipant_test'
62
63
  require 'timeout_test'
@@ -184,6 +184,7 @@ end""".strip
184
184
  "to_code_s() not working properly (3)"
185
185
  end
186
186
 
187
+
187
188
  #
188
189
  # TEST 4
189
190
  #
@@ -219,5 +220,209 @@ end""".strip
219
220
  "to_code_s() not working properly (4)"
220
221
  end
221
222
 
223
+
224
+ #
225
+ # TEST 4b
226
+ #
227
+
228
+ class TestDefinition4b < OpenWFE::ProcessDefinition
229
+ def make
230
+ sequence do
231
+ [ :b, :b, :b ].each do |p|
232
+ participant p
233
+ end
234
+ end
235
+ end
236
+ end
237
+
238
+ CODE_DEF4b = """
239
+ process_definition :name => 'TestDefinition4b', :revision => '0' do
240
+ sequence do
241
+ participant do
242
+ 'b'
243
+ end
244
+ participant do
245
+ 'b'
246
+ end
247
+ participant do
248
+ 'b'
249
+ end
250
+ end
251
+ end""".strip
252
+
253
+ def test_prog_4b
254
+
255
+ #puts
256
+ #puts TestDefinition4.do_make.to_s
257
+ #puts
258
+ #puts TestDefinition4b.do_make.to_code_s
259
+
260
+ assert \
261
+ TestDefinition4b.do_make.to_code_s == CODE_DEF4b,
262
+ "to_code_s() not working properly (4b)"
263
+ end
264
+
265
+
266
+ #
267
+ # TEST 5
268
+ #
269
+
270
+ class TestDefinition5 < OpenWFE::ProcessDefinition
271
+ def make
272
+ sequence do
273
+ participant :ref => :toto
274
+ sub0
275
+ end
276
+ process_definition :name => "sub0" do
277
+ nada
278
+ end
279
+ end
280
+ end
281
+
282
+ CODE_DEF5 = """
283
+ process_definition :name => 'Test', :revision => '5' do
284
+ sequence do
285
+ participant :ref => 'toto'
286
+ sub0
287
+ end
288
+ process_definition :name => 'sub0' do
289
+ nada
290
+ end
291
+ end""".strip
292
+
293
+ def test_prog_5
294
+
295
+ #puts
296
+ #puts TestDefinition5.do_make.to_s
297
+ #puts
298
+ #puts TestDefinition5.do_make.to_code_s
299
+
300
+ assert \
301
+ TestDefinition5.do_make.to_code_s == CODE_DEF5,
302
+ "to_code_s() not working properly (5)"
303
+ end
304
+
305
+
306
+ #
307
+ # TEST 6
308
+ #
309
+
310
+ class TestDefinition60 < OpenWFE::ProcessDefinition
311
+ def make
312
+ sequence do
313
+ participant :ref => :toto
314
+ nada
315
+ end
316
+ end
317
+ end
318
+
319
+ CODE_DEF6 = """
320
+ process_definition :name => 'Test', :revision => '60' do
321
+ sequence do
322
+ participant :ref => 'toto'
323
+ nada
324
+ end
325
+ end""".strip
326
+
327
+ def test_prog_6
328
+
329
+ #puts
330
+ #puts TestDefinition60.do_make.to_s
331
+ #puts
332
+ #puts TestDefinition60.do_make.to_code_s
333
+
334
+ assert \
335
+ TestDefinition60.do_make.to_code_s == CODE_DEF6,
336
+ "to_code_s() not working properly (6)"
337
+ end
338
+
339
+
340
+ #
341
+ # TEST 7
342
+ #
343
+
344
+ class TestDefinitionSeven < OpenWFE::ProcessDefinition
345
+ def make
346
+ participant :ref => :toto
347
+ end
348
+ end
349
+
350
+ CODE_DEF7 = """
351
+ process_definition :name => 'TestDefinitionSeven', :revision => '0' do
352
+ participant :ref => 'toto'
353
+ end""".strip
354
+
355
+ def test_prog_7
356
+
357
+ #puts
358
+ #puts TestDefinition7.do_make.to_s
359
+ #puts
360
+ #puts TestDefinition7.do_make.to_code_s
361
+
362
+ assert \
363
+ TestDefinitionSeven.do_make.to_code_s == CODE_DEF7,
364
+ "to_code_s() not working properly (7)"
365
+ end
366
+
367
+ #
368
+ # TEST 8
369
+ #
370
+
371
+ def do_test(class_name, pdef)
372
+ result = eval """
373
+ class #{class_name} < OpenWFE::ProcessDefinition
374
+ def make
375
+ participant 'nada'
376
+ end
377
+ end
378
+ #{class_name}.do_make
379
+ """
380
+ assert_equal result.attributes['name'], pdef[0]
381
+ assert_equal result.attributes['revision'], pdef[1]
382
+ end
383
+
384
+ def test_process_names
385
+ do_test("MyProcessDefinition_10", ["MyProcess", "10"])
386
+ do_test("MyProcessDefinition10", ["MyProcess", "10"])
387
+ do_test("MyProcessDefinition1_0", ["MyProcess", "1.0"])
388
+ do_test("MyProcessThing_1_0", ["MyProcessThing", "1.0"])
389
+ end
390
+
391
+
392
+ #
393
+ # TEST 9
394
+ #
395
+
396
+ class TestDefinition9 < OpenWFE::ProcessDefinition
397
+ def make
398
+ description "this is my process"
399
+ sequence do
400
+ participant :ref => :toto
401
+ end
402
+ end
403
+ end
404
+
405
+ CODE_DEF9 = """
406
+ process_definition :name => 'Test', :revision => '60' do
407
+ description 'this is my process'
408
+ sequence do
409
+ participant :ref => 'toto'
410
+ nada
411
+ end
412
+ end""".strip
413
+
414
+ def xxxx_prog_9
415
+ #def test_prog_9
416
+
417
+ #puts
418
+ #puts TestDefinition60.do_make.to_s
419
+ puts
420
+ puts TestDefinition9.do_make.to_code_s
421
+
422
+ assert \
423
+ TestDefinition9.do_make.to_code_s == CODE_DEF9,
424
+ "to_code_s() not working properly (9)"
425
+ end
426
+
222
427
  end
223
428
 
@@ -6,6 +6,9 @@
6
6
  # Mon Oct 9 22:19:44 JST 2006
7
7
  #
8
8
 
9
+ require 'openwfe/rudefinitions'
10
+
11
+
9
12
  class Tracer
10
13
 
11
14
  def initialize
@@ -26,3 +29,16 @@ class Tracer
26
29
  end
27
30
  end
28
31
 
32
+ def new_fei ()
33
+ fei = OpenWFE::FlowExpressionId.new()
34
+ fei.owfe_version = OpenWFE::OPENWFERU_VERSION
35
+ fei.engine_id = 'this'
36
+ fei.initial_engine_id = 'that'
37
+ fei.workflow_definition_url = 'http://test/test.xml'
38
+ fei.workflow_definition_name = 'test'
39
+ fei.workflow_definition_revision = '1.0'
40
+ fei.workflow_instance_id = '123456'
41
+ fei.expression_name = 'do-test'
42
+ fei.expression_id = '0.0'
43
+ fei
44
+ end
@@ -0,0 +1,89 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+
8
+ require 'tmpdir'
9
+ require 'test/unit'
10
+ #require 'openwfe/utils'
11
+ require 'openwfe/util/safe'
12
+
13
+
14
+ class SafelyTest < Test::Unit::TestCase
15
+
16
+ #def setup
17
+ #end
18
+
19
+ #def teardown
20
+ #end
21
+
22
+ def test_safely_0
23
+
24
+ assert_not_nil dotest("print ''", 4)
25
+ assert_not_nil dotest2("print ''", 4)
26
+
27
+ assert_nil dotest("print ''", 2)
28
+ assert_nil dotest2("print ''", 2)
29
+ end
30
+
31
+ def test_safely_1
32
+ assert_not_nil dotest3(STDOUT, "self.print ''", 4)
33
+ assert_nil dotest3(STDOUT, "self.print ''", 2)
34
+ assert_not_nil dotest3(nil, "print ''", 4)
35
+ assert_nil dotest3(nil, "print ''", 2)
36
+ end
37
+
38
+ protected
39
+
40
+ def dotest (code, level)
41
+
42
+ fname = "#{Dir.tmpdir}/safely_test_temp.rb"
43
+
44
+ File.open fname, "w" do |f|
45
+ f.puts code
46
+ end
47
+
48
+ e = nil
49
+
50
+ begin
51
+ OpenWFE::load_safely(fname, level)
52
+ rescue Exception => e
53
+ end
54
+
55
+ File.delete(fname)
56
+
57
+ #puts OpenWFE::exception_to_s(e) if e
58
+
59
+ e
60
+ end
61
+
62
+ def dotest2 (code, level)
63
+
64
+ begin
65
+ OpenWFE::load_eval_safely(code, level)
66
+ rescue Exception => e
67
+ return e
68
+ end
69
+
70
+ nil
71
+ end
72
+
73
+ def dotest3 (instance, code, level)
74
+
75
+ begin
76
+ if instance
77
+ OpenWFE::instance_eval_safely(instance, code, level)
78
+ else
79
+ OpenWFE::eval_safely(code, level)
80
+ end
81
+ rescue Exception => e
82
+ return e
83
+ end
84
+
85
+ nil
86
+ end
87
+
88
+ end
89
+