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

- old
+ new

@@ -5,146 +5,208 @@ # John Mettraux at openwfe.org # # Sat Jul 7 22:44:00 JST 2007 (tanabata) # +require 'rubygems' + require 'openwfe/def' require 'openwfe/participants/storeparticipants' require 'flowtestbase' class FlowTest59 < Test::Unit::TestCase - include FlowTestBase + include FlowTestBase - #def setup - #end + #def setup + #end - #def teardown - #end + #def teardown + #end - # - # TEST 0 + # + # TEST 0 - class Def59 < ProcessDefinition - concurrence do - store_a - store_b - end + class Def59 < OpenWFE::ProcessDefinition + concurrence do + store_a + store_b end + end - def test_0 + def test_0 - sa = @engine.register_participant("store_a", OpenWFE::HashParticipant) - sb = @engine.register_participant("store_b", OpenWFE::HashParticipant) + sa = @engine.register_participant("store_a", OpenWFE::HashParticipant) + sb = @engine.register_participant("store_b", OpenWFE::HashParticipant) - fei = launch Def59 + fei = launch Def59 - sleep 0.350 + sleep 0.350 - ps = @engine.process_statuses - #puts ps + ps = @engine.process_statuses + #puts ps - assert_equal 2, ps[fei.wfid].expressions.size - assert_equal 0, ps[fei.wfid].errors.size + assert_equal 2, ps[fei.wfid].expressions.size + assert_equal 0, ps[fei.wfid].errors.size - @engine.cancel_process fei - end + @engine.cancel_process fei + end - # - # TEST 0b + # + # TEST 0b - class Def59b < ProcessDefinition - sequence do - alpha - bravo - end + class Def59b < OpenWFE::ProcessDefinition + sequence do + alpha + bravo end + end - def test_0b + def test_0b - a = @engine.register_participant :alpha, OpenWFE::HashParticipant - b = @engine.register_participant :bravo, OpenWFE::HashParticipant + a = @engine.register_participant :alpha, OpenWFE::HashParticipant + b = @engine.register_participant :bravo, OpenWFE::HashParticipant - fei = launch Def59b + fei = launch Def59b - sleep 0.350 + sleep 0.350 - ps = @engine.process_statuses - #puts ps + ps = @engine.process_statuses + #puts ps - assert_equal 1, ps[fei.wfid].expressions.size - assert_equal 0, ps[fei.wfid].errors.size + assert_equal 1, ps[fei.wfid].expressions.size + assert_equal 0, ps[fei.wfid].errors.size - @engine.cancel_process fei + @engine.cancel_process fei + end + + # + # TEST 1 + + class Def59_1 < OpenWFE::ProcessDefinition + sequence do + nada59_1 + alpha end + end - # - # TEST 1 + def test_1 - class Def59_1 < ProcessDefinition - sequence do - nada59_1 - alpha - end + alpha = @engine.register_participant :alpha do + # nothing end - def test_1 + fei = launch Def59_1 - alpha = @engine.register_participant :alpha do - # nothing - end + sleep 0.350 - fei = launch Def59_1 + ps = @engine.process_statuses + #p ps[fei.wfid].scheduled_jobs + #puts ps[fei.wfid].errors - sleep 0.350 + assert_equal 1, ps[fei.wfid].expressions.size + assert_equal 1, ps[fei.wfid].branches + assert_equal 1, ps[fei.wfid].errors.size - ps = @engine.process_statuses - #puts ps - #puts ps[fei.wfid].errors + #puts + #puts ps.to_s - assert_equal 1, ps[fei.wfid].expressions.size - assert_equal 1, ps[fei.wfid].branches - assert_equal 1, ps[fei.wfid].errors.size + @engine.cancel_process fei.wfid + end - #puts - #puts ps.to_s + # + # TEST 2 - @engine.cancel_process fei.wfid + class Def59c < OpenWFE::ProcessDefinition + sequence do + bravo + alpha end + end - # - # TEST 2 + def test_2 - class Def59c < ProcessDefinition - sequence do - bravo - alpha - end + a = @engine.register_participant :alpha, OpenWFE::HashParticipant + b = @engine.register_participant :bravo, OpenWFE::HashParticipant + + feis = [] + feis << launch(Def59b) + feis << launch(Def59b) + feis << launch(Def59c) + + sleep 0.350 + + assert_equal 3, @engine.list_processes(:wfname => "Def").size + assert_equal 2, @engine.list_processes(:wfrevision => "59b").size + assert_equal 1, @engine.list_processes(:wfrevision => "59c").size + assert_equal 2, @engine.list_processes(:wfname => "Def", :wfrevision => "59b").size + + feis.each do |fei| + @engine.cancel_process fei end - def test_2 + sleep 0.350 + end - a = @engine.register_participant :alpha, OpenWFE::HashParticipant - b = @engine.register_participant :bravo, OpenWFE::HashParticipant + # + # TEST 3 - feis = [] - feis << launch(Def59b) - feis << launch(Def59b) - feis << launch(Def59c) + class Def59d < OpenWFE::ProcessDefinition + _sleep "1h" + end - sleep 0.350 + def test_3 - assert_equal 3, @engine.list_processes(:wfname => "Def").size - assert_equal 2, @engine.list_processes(:wfrevision => "59b").size - assert_equal 1, @engine.list_processes(:wfrevision => "59c").size - assert_equal 2, @engine.list_processes(:wfname => "Def", :wfrevision => "59b").size + now = Time.now - feis.each do |fei| - @engine.cancel_process fei - end + fei = launch Def59d - sleep 0.350 - end + sleep 0.350 + + ps = @engine.process_status fei.wfid + + delta = ps.scheduled_jobs.first.next_time - now + assert(delta > 3600) + assert(delta < 3601) + + purge_engine + end + + # + # TEST 4 + + def test_4 + + sa = @engine.register_participant('store_a', OpenWFE::HashParticipant) + sb = @engine.register_participant('store_b', OpenWFE::HashParticipant) + + fei = launch Def59 + + sleep 0.350 + + ps0 = @engine.process_status fei.wfid + pss0 = @engine.process_statuses + sleep 0.020 + ps1 = @engine.process_status fei.wfid + pss1 = @engine.process_statuses + + assert_equal ps0.timestamp, ps1.timestamp + assert_equal pss0.object_id, pss1.object_id + + sa.forward(sa.first_workitem) + + sleep 0.350 + + ps2 = @engine.process_status fei.wfid + pss2 = @engine.process_statuses + + assert_not_equal ps0.timestamp, ps2.timestamp + assert_not_equal pss0.object_id, pss2.object_id + + @engine.cancel_process fei + + sleep 0.350 + end end