openwferu 0.9.15 → 0.9.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +4 -2
- data/lib/openwfe/engine/engine.rb +143 -25
- data/lib/openwfe/engine/file_persisted_engine.rb +3 -3
- data/lib/openwfe/expool/errorjournal.rb +48 -25
- data/lib/openwfe/expool/expressionpool.rb +77 -106
- data/lib/openwfe/expool/expstorage.rb +6 -5
- data/lib/openwfe/expool/threadedexpstorage.rb +190 -0
- data/lib/openwfe/expool/yamlexpstorage.rb +5 -150
- data/lib/openwfe/expressions/condition.rb +6 -6
- data/lib/openwfe/expressions/environment.rb +7 -2
- data/lib/openwfe/expressions/expressionmap.rb +14 -0
- data/lib/openwfe/expressions/fe_command.rb +2 -1
- data/lib/openwfe/expressions/fe_concurrence.rb +40 -18
- data/lib/openwfe/expressions/fe_cron.rb +14 -11
- data/lib/openwfe/expressions/fe_cursor.rb +2 -3
- data/lib/openwfe/expressions/fe_define.rb +34 -31
- data/lib/openwfe/expressions/fe_equals.rb +11 -21
- data/lib/openwfe/expressions/fe_filter_definition.rb +0 -2
- data/lib/openwfe/expressions/fe_fqv.rb +1 -3
- data/lib/openwfe/expressions/fe_if.rb +37 -12
- data/lib/openwfe/expressions/fe_iterator.rb +1 -1
- data/lib/openwfe/expressions/fe_listen.rb +147 -28
- data/lib/openwfe/expressions/fe_losfor.rb +13 -1
- data/lib/openwfe/expressions/fe_misc.rb +70 -11
- data/lib/openwfe/expressions/fe_participant.rb +3 -3
- data/lib/openwfe/expressions/fe_reserve.rb +1 -1
- data/lib/openwfe/expressions/fe_save.rb +11 -12
- data/lib/openwfe/expressions/fe_sequence.rb +22 -29
- data/lib/openwfe/expressions/fe_sleep.rb +11 -7
- data/lib/openwfe/expressions/fe_subprocess.rb +24 -10
- data/lib/openwfe/expressions/fe_value.rb +35 -15
- data/lib/openwfe/expressions/fe_when.rb +2 -4
- data/lib/openwfe/expressions/flowexpression.rb +73 -37
- data/lib/openwfe/expressions/merge.rb +2 -4
- data/lib/openwfe/expressions/raw.rb +40 -31
- data/lib/openwfe/expressions/raw_prog.rb +18 -9
- data/lib/openwfe/expressions/raw_xml.rb +1 -8
- data/lib/openwfe/expressions/simplerep.rb +27 -5
- data/lib/openwfe/expressions/time.rb +45 -15
- data/lib/openwfe/expressions/timeout.rb +2 -1
- data/lib/openwfe/expressions/wtemplate.rb +2 -2
- data/lib/openwfe/flowexpressionid.rb +62 -16
- data/lib/openwfe/listeners/listener.rb +28 -37
- data/lib/openwfe/listeners/listeners.rb +1 -1
- data/lib/openwfe/listeners/socketlisteners.rb +7 -15
- data/lib/openwfe/logging.rb +5 -4
- data/lib/openwfe/{rest → orest}/controlclient.rb +3 -5
- data/lib/openwfe/{rest → orest}/definitions.rb +0 -2
- data/lib/openwfe/{rest → orest}/exception.rb +0 -0
- data/lib/openwfe/{rest → orest}/oldrestservlet.rb +1 -1
- data/lib/openwfe/{rest → orest}/osocket.rb +1 -1
- data/lib/openwfe/{rest → orest}/restclient.rb +0 -2
- data/lib/openwfe/orest/workitem.rb +206 -0
- data/lib/openwfe/{rest → orest}/worklistclient.rb +15 -5
- data/lib/openwfe/{rest → orest}/xmlcodec.rb +4 -1
- data/lib/openwfe/participants/enoparticipants.rb +4 -14
- data/lib/openwfe/participants/participantmap.rb +16 -12
- data/lib/openwfe/participants/participants.rb +46 -1
- data/lib/openwfe/participants/socketparticipants.rb +1 -6
- data/lib/openwfe/service.rb +15 -6
- data/lib/openwfe/storage/yamlcustom.rb +3 -0
- data/lib/openwfe/storage/yamlfilestorage.rb +3 -1
- data/lib/openwfe/util/dollar.rb +21 -14
- data/lib/openwfe/util/lru.rb +29 -10
- data/lib/openwfe/util/observable.rb +4 -1
- data/lib/openwfe/util/otime.rb +3 -0
- data/lib/openwfe/util/scheduler.rb +346 -114
- data/lib/openwfe/utils.rb +67 -13
- data/lib/openwfe/version.rb +1 -1
- data/lib/openwfe/workitem.rb +22 -165
- data/lib/openwfe/worklist/oldrest.rb +2 -2
- data/test/bm/bm_1_xml_vs_prog.rb +56 -0
- data/test/{ft_26_load.rb → bm/ft_26_load.rb} +0 -0
- data/test/{ft_26b_load.rb → bm/ft_26b_load.rb} +0 -0
- data/test/{ft_26c_load.rb → bm/ft_26c_load.rb} +16 -4
- data/test/clone_test.rb +62 -0
- data/test/cron_test.rb +56 -1
- data/test/cronline_test.rb +17 -8
- data/test/description_test.rb +57 -0
- data/test/dollar_test.rb +17 -6
- data/test/eno_test.rb +22 -9
- data/test/fe_lookup_att_test.rb +50 -0
- data/test/fei_test.rb +18 -9
- data/test/flowtestbase.rb +24 -2
- data/test/ft_0.rb +10 -12
- data/test/ft_0e_multibody.rb +34 -0
- data/test/ft_10_loop.rb +4 -6
- data/test/ft_11_ppd.rb +5 -20
- data/test/ft_14b_subprocess.rb +2 -2
- data/test/ft_15_iterator.rb +56 -4
- data/test/ft_15b_iterator.rb +48 -0
- data/test/ft_16_fqv.rb +18 -3
- data/test/ft_23c_wait.rb +7 -5
- data/test/ft_25_cancel.rb +5 -3
- data/test/ft_27_getflowpos.rb +14 -11
- data/test/ft_28_fileparticipant.rb +3 -4
- data/test/ft_2_concurrence.rb +8 -12
- data/test/ft_2b_concurrence.rb +3 -2
- data/test/ft_30_socketlistener.rb +5 -6
- data/test/ft_32c_journal.rb +2 -2
- data/test/ft_32d_journal.rb +5 -6
- data/test/ft_33_description.rb +8 -3
- data/test/ft_34_cancelwfid.rb +3 -3
- data/test/ft_38_tag.rb +7 -10
- data/test/ft_39_reserve.rb +4 -2
- data/test/ft_3_equals.rb +18 -13
- data/test/ft_44b_restore.rb +2 -6
- data/test/ft_49_condition.rb +16 -12
- data/test/ft_4_misc.rb +51 -12
- data/test/ft_50_xml_attribute.rb +1 -1
- data/test/ft_54_listen.rb +96 -10
- data/test/ft_54b_listen.rb +68 -0
- data/test/ft_55_ptimeout.rb +1 -2
- data/test/ft_58_ejournal.rb +8 -33
- data/test/ft_59_ps.rb +2 -3
- data/test/ft_59b_ps_for_pat.rb +59 -0
- data/test/ft_5_time.rb +45 -4
- data/test/ft_60_ecancel.rb +7 -7
- data/test/ft_61_elsub.rb +1 -1
- data/test/ft_64_alias.rb +1 -1
- data/test/ft_67_schedlaunch.rb +29 -16
- data/test/ft_69_cancelmissing.rb +1 -1
- data/test/ft_6_lambda.rb +8 -6
- data/test/ft_70_lookupvar.rb +2 -2
- data/test/ft_71_log.rb +60 -0
- data/test/ft_72_lookup_processes.rb +79 -0
- data/test/ft_73_cancel_sub.rb +144 -0
- data/test/ft_74_block_and_workitem_dup.rb +63 -0
- data/test/ft_75_ruby_attributes.rb +87 -0
- data/test/ft_76_merge_isolate.rb +90 -0
- data/test/ft_7_lose.rb +2 -1
- data/test/ft_tests.rb +9 -0
- data/test/lookup_att_test.rb +90 -0
- data/test/misc_test.rb +33 -50
- data/test/orest_test.rb +1 -1
- data/test/participant_test.rb +32 -8
- data/test/pending.rb +6 -7
- data/test/rake_ltest.rb +3 -0
- data/test/rake_qtest.rb +4 -1
- data/test/raw_prog_test.rb +1 -1
- data/test/restart_cron_test.rb +6 -6
- data/test/restart_sleep_test.rb +8 -8
- data/test/ruby_procdef_test.rb +2 -2
- data/test/rutest_utils.rb +9 -3
- data/test/scheduler_1_test.rb +88 -0
- data/test/scheduler_test.rb +49 -4
- data/test/sec_test.rb +18 -11
- metadata +51 -34
- data/test/cron_test_2.rb +0 -50
data/lib/openwfe/utils.rb
CHANGED
@@ -108,6 +108,9 @@ module OpenWFE
|
|
108
108
|
return d.root
|
109
109
|
end
|
110
110
|
|
111
|
+
return Rational(object.denominator, object.numerator) \
|
112
|
+
if object.kind_of?(Rational)
|
113
|
+
|
111
114
|
o = nil
|
112
115
|
|
113
116
|
begin
|
@@ -153,20 +156,24 @@ module OpenWFE
|
|
153
156
|
end
|
154
157
|
|
155
158
|
def OpenWFE.to_underscore (string)
|
159
|
+
|
156
160
|
string.gsub("-", "_")
|
157
161
|
end
|
158
162
|
|
159
163
|
def OpenWFE.to_dash (string)
|
164
|
+
|
160
165
|
string.gsub("_", "-")
|
161
166
|
end
|
162
167
|
|
163
168
|
def OpenWFE.symbol_to_name (symbol)
|
169
|
+
|
164
170
|
to_dash(symbol.to_s)
|
165
171
|
end
|
166
172
|
|
167
173
|
def OpenWFE.name_to_symbol (name)
|
174
|
+
|
168
175
|
return name if name.is_a?(Symbol)
|
169
|
-
|
176
|
+
to_underscore(name).intern
|
170
177
|
end
|
171
178
|
|
172
179
|
#
|
@@ -174,6 +181,7 @@ module OpenWFE
|
|
174
181
|
# Returns the new String.
|
175
182
|
#
|
176
183
|
def OpenWFE.stu (s)
|
184
|
+
|
177
185
|
s.gsub("\s", "_")
|
178
186
|
end
|
179
187
|
|
@@ -336,7 +344,7 @@ module OpenWFE
|
|
336
344
|
# instantiated.
|
337
345
|
#
|
338
346
|
def duration
|
339
|
-
|
347
|
+
(Time.now.to_f - @start) * 1000
|
340
348
|
end
|
341
349
|
end
|
342
350
|
|
@@ -355,6 +363,7 @@ module OpenWFE
|
|
355
363
|
# (removes for examples things like '/' or '\'...)
|
356
364
|
#
|
357
365
|
def OpenWFE.ensure_for_filename (s)
|
366
|
+
|
358
367
|
s = s.gsub(" ", "_")
|
359
368
|
s = s.gsub("/", "_")
|
360
369
|
s = s.gsub(":", "_")
|
@@ -363,7 +372,8 @@ module OpenWFE
|
|
363
372
|
s = s.gsub("\\", "_")
|
364
373
|
s = s.gsub("\+", "_")
|
365
374
|
s = s.gsub("\?", "_")
|
366
|
-
|
375
|
+
|
376
|
+
s
|
367
377
|
end
|
368
378
|
|
369
379
|
#
|
@@ -379,7 +389,14 @@ module OpenWFE
|
|
379
389
|
def OpenWFE.lookup_attribute (container, key)
|
380
390
|
|
381
391
|
key, rest = pop_key(key)
|
382
|
-
|
392
|
+
|
393
|
+
#value = nil
|
394
|
+
#begin
|
395
|
+
# value = container[key]
|
396
|
+
#rescue Exception => e
|
397
|
+
#end
|
398
|
+
|
399
|
+
value = flex_lookup(container, key)
|
383
400
|
|
384
401
|
return value unless rest
|
385
402
|
|
@@ -393,17 +410,22 @@ module OpenWFE
|
|
393
410
|
#
|
394
411
|
def OpenWFE.has_attribute? (container, key)
|
395
412
|
|
396
|
-
key,
|
413
|
+
key, last_key = pop_last_key(key)
|
397
414
|
|
398
|
-
|
415
|
+
container = lookup_attribute(container, key) if key
|
399
416
|
|
400
|
-
|
401
|
-
if container.respond_to?(:has_key?)
|
417
|
+
if container.respond_to?(:has_key?)
|
402
418
|
|
403
|
-
|
404
|
-
end
|
419
|
+
(container.has_key?(last_key) or container.has_key?(last_key.to_s))
|
405
420
|
|
406
|
-
|
421
|
+
elsif container.is_a?(Array) and last_key.is_a?(Fixnum)
|
422
|
+
|
423
|
+
(last_key < container.length)
|
424
|
+
|
425
|
+
else
|
426
|
+
|
427
|
+
false
|
428
|
+
end
|
407
429
|
end
|
408
430
|
|
409
431
|
#
|
@@ -415,6 +437,8 @@ module OpenWFE
|
|
415
437
|
# puts " - '#{line.downcase}'"
|
416
438
|
# end
|
417
439
|
#
|
440
|
+
# TODO : find a ruby library and use it instead of that code
|
441
|
+
#
|
418
442
|
def OpenWFE.grep (pattern, filepath, &block)
|
419
443
|
|
420
444
|
result = []
|
@@ -468,18 +492,48 @@ module OpenWFE
|
|
468
492
|
|
469
493
|
protected
|
470
494
|
|
471
|
-
def pop_key (key)
|
495
|
+
def OpenWFE.pop_key (key)
|
472
496
|
i = key.index(".")
|
473
497
|
return narrow(key), nil unless i
|
474
498
|
[ narrow(key[0..i-1]), key[i+1..-1] ]
|
475
499
|
end
|
476
500
|
|
477
|
-
def
|
501
|
+
def OpenWFE.pop_last_key (key)
|
502
|
+
i = key.rindex(".")
|
503
|
+
return nil, narrow(key) unless i
|
504
|
+
[ key[0..i-1], narrow(key[i+1..-1]) ]
|
505
|
+
end
|
506
|
+
|
507
|
+
def OpenWFE.narrow (key)
|
478
508
|
return 0 if key == "0"
|
479
509
|
i = key.to_i
|
480
510
|
return i if i != 0
|
481
511
|
key
|
482
512
|
end
|
513
|
+
|
514
|
+
#
|
515
|
+
# looks up in a container (something that has a [] method) with a key,
|
516
|
+
# if nothing has been found and the key is a number, turns the
|
517
|
+
# the number into a String a does a last lookup.
|
518
|
+
#
|
519
|
+
def OpenWFE.flex_lookup (container, key)
|
520
|
+
|
521
|
+
value = nil
|
522
|
+
|
523
|
+
begin
|
524
|
+
value = container[key]
|
525
|
+
rescue Exception => e
|
526
|
+
end
|
527
|
+
|
528
|
+
if value == nil and key.kind_of?(Fixnum)
|
529
|
+
begin
|
530
|
+
value = container[key.to_s]
|
531
|
+
rescue Exception => e
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
value
|
536
|
+
end
|
483
537
|
|
484
538
|
end
|
485
539
|
|
data/lib/openwfe/version.rb
CHANGED
data/lib/openwfe/workitem.rb
CHANGED
@@ -33,17 +33,13 @@
|
|
33
33
|
|
34
34
|
#
|
35
35
|
# "hecho en Costa Rica"
|
36
|
+
# and "made in Japan"
|
36
37
|
#
|
37
38
|
# john.mettraux@openwfe.org
|
38
39
|
#
|
39
40
|
|
40
|
-
require 'base64'
|
41
|
-
|
42
41
|
require 'openwfe/utils'
|
43
42
|
|
44
|
-
require 'openwfe/rest/definitions'
|
45
|
-
# hmmm, only used for MAP_TYPE
|
46
|
-
|
47
43
|
|
48
44
|
module OpenWFE
|
49
45
|
|
@@ -53,9 +49,9 @@ module OpenWFE
|
|
53
49
|
#
|
54
50
|
FIELD_RESULT = "__result__"
|
55
51
|
|
56
|
-
|
52
|
+
#--
|
57
53
|
# WORKITEMS
|
58
|
-
|
54
|
+
#++
|
59
55
|
|
60
56
|
#
|
61
57
|
# The base class for all the workitems.
|
@@ -64,17 +60,21 @@ module OpenWFE
|
|
64
60
|
|
65
61
|
attr_accessor :last_modified, :attributes
|
66
62
|
|
67
|
-
def initialize
|
68
|
-
|
63
|
+
def initialize
|
69
64
|
@last_modified = nil
|
70
|
-
|
71
65
|
@attributes = {}
|
72
|
-
@attributes[MAP_TYPE] = E_SMAP
|
73
66
|
end
|
74
67
|
|
75
68
|
alias :fields :attributes
|
76
69
|
alias :fields= :attributes=
|
77
70
|
|
71
|
+
#
|
72
|
+
# Sets the last_modified field to now
|
73
|
+
#
|
74
|
+
def touch
|
75
|
+
@last_modified = Time.now
|
76
|
+
end
|
77
|
+
|
78
78
|
def to_h
|
79
79
|
h = {}
|
80
80
|
h[:type] = self.class.name
|
@@ -248,17 +248,21 @@ module OpenWFE
|
|
248
248
|
# Outputting the workitem in a human readable format
|
249
249
|
#
|
250
250
|
def to_s
|
251
|
+
|
251
252
|
s = ""
|
252
|
-
s << "
|
253
|
+
s << " #{self.class} :\n"
|
253
254
|
s << " - flow_expression_id : #{@flow_expression_id}\n"
|
254
255
|
s << " - participant_name : #{@participant_name}\n"
|
255
256
|
s << " - last_modified : #{@last_modified}\n"
|
256
257
|
s << " - dispatch_time : #{@dispatch_time}\n"
|
257
258
|
s << " - attributes :\n"
|
258
|
-
|
259
|
-
|
259
|
+
|
260
|
+
s << " {\n"
|
261
|
+
@attributes.keys.sort.each do |k|
|
262
|
+
v = @attributes[k]
|
263
|
+
s << " #{k.inspect} => #{v.inspect},\n"
|
260
264
|
end
|
261
|
-
s << "
|
265
|
+
s << " }"
|
262
266
|
s
|
263
267
|
end
|
264
268
|
|
@@ -267,6 +271,7 @@ module OpenWFE
|
|
267
271
|
# (Any YAML-enabled platform can thus read it).
|
268
272
|
#
|
269
273
|
def to_h
|
274
|
+
|
270
275
|
h = super
|
271
276
|
h[:dispatch_time] = @dispatch_time
|
272
277
|
h[:history] = @history
|
@@ -374,13 +379,13 @@ module OpenWFE
|
|
374
379
|
#
|
375
380
|
# # Load an XML process definition from a local file
|
376
381
|
# require 'uri'
|
377
|
-
# LaunchItem.new(URI.
|
382
|
+
# LaunchItem.new(URI.parse("file:///tmp/my_process_definition.xml"))
|
378
383
|
#
|
379
384
|
# # If you initialized your engine with
|
380
385
|
# # {:remote_definitions_allowed => true}, then you can also load an
|
381
386
|
# # XML process definition from a remote url
|
382
387
|
# require 'uri'
|
383
|
-
# LaunchItem.new(URI.
|
388
|
+
# LaunchItem.new(URI.parse("http://foo.bar/my_process_definition.xml"))
|
384
389
|
#
|
385
390
|
def initialize (process_definition=nil)
|
386
391
|
|
@@ -419,153 +424,5 @@ module OpenWFE
|
|
419
424
|
wi_class.from_h(h)
|
420
425
|
end
|
421
426
|
|
422
|
-
#
|
423
|
-
# HISTORY ITEM
|
424
|
-
#
|
425
|
-
|
426
|
-
#
|
427
|
-
# HistoryItem instances are used to keep track of what happened to
|
428
|
-
# a workitem.
|
429
|
-
#
|
430
|
-
class HistoryItem
|
431
|
-
|
432
|
-
attr_accessor \
|
433
|
-
:date, \
|
434
|
-
:author, \
|
435
|
-
:host, \
|
436
|
-
:text, \
|
437
|
-
:wfd_name, \
|
438
|
-
:wfd_revision, \
|
439
|
-
:wf_instance_id, \
|
440
|
-
:expression_id
|
441
|
-
|
442
|
-
def dup
|
443
|
-
return OpenWFE::fulldup(self)
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
|
448
|
-
#
|
449
|
-
# STORES
|
450
|
-
#
|
451
|
-
|
452
|
-
#
|
453
|
-
# Models the information about a store as viewed by the current user
|
454
|
-
# (upon calling the listStores or getStoreNames methods)
|
455
|
-
#
|
456
|
-
class Store
|
457
|
-
|
458
|
-
attr_accessor :name, :workitem_count, :permissions
|
459
|
-
|
460
|
-
def initialize ()
|
461
|
-
super()
|
462
|
-
#@name = nil
|
463
|
-
#@workitem_count = nil
|
464
|
-
#@permissions = nil
|
465
|
-
end
|
466
|
-
|
467
|
-
#
|
468
|
-
# Returns true if the current user may read headers and workitems
|
469
|
-
# from this store
|
470
|
-
#
|
471
|
-
def may_read? ()
|
472
|
-
return @permissions.index('r') > -1
|
473
|
-
end
|
474
|
-
|
475
|
-
#
|
476
|
-
# Returns true if the current user may modify workitems (and at least
|
477
|
-
# proceed/forward them) in this store
|
478
|
-
#
|
479
|
-
def may_write? ()
|
480
|
-
return @permissions.index('w') > -1
|
481
|
-
end
|
482
|
-
|
483
|
-
#
|
484
|
-
# Returns true if the current user may browse the headers of this
|
485
|
-
# store
|
486
|
-
#
|
487
|
-
def may_browse? ()
|
488
|
-
return @permissions.index('b') > -1
|
489
|
-
end
|
490
|
-
|
491
|
-
#
|
492
|
-
# Returns true if the current user may delegate workitems to this store
|
493
|
-
#
|
494
|
-
def may_delegate? ()
|
495
|
-
return @permissions.index('d') > -1
|
496
|
-
end
|
497
|
-
end
|
498
|
-
|
499
|
-
#
|
500
|
-
# A header is a summary of a workitem, returned by the getHeader
|
501
|
-
# worklist method.
|
502
|
-
#
|
503
|
-
class Header < InFlowWorkItem
|
504
|
-
|
505
|
-
attr_accessor :locked
|
506
|
-
end
|
507
|
-
|
508
|
-
|
509
|
-
#
|
510
|
-
# MISC ATTRIBUTES
|
511
|
-
#
|
512
|
-
# in openwfe-ruby, OpenWFE attributes are immediately mapped to
|
513
|
-
# Ruby instances, but some attributes still deserve their own class
|
514
|
-
#
|
515
|
-
|
516
|
-
#
|
517
|
-
# a wrapper for some binary content
|
518
|
-
#
|
519
|
-
class Base64Attribute
|
520
|
-
|
521
|
-
attr_accessor :content
|
522
|
-
|
523
|
-
def initialize (base64content)
|
524
|
-
|
525
|
-
@content = base64content
|
526
|
-
end
|
527
|
-
|
528
|
-
#
|
529
|
-
# dewraps (decode) the current content and returns it
|
530
|
-
#
|
531
|
-
def dewrap ()
|
532
|
-
|
533
|
-
return Base64.decode64(@content)
|
534
|
-
end
|
535
|
-
|
536
|
-
#
|
537
|
-
# wraps some binary content and stores it in this attribute
|
538
|
-
# (class method)
|
539
|
-
#
|
540
|
-
def Base64Attribute.wrap (binaryData)
|
541
|
-
|
542
|
-
return Base64Attribute.new(Base64.encode64(binaryData))
|
543
|
-
end
|
544
|
-
end
|
545
|
-
|
546
|
-
|
547
|
-
#
|
548
|
-
# LAUNCHABLE
|
549
|
-
#
|
550
|
-
|
551
|
-
#
|
552
|
-
# A worklist will return list of Launchable instances indicating
|
553
|
-
# what processes (URL) a user may launch on which engine.
|
554
|
-
#
|
555
|
-
class Launchable
|
556
|
-
|
557
|
-
attr_accessor :url, :engine_id
|
558
|
-
end
|
559
|
-
|
560
|
-
|
561
|
-
#
|
562
|
-
# Expression, somehow equivalent to FlowExpression, but only used
|
563
|
-
# by the control interface.
|
564
|
-
#
|
565
|
-
class Expression
|
566
|
-
|
567
|
-
attr_accessor :id, :apply_time, :state, :state_since
|
568
|
-
end
|
569
|
-
|
570
427
|
end
|
571
428
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# a bit of benchmark
|
4
|
+
#
|
5
|
+
# Thu Nov 8 21:48:20 JST 2007
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'benchmark'
|
9
|
+
|
10
|
+
require 'openwfe/def'
|
11
|
+
#require 'openwfe/engine/engine'
|
12
|
+
require 'openwfe/engine/file_persisted_engine'
|
13
|
+
|
14
|
+
|
15
|
+
class ProgDef < OpenWFE::ProcessDefinition
|
16
|
+
sequence do
|
17
|
+
toto
|
18
|
+
toto
|
19
|
+
toto
|
20
|
+
toto
|
21
|
+
toto
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
xml = <<END
|
26
|
+
<process-definition name="x" revision="y">
|
27
|
+
<sequence>
|
28
|
+
<toto/>
|
29
|
+
<toto/>
|
30
|
+
<toto/>
|
31
|
+
<toto/>
|
32
|
+
<toto/>
|
33
|
+
</sequence>
|
34
|
+
</process-definition>
|
35
|
+
END
|
36
|
+
|
37
|
+
#$engine = OpenWFE::Engine.new
|
38
|
+
$engine = OpenWFE::FilePersistedEngine.new
|
39
|
+
|
40
|
+
$engine.register_participant "toto" do |workitem|
|
41
|
+
# do nothing
|
42
|
+
end
|
43
|
+
|
44
|
+
N = 500
|
45
|
+
|
46
|
+
def test (proc_def)
|
47
|
+
N.times do
|
48
|
+
fei = $engine.launch proc_def
|
49
|
+
$engine.wait_for fei
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Benchmark.bm do |x|
|
54
|
+
x.report("prog :") { test ProgDef }
|
55
|
+
x.report("xml :") { test xml.strip }
|
56
|
+
end
|
File without changes
|
File without changes
|
@@ -28,7 +28,7 @@ class FlowTest26c < Test::Unit::TestCase
|
|
28
28
|
# Test 0
|
29
29
|
#
|
30
30
|
|
31
|
-
N =
|
31
|
+
N = 10_000
|
32
32
|
|
33
33
|
class TestDefinition0 < ProcessDefinition
|
34
34
|
sequence do
|
@@ -38,9 +38,10 @@ class FlowTest26c < Test::Unit::TestCase
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
#def xxxx_load_0
|
42
41
|
def test_load_0
|
43
42
|
|
43
|
+
#log_level_to_debug
|
44
|
+
|
44
45
|
#@engine.get_scheduler.sstop
|
45
46
|
#
|
46
47
|
# JRuby is no friend of the Scheduler
|
@@ -55,10 +56,11 @@ class FlowTest26c < Test::Unit::TestCase
|
|
55
56
|
fei = @engine.launch(LaunchItem.new(TestDefinition0))
|
56
57
|
puts "launched #{fei}"
|
57
58
|
|
59
|
+
#log_level_to_debug
|
60
|
+
|
58
61
|
@engine.wait_for fei
|
59
|
-
#sleep 60
|
60
62
|
|
61
|
-
assert_equal $count
|
63
|
+
assert_equal N, $count
|
62
64
|
end
|
63
65
|
|
64
66
|
#
|
@@ -80,5 +82,15 @@ class FlowTest26c < Test::Unit::TestCase
|
|
80
82
|
#
|
81
83
|
# 10_000 in 42.616s
|
82
84
|
|
85
|
+
#
|
86
|
+
# Thu Nov 8 21:36:02 JST 2007
|
87
|
+
#
|
88
|
+
# ruby 1.8.6 (2007-06-07 patchlevel 36) [universal-darwin9.0]
|
89
|
+
#
|
90
|
+
# 10_000 in 39.089
|
91
|
+
#
|
92
|
+
# ?
|
93
|
+
#
|
94
|
+
|
83
95
|
end
|
84
96
|
|
data/test/clone_test.rb
CHANGED
@@ -6,8 +6,10 @@
|
|
6
6
|
#
|
7
7
|
|
8
8
|
require 'test/unit'
|
9
|
+
require 'rexml/document'
|
9
10
|
|
10
11
|
require 'openwfe/utils'
|
12
|
+
require 'openwfe/workitem'
|
11
13
|
|
12
14
|
|
13
15
|
class FullDupTest < Test::Unit::TestCase
|
@@ -48,4 +50,64 @@ class FullDupTest < Test::Unit::TestCase
|
|
48
50
|
assert_equal o0.name, o1.name
|
49
51
|
end
|
50
52
|
|
53
|
+
def test_dup_0
|
54
|
+
a0 = A.new
|
55
|
+
a0.a = 1
|
56
|
+
a0.b = 2
|
57
|
+
a1 = OpenWFE::fulldup(a0)
|
58
|
+
|
59
|
+
#puts a0
|
60
|
+
#puts a1
|
61
|
+
|
62
|
+
assert_equal a0, a1, "dup() utility not working"
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_dup_1
|
66
|
+
d = REXML::Document.new("<document/>")
|
67
|
+
d1 = OpenWFE::fulldup(d)
|
68
|
+
assert d.object_id != d1.object_id
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_dup_2
|
72
|
+
d = REXML::Document.new("<document>text</document>")
|
73
|
+
d1 = OpenWFE::fulldup(d)
|
74
|
+
assert d.object_id != d1.object_id
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_dup_3
|
78
|
+
d = REXML::Text.new "toto"
|
79
|
+
d1 = OpenWFE::fulldup(d)
|
80
|
+
assert d.object_id != d1.object_id
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_dup_4
|
84
|
+
wi = OpenWFE::InFlowWorkItem.new
|
85
|
+
wi.xml_stuff = REXML::Text.new "whatever"
|
86
|
+
wi1 = wi.dup
|
87
|
+
assert wi.object_id != wi1.object_id
|
88
|
+
assert wi.xml_stuff.object_id != wi1.xml_stuff.object_id
|
89
|
+
assert_equal wi.xml_stuff, wi1.xml_stuff
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_dup_5
|
93
|
+
require 'date'
|
94
|
+
d = DateTime.now()
|
95
|
+
d1 = OpenWFE::fulldup(d)
|
96
|
+
assert d.object_id != d1.object_id
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
class A
|
102
|
+
attr_accessor :a, :b
|
103
|
+
|
104
|
+
def == (other)
|
105
|
+
return false if not other.kind_of?(A)
|
106
|
+
(self.a == other.a and self.b == other.b)
|
107
|
+
end
|
108
|
+
|
109
|
+
def to_s
|
110
|
+
"A : a='#{a}', b='#{b}'"
|
111
|
+
end
|
112
|
+
end
|
51
113
|
end
|
data/test/cron_test.rb
CHANGED
@@ -24,7 +24,7 @@ class CronTest < Test::Unit::TestCase
|
|
24
24
|
#def teardown
|
25
25
|
#end
|
26
26
|
|
27
|
-
def
|
27
|
+
def test_0
|
28
28
|
|
29
29
|
$var = 0
|
30
30
|
|
@@ -45,6 +45,61 @@ class CronTest < Test::Unit::TestCase
|
|
45
45
|
assert_equal $var, 2, "$var should be at 2, it's at #{$var}"
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_1
|
49
|
+
|
50
|
+
scheduler = OpenWFE::Scheduler.new
|
51
|
+
scheduler.start
|
52
|
+
|
53
|
+
sec = nil
|
54
|
+
has_gone_wrong = false
|
55
|
+
counter = 0
|
56
|
+
|
57
|
+
scheduler.schedule "* * * * * *" do
|
58
|
+
t = Time.new
|
59
|
+
if (t.sec == sec)
|
60
|
+
has_gone_wrong = true
|
61
|
+
#print "x"
|
62
|
+
else
|
63
|
+
#print "."
|
64
|
+
end
|
65
|
+
#STDOUT.flush
|
66
|
+
sec = t.sec
|
67
|
+
counter = counter + 1
|
68
|
+
end
|
69
|
+
|
70
|
+
sleep 10
|
71
|
+
scheduler.stop
|
72
|
+
|
73
|
+
assert_equal 10, counter
|
74
|
+
assert (not has_gone_wrong)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_2
|
78
|
+
|
79
|
+
scheduler = OpenWFE::Scheduler.new
|
80
|
+
scheduler.start
|
81
|
+
|
82
|
+
seen = false
|
83
|
+
has_gone_wrong = false
|
84
|
+
|
85
|
+
scheduler.schedule "7 * * * * *" do
|
86
|
+
if seen
|
87
|
+
has_gone_wrong = true
|
88
|
+
#print "x"
|
89
|
+
else
|
90
|
+
seen = true
|
91
|
+
#print "."
|
92
|
+
end
|
93
|
+
#STDOUT.flush
|
94
|
+
end
|
95
|
+
|
96
|
+
sleep 61
|
97
|
+
scheduler.stop
|
98
|
+
|
99
|
+
assert seen
|
100
|
+
assert (not has_gone_wrong)
|
101
|
+
end
|
102
|
+
|
48
103
|
protected
|
49
104
|
|
50
105
|
class CounterSchedulable
|