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

- old
+ new

@@ -9,116 +9,129 @@ require 'openwfe/def' require 'openwfe/participants/storeparticipants' class FlowTest63 < Test::Unit::TestCase - include FlowTestBase + include FlowTestBase - #def setup - #end + #def setup + #end - #def teardown - #end + #def teardown + #end - # - # Test 0 - # + # + # Test 0 + # - class Test0 < OpenWFE::ProcessDefinition - sequence do - participant :alpha - _print "done." - end + class Test0 < OpenWFE::ProcessDefinition + sequence do + participant :alpha + _print "done." end + end - def test_0 + def test_0 - #log_level_to_debug + #log_level_to_debug - sa = @engine.register_participant :alpha, OpenWFE::HashParticipant + sa = @engine.register_participant :alpha, OpenWFE::HashParticipant - fei = @engine.launch Test0 + pause_events = [] + @engine.get_expression_pool.add_observer :all do |channel, args| + pause_events << [ channel, args.wfid ] \ + if [ :pause, :resume ].include?(channel) + end - sleep 0.350 + fei = @engine.launch Test0 - assert_equal( - @engine.process_status(fei.wfid).expressions[0].fei.wfid, - fei.wfid) - #puts @engine.process_status(fei.wfid) - #puts @engine.list_process_status + sleep 0.350 - assert ! @engine.process_status(fei.wfid).paused? - assert ! @engine.is_paused?(fei.wfid) + assert_equal( + @engine.process_status(fei.wfid).expressions[0].fei.wfid, + fei.wfid) + #puts @engine.process_status(fei.wfid) + #puts @engine.list_process_status - @engine.pause_process fei.workflow_instance_id + assert ! @engine.process_status(fei.wfid).paused? + assert ! @engine.is_paused?(fei.wfid) - assert @engine.process_status(fei.wfid).paused? - assert @engine.is_paused?(fei.wfid) + @engine.pause_process fei.workflow_instance_id - hp = @engine.get_participant :alpha - wi = hp.first_workitem - hp.forward wi + assert @engine.process_status(fei.wfid).paused? + assert @engine.is_paused?(fei.wfid) + assert_equal [ [ :pause, fei.wfid ] ], pause_events - sleep 0.350 + hp = @engine.get_participant :alpha + wi = hp.first_workitem + hp.forward wi - assert_equal @engine.process_status(fei.wfid).errors.size, 1 - assert_equal @tracer.to_s, "" + sleep 0.350 - @engine.resume_process fei.workflow_instance_id + assert_equal @engine.process_status(fei.wfid).errors.size, 1 + assert_equal @tracer.to_s, '' - #unless @engine.get_expression_storage.is_a?( - # OpenWFE::InMemoryExpressionStorage) - # - # ps = @engine.process_status fei.wfid - # #puts ps - # assert_equal ps.errors.size, 0 - # assert ! ps.paused? - #end + @engine.resume_process fei.workflow_instance_id - sleep 0.350 + #assert ! @engine.process_status(fei.wfid).paused? - assert_nil @engine.process_status(fei.wfid) - assert_equal @tracer.to_s, "done." - end + #unless @engine.get_expression_storage.is_a?( + # OpenWFE::InMemoryExpressionStorage) + # + # ps = @engine.process_status fei.wfid + # #puts ps + # assert_equal ps.errors.size, 0 + # assert ! ps.paused? + #end + sleep 0.350 - # - # Test 1 - # + assert_equal( + [ [ :pause, fei.wfid ], [ :resume, fei.wfid ] ], + pause_events) - class Test1 < OpenWFE::ProcessDefinition - sequence do - participant :alpha - _print "done." - end + assert_nil @engine.process_status(fei.wfid) + assert_equal @tracer.to_s, 'done.' + end + + + # + # Test 1 + # + + class Test1 < OpenWFE::ProcessDefinition + sequence do + participant :alpha + _print "done." end + end - def test_1 + def test_1 - #log_level_to_debug + #log_level_to_debug - sa = @engine.register_participant :alpha, OpenWFE::NullParticipant + sa = @engine.register_participant :alpha, OpenWFE::NullParticipant - fei = @engine.launch Test1 + fei = @engine.launch Test1 - sleep 0.350 + sleep 0.350 - assert ! @engine.process_status(fei.wfid).paused? + assert ! @engine.process_status(fei.wfid).paused? - @engine.pause_process fei.wfid + @engine.pause_process fei.wfid - sleep 0.350 + sleep 0.350 - assert @engine.process_status(fei.wfid).paused? + assert @engine.process_status(fei.wfid).paused? - @engine.resume_process fei.wfid + @engine.resume_process fei.wfid - assert ! @engine.process_status(fei.wfid).paused? + assert ! @engine.process_status(fei.wfid).paused? - @engine.cancel_process fei.wfid + @engine.cancel_process fei.wfid - sleep 0.350 - end + sleep 0.350 + end end