test/flowtestbase.rb in openwferu-0.9.4 vs test/flowtestbase.rb in openwferu-0.9.5
- old
+ new
@@ -17,26 +17,30 @@
require 'rutest_utils'
include OpenWFE
+
+$WORKFLOW_ENGINE_CLASS = Engine
+
persistence = ENV["__persistence__"]
+require "openwfe/engine/file_persisted_engine" if persistence
-$WORKFLOW_ENGINE_CLASS = Engine
-if persistence == "FilePersistedEngine"
- require "openwfe/engine/file_persisted_engine"
+if persistence == "pure-persistence"
$WORKFLOW_ENGINE_CLASS = FilePersistedEngine
+elsif persistence == "cached-persistence"
+ $WORKFLOW_ENGINE_CLASS = CachedFilePersistedEngine
end
puts
puts "testing with engine of class " + $WORKFLOW_ENGINE_CLASS.to_s
-#puts "testing with engine of class " + ENV["workflow_engine_class"]
puts
-class FlowTestBase < Test::Unit::TestCase
+#class FlowTestBase < Test::Unit::TestCase
+module FlowTestBase
attr_reader \
:engine, :tracer
def setup
@@ -46,29 +50,35 @@
@tracer = Tracer.new
@engine.application_context["__tracer"] = @tracer
end
def teardown
+
@engine.stop
end
- def default_test ()
- assert true
- end
+ #def default_test ()
+ # assert true
+ #end
protected
- def test_name
+ def name_of_test
s = caller(1)[0]
i = s.index('`')
#s = s[i+1..s.length-2]
s = s[i+6..s.length-2]
return s
end
+ #
+ # dotest()
+ #
def dotest (flowDef, expectedTrace, sleepTime=0, 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"
@@ -106,10 +116,15 @@
result = false
expectedTrace.each do |etrace|
result = (result or (trace == etrace))
end
+ unless result
+ puts
+ puts ">#{trace}<"
+ puts
+ end
assert \
result,
"flow failed : trace doesn't correspond to any expected traces"
else
assert \
@@ -122,18 +137,17 @@
'#{expectedTrace}'
"""
end
-
- #exp_storage = \
- # engine.application_context[S_EXPRESSION_STORAGE]
- exp_storage = engine.get_expression_storage
-
if allowRemainingExpressions
- exp_storage.purge
+ engine.get_expression_storages.each do |storage|
+ storage.purge
+ end
return
end
+
+ exp_storage = engine.get_expression_storage
if exp_storage.length != 1
puts
puts " remaining expressions : #{exp_storage.length}"
puts