test/functional/ft_4_cancel.rb in ruote-2.2.0 vs test/functional/ft_4_cancel.rb in ruote-2.3.0

- old
+ new

@@ -3,11 +3,11 @@ # testing ruote # # Wed Jun 3 08:42:07 JST 2009 # -require File.join(File.dirname(__FILE__), 'base') +require File.expand_path('../base', __FILE__) require 'ruote/participant' class FtCancelTest < Test::Unit::TestCase @@ -17,26 +17,26 @@ pdef = Ruote.process_definition do alpha end - alpha = @engine.register_participant :alpha, Ruote::StorageParticipant + alpha = @dashboard.register_participant :alpha, Ruote::StorageParticipant #noisy - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) wait_for(:alpha) - ps = @engine.process(wfid) + ps = @dashboard.process(wfid) assert_equal 1, alpha.size assert_not_nil ps - @engine.cancel_process(wfid) + @dashboard.cancel_process(wfid) wait_for(wfid) - ps = @engine.process(wfid) + ps = @dashboard.process(wfid) assert_nil ps assert_equal 0, alpha.size #puts; logger.log.each { |e| p e['action'] }; puts @@ -51,23 +51,23 @@ alpha bravo end end - @engine.register_participant :alpha, Ruote::StorageParticipant - sto = @engine.register_participant :bravo, Ruote::StorageParticipant + @dashboard.register_participant :alpha, Ruote::StorageParticipant + sto = @dashboard.register_participant :bravo, Ruote::StorageParticipant #noisy - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) wait_for(:alpha) assert_equal 1, sto.size wi = sto.first - @engine.cancel_expression(wi.fei) + @dashboard.cancel_expression(wi.fei) wait_for(:bravo) assert_equal 1, sto.size assert_equal 'bravo', sto.first.participant_name end @@ -76,27 +76,38 @@ pdef = Ruote.process_definition do alpha end - @engine.register_participant :alpha, Ruote::NullParticipant + @dashboard.register_participant :alpha, Ruote::NullParticipant #noisy - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) - @engine.wait_for(:alpha) + @dashboard.wait_for(:alpha) - @engine.cancel(wfid) + @dashboard.cancel(wfid) - @engine.wait_for(wfid) + @dashboard.wait_for(wfid) - assert_nil @engine.process(wfid) + assert_nil @dashboard.process(wfid) - assert_equal 1, logger.log.select { |e| e['action'] == 'cancel_process' }.size + assert_equal( + 1, + logger.log.select { |e| e['action'] == 'cancel_process' }.size) end + def test_cancel_process_with_source + + @dashboard.cancel('20111121-nada', :source => 'x') + + @dashboard.wait_for(1) + + assert_equal 'x', logger.log.first['source'] + end + def test_cancel__expression pdef = Ruote.process_definition do alpha echo '0' @@ -104,29 +115,76 @@ echo '1' alpha echo '2' end - @engine.register_participant :alpha, Ruote::NullParticipant + @dashboard.register_participant :alpha, Ruote::NullParticipant - wfid = @engine.launch(pdef) + wfid = @dashboard.launch(pdef) - r = @engine.wait_for(:alpha) + r = @dashboard.wait_for(:alpha) - @engine.cancel(r['fei']) # fei as a Hash + @dashboard.cancel(r['fei']) # fei as a Hash - r = @engine.wait_for(:alpha) + r = @dashboard.wait_for(:alpha) - @engine.cancel(Ruote.sid(r['fei'])) # fei as a String + @dashboard.cancel(Ruote.sid(r['fei'])) # fei as a String - r = @engine.wait_for(:alpha) + r = @dashboard.wait_for(:alpha) - @engine.cancel(Ruote::Workitem.new(r['workitem'])) # fei as workitem + @dashboard.cancel(Ruote::Workitem.new(r['workitem'])) # fei as workitem - @engine.wait_for(wfid) + @dashboard.wait_for(wfid) assert_equal %w[ 0 1 2 ], @tracer.to_a assert_equal 3, logger.log.select { |e| e['action'] == 'cancel' }.size + end + + def test_cancel_rebound + + pdef = Ruote.define do + stall + end + + wfid = @dashboard.launch(pdef) + @dashboard.wait_for('apply') + + @dashboard.cancel(wfid) + r = @dashboard.wait_for('terminated') + + assert_equal 'cancel', r['flavour'] + end + + def test_kill_rebound + + pdef = Ruote.define do + stall + end + + wfid = @dashboard.launch(pdef) + @dashboard.wait_for('apply') + + @dashboard.kill(wfid) + r = @dashboard.wait_for('terminated') + + assert_equal 'kill', r['flavour'] + end + + def test_cancel_limited_rebound + + pdef = Ruote.define do + stall + end + + wfid = @dashboard.launch(pdef) + @dashboard.wait_for('apply') + + exp = @dashboard.process(wfid).expressions.last + + @dashboard.cancel(exp) + r = @dashboard.wait_for('terminated') + + assert_equal nil, r['flavour'] end end