test/flowtestbase.rb in openwferu-0.9.7 vs test/flowtestbase.rb in openwferu-0.9.8
- old
+ new
@@ -55,10 +55,21 @@
@engine.register_participant('pp-workitem') do |workitem|
puts
require 'pp'; pp workitem
puts
end
+
+ @engine.register_participant('test-.*', PrintParticipant.new())
+
+ @engine.register_participant('block-participant') do |workitem|
+ @tracer << "the block participant received a workitem"
+ @tracer << "\n"
+ end
+
+ @engine.register_participant('p-toto') do |workitem|
+ @tracer << "toto"
+ end
end
def teardown
@engine.stop
@@ -87,48 +98,24 @@
end
#
# dotest()
#
- def dotest (flowDef, expectedTrace, sleepTime=0, allowRemainingExpressions=false)
+ def dotest (flowDef, expectedTrace, join=false, allowRemainingExpressions=false)
@tracer.clear
- @engine.register_participant('test-.*', PrintParticipant.new())
-
- @engine.register_participant('block-participant') do |workitem|
- @tracer << "the block participant received a workitem"
- @tracer << "\n"
- end
-
- @engine.register_participant('p-toto') do |workitem|
- @tracer << "toto"
- end
-
-# @engine.register_participant(
-# 'eno',
-# EmailNotificationParticipant.new(
-# "googlemail.l.google.com",
-# 25,
-# "eno@outoftheblue.co.jp",
-# """Subject: test 0
-#
-#0 : ${r:Time.new}
-#1 : ${f:customer_name}
-# """))
-
- # register unique tracing participant
-
li = if flowDef.kind_of? OpenWFE::LaunchItem
flowDef
else
OpenWFE::LaunchItem.new(flowDef)
end
fei = @engine.launch(li)
- sleep(sleepTime)
+ #sleep(sleep_time)
+ @engine.get_scheduler.join_until_no_more_jobs if join
trace = @tracer.to_s
#puts "...'#{trace}' ?= '#{expectedTrace}'"
@@ -144,12 +131,17 @@
puts
end
assert \
result,
"flow failed : trace doesn't correspond to any expected traces"
+ elsif expectedTrace.kind_of? Regexp
+
+ assert \
+ trace.match(expectedTrace)
else
+
assert \
- trace == expectedTrace, \
+ trace == expectedTrace,
"""flow failed :
'#{trace}'
!=