test/restart_sleep_test.rb in ruote-0.9.18 vs test/restart_sleep_test.rb in ruote-0.9.19

- old
+ new

@@ -17,124 +17,124 @@ require 'rutest_utils' class RestartSleepTest < Test::Unit::TestCase - #def setup - # @engine = $WORKFLOW_ENGINE_CLASS.new() - #end + #def setup + # @engine = $WORKFLOW_ENGINE_CLASS.new() + #end - #def teardown - #end + #def teardown + #end - # - # sleep tests + # + # sleep tests - class SleepDef < OpenWFE::ProcessDefinition - def make - process_definition :name => "rs0", :revision => "0" do - sequence do - _sleep :for => "10s" - _print "after" - end - end + class SleepDef < OpenWFE::ProcessDefinition + def make + process_definition :name => "rs0", :revision => "0" do + sequence do + _sleep :for => "10s" + _print "after" end + end end + end - def test_0 - dotest OpenWFE::FilePersistedEngine, SleepDef - end - def test_1 - dotest OpenWFE::CachedFilePersistedEngine, SleepDef - end + def test_0 + dotest OpenWFE::FilePersistedEngine, SleepDef + end + def test_1 + dotest OpenWFE::CachedFilePersistedEngine, SleepDef + end - # - # participant timeout tests + # + # participant timeout tests - class TimeoutDef < OpenWFE::ProcessDefinition - sequence do - nemo :timeout => "10s" - _print "after" - end + class TimeoutDef < OpenWFE::ProcessDefinition + sequence do + nemo :timeout => "10s" + _print "after" end + end - def test_timeout_0 - dotest OpenWFE::FilePersistedEngine, TimeoutDef - end - def test_timeout_1 - dotest OpenWFE::CachedFilePersistedEngine, TimeoutDef - end + def test_timeout_0 + dotest OpenWFE::FilePersistedEngine, TimeoutDef + end + def test_timeout_1 + dotest OpenWFE::CachedFilePersistedEngine, TimeoutDef + end - TDEF = ''' + TDEF = ''' <process-definition name="timeouttest" revision="1"> - <sequence> - <participant ref="nemo" timeout="10s" /> - <print>after</print> - </sequence> + <sequence> + <participant ref="nemo" timeout="10s" /> + <print>after</print> + </sequence> </process-definition> '''.strip - def test_timeout_0b - dotest OpenWFE::FilePersistedEngine, TDEF - end + def test_timeout_0b + dotest OpenWFE::FilePersistedEngine, TDEF + end - protected + protected - def dotest (engine_class, def_class) + def dotest (engine_class, def_class) - #require 'fileutils' - #FileUtils.remove_dir "work" if File.exist? "work" + #require 'fileutils' + #FileUtils.remove_dir "work" if File.exist? "work" - engine = new_engine engine_class + engine = new_engine engine_class - #$OWFE_LOG.level = Logger::DEBUG + #$OWFE_LOG.level = Logger::DEBUG - li = OpenWFE::LaunchItem.new def_class + li = OpenWFE::LaunchItem.new def_class - engine.launch li + engine.launch li - sleep 1 + sleep 1 - engine.stop + engine.stop - $OWFE_LOG.warn "stopped the engine" + $OWFE_LOG.warn "stopped the engine" - old_engine = engine - engine = new_engine engine_class + old_engine = engine + engine = new_engine engine_class - #$OWFE_LOG.level = Logger::DEBUG + #$OWFE_LOG.level = Logger::DEBUG - $OWFE_LOG.warn "started the new engine" + $OWFE_LOG.warn "started the new engine" - sleep 11 - #sleep 21 + sleep 11 + #sleep 21 - s_old = old_engine.application_context["__tracer"].to_s - s_now = engine.application_context["__tracer"].to_s + s_old = old_engine.application_context["__tracer"].to_s + s_now = engine.application_context["__tracer"].to_s - #puts "__ s_old >>>#{s_old}<<<" - #puts "__ s_now >>>#{s_now}<<<" + #puts "__ s_old >>>#{s_old}<<<" + #puts "__ s_now >>>#{s_now}<<<" - $OWFE_LOG.level = Logger::INFO + $OWFE_LOG.level = Logger::INFO - assert \ - (s_old == "" and s_now == "after"), - "old : '#{s_old}' / new : '#{s_now}' BAD for #{engine_class}" - end + assert \ + (s_old == "" and s_now == "after"), + "old : '#{s_old}' / new : '#{s_now}' BAD for #{engine_class}" + end - def new_engine (engine_class) + def new_engine (engine_class) - engine = engine_class.new :definition_in_launchitem_allowed => true + engine = engine_class.new :definition_in_launchitem_allowed => true - tracer = Tracer.new - engine.application_context["__tracer"] = tracer + tracer = Tracer.new + engine.application_context["__tracer"] = tracer - engine.register_participant :nemo, OpenWFE::NullParticipant + engine.register_participant :nemo, OpenWFE::NullParticipant - #engine.reschedule - engine.reload + #engine.reschedule + engine.reload - engine - end + engine + end end