test/flowtestbase.rb in openwferu-0.9.1 vs test/flowtestbase.rb in openwferu-0.9.2
- old
+ new
@@ -1,93 +1,139 @@
-
#
-# Testing OpenWFEru
+# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 15:41:44 JST 2006
#
# somewhere between Philippina and the Japan
#
require 'test/unit'
-require 'workitem'
-require 'ru/engine'
-require 'ru/rudefinitions'
-require 'ru/participants'
+
+require 'openwfe/workitem'
+require 'openwfe/engine/engine'
+require 'openwfe/rudefinitions'
+require 'openwfe/participants/participants'
+
require 'rutest_utils'
+include OpenWFE
+
+$WORKFLOW_ENGINE_CLASS = Engine \
+ if not $WORKFLOW_ENGINE_CLASS
+
+puts
+puts "testing with engine of class " + $WORKFLOW_ENGINE_CLASS.to_s
+puts
+
class FlowTestBase < Test::Unit::TestCase
- #def setup
- #end
+ attr_reader \
+ :engine, :tracer
+ def setup
+
+ @engine = $WORKFLOW_ENGINE_CLASS.new()
+
+ @tracer = Tracer.new
+ @engine.application_context["__tracer"] = @tracer
+ end
+
#def teardown
#end
-
+
def default_test ()
assert true
end
protected
def test_name
s = caller(1)[0]
i = s.index('`')
- s = s[i+1..s.length-2]
+ #s = s[i+1..s.length-2]
+ s = s[i+6..s.length-2]
return s
end
- def dotest (flowDef, expectedTrace, sleepTime=0)
+ def dotest (flowDef, expectedTrace, sleepTime=0, allowRemainingExpressions=false)
- engine = OpenWFEru::Engine.new()
+ @engine.register_participant('test-.*', PrintParticipant.new())
- engine.application_context["__tracer"] = Tracer.new
+ @engine.register_participant('block-participant') do |workitem|
+ @tracer << "the block participant received a workitem"
+ @tracer << "\n"
+ end
- engine.register_participant('test-.*', OpenWFEru::PrintParticipant.new())
+# @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 = OpenWFE::LaunchItem.new()
+ li = OpenWFE::LaunchItem.new(flowDef)
- li.workflowDefinitionUrl = "field:__definition"
+ @engine.launch(li)
- li.attributes['__definition'] = flowDef
- engine.launch(li)
-
sleep(sleepTime)
- trace = engine.application_context["__tracer"].to_s
+ trace = @tracer.to_s
#puts "...'#{trace}' ?= '#{expectedTrace}'"
- if expectedTrace.kind_of?([].class)
- result = true
+ if expectedTrace.kind_of? [].class
+
+ result = false
expectedTrace.each do |etrace|
- result = result and trace == etrace
+ result = (result or (trace == etrace))
end
assert \
result,
"flow failed : trace doesn't correspond to any expected traces"
else
assert \
trace == expectedTrace, \
- "flow failed : '#{trace}' != '#{expectedTrace}'"
+ """flow failed :
+
+'#{trace}'
+
+ !=
+
+'#{expectedTrace}'
+"""
end
+
exp_storage = \
- engine.application_context[OpenWFEru::S_EXPRESSION_STORAGE]
+ engine.application_context[S_EXPRESSION_STORAGE]
+ if allowRemainingExpressions
+ exp_storage.purge
+ return
+ end
+
if exp_storage.length != 1
puts
+ puts " remaining expressions : #{exp_storage.length}"
+ puts
puts exp_storage.to_s
puts
end
assert \
exp_storage.length == 1,
- "there are expressions remaining in the expression pool"
+ "there are expressions remaining in the expression pool " +
+ "(#{exp_storage.length})"
end
end