test/restart_cron_test.rb in ruote-0.9.18 vs test/restart_cron_test.rb in ruote-0.9.19
- old
+ new
@@ -19,118 +19,118 @@
require 'rutest_utils'
class RestartCronTest < Test::Unit::TestCase
- #def setup
- # @engine = $WORKFLOW_ENGINE_CLASS.new()
- #end
+ #def setup
+ # @engine = $WORKFLOW_ENGINE_CLASS.new()
+ #end
- def teardown
- FileUtils.rm_rf 'work'
- end
+ def teardown
+ FileUtils.rm_rf 'work'
+ end
- # test 0
+ # test 0
- class RestartDefinition0 < OpenWFE::ProcessDefinition
- cron :tab => "* * * * *", :name => "//mycron" do
- cron_event_restart
- end
+ class RestartDefinition0 < OpenWFE::ProcessDefinition
+ cron :tab => "* * * * *", :name => "//mycron" do
+ cron_event_restart
end
+ end
- def test_0
+ def test_0
- dotest RestartDefinition0
+ dotest RestartDefinition0
- assert_equal(
- 4, @engine.get_expression_storage.size,
- "\n\n" + @engine.get_expression_storage.to_s)
- end
+ assert_equal(
+ 4, @engine.get_expression_storage.size,
+ "\n\n" + @engine.get_expression_storage.to_s)
+ end
- # test 1
+ # test 1
- class RestartDefinition1 < OpenWFE::ProcessDefinition
- concurrence do
- cron :tab => "* * * * *", :name => "mycron" do
- cron_event_restart
- end
- participant :ref => "nada"
- end
+ class RestartDefinition1 < OpenWFE::ProcessDefinition
+ concurrence do
+ cron :tab => "* * * * *", :name => "mycron" do
+ cron_event_restart
+ end
+ participant :ref => "nada"
end
+ end
- def test_1
+ def test_1
- dotest RestartDefinition1
+ dotest RestartDefinition1
- assert_equal(
- 6, @engine.get_expression_storage.size,
- "\n\n" + @engine.get_expression_storage.to_s)
- end
+ assert_equal(
+ 6, @engine.get_expression_storage.size,
+ "\n\n" + @engine.get_expression_storage.to_s)
+ end
- protected
+ protected
- def dotest (definition)
+ def dotest (definition)
- @engine = new_engine
+ @engine = new_engine
- feis = []
+ feis = []
- participant = lambda do |wi|
- feis << wi.fei.dup
- end
- @engine.register_participant :cron_event_restart, &participant
- @engine.register_participant :nada, OpenWFE::NullParticipant
+ participant = lambda do |wi|
+ feis << wi.fei.dup
+ end
+ @engine.register_participant :cron_event_restart, &participant
+ @engine.register_participant :nada, OpenWFE::NullParticipant
- fei = @engine.launch definition
+ fei = @engine.launch definition
- sleep 60
+ sleep 60
- @engine.stop
+ @engine.stop
- assert_equal 1, @engine.get_scheduler.cron_job_count
- assert_equal 1, feis.size
+ assert_equal 1, @engine.get_scheduler.cron_job_count
+ assert_equal 1, feis.size
- assert_equal(
- ".0",
- feis[0].expid[-2, 2],
- "not ending with .0 : >#{feis[0].expid}<")
- assert_equal(
- fei.wfid,
- feis[0].wfid)
+ assert_equal(
+ ".0",
+ feis[0].expid[-2, 2],
+ "not ending with .0 : >#{feis[0].expid}<")
+ assert_equal(
+ fei.wfid,
+ feis[0].wfid)
- #puts "___restarting to new engine"
+ #puts "___restarting to new engine"
- #old_engine = @engine
- new_engine
+ #old_engine = @engine
+ new_engine
- @engine.register_participant :cron_event_restart, &participant
- @engine.register_participant :nada, OpenWFE::NullParticipant
+ @engine.register_participant :cron_event_restart, &participant
+ @engine.register_participant :nada, OpenWFE::NullParticipant
- @engine.reload
- #
- # very important
+ @engine.reload
+ #
+ # very important
- sleep 60
+ sleep 60
- assert_equal(
- 1, @engine.get_scheduler.cron_job_count, "wrong cron job count")
+ assert_equal(
+ 1, @engine.get_scheduler.cron_job_count, "wrong cron job count")
- @engine.stop
+ @engine.stop
- assert_equal 2, feis.size
- assert_equal feis[0].wfid, feis[1].wfid
+ assert_equal 2, feis.size
+ assert_equal feis[0].wfid, feis[1].wfid
- assert feis[0].expid[-1, 1].to_i < feis[1].expid[-1, 1].to_i
- end
+ assert feis[0].expid[-1, 1].to_i < feis[1].expid[-1, 1].to_i
+ end
- def new_engine
+ def new_engine
- @engine = OpenWFE::FilePersistedEngine.new(
- :definition_in_launchitem_allowed => true)
+ @engine = OpenWFE::FilePersistedEngine.new(
+ :definition_in_launchitem_allowed => true)
- #engine = OpenWFE::CachedFilePersistedEngine.new
+ #engine = OpenWFE::CachedFilePersistedEngine.new
- #$OWFE_LOG.level = Logger::DEBUG
- end
+ #$OWFE_LOG.level = Logger::DEBUG
+ end
end