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

- old
+ new

@@ -1,7 +1,8 @@ + # -# Testing OpenWFE +# Testing OpenWFEru (Ruote) # # John Mettraux at openwfe.org # # Sun Oct 29 15:41:44 JST 2006 # @@ -16,149 +17,152 @@ require 'openwfe/participants/storeparticipants' class HParticipantTest < Test::Unit::TestCase - def setup + def setup - @engine = Engine.new({ :definition_in_launchitem_allowed => true }) - end + @engine = OpenWFE::Engine.new :definition_in_launchitem_allowed => true + end - def teardown + def teardown - @engine.stop if @engine - end + @engine.stop if @engine + end - class HpDefinition0 < OpenWFE::ProcessDefinition - sequence do - participant :alice - participant :bob - end + class HpDefinition0 < OpenWFE::ProcessDefinition + sequence do + participant :alice + participant :bob end + end - def test_hp_0 + def test_hp_0 - @hpAlice = HashParticipant.new - @hpBob = HashParticipant.new + @hpAlice = OpenWFE::HashParticipant.new + @hpBob = OpenWFE::HashParticipant.new - @engine.register_participant :alice, @hpAlice - @engine.register_participant :bob, @hpBob + @engine.register_participant :alice, @hpAlice + @engine.register_participant :bob, @hpBob - do_test - end + do_test + end - def test_hp_1 + def test_hp_1 - #FileUtils.remove_dir "./work" if File.exist? "./work" - FileUtils.rm_rf "work" if File.exist? "./work" + #FileUtils.remove_dir "./work" if File.exist? "./work" + FileUtils.rm_rf "work" if File.exist? "./work" - @engine.application_context[:work_directory] = "./work" - @hpAlice = YamlParticipant.new("alice", @engine.application_context) - #@hpBob = YamlParticipant.new("bob", @engine.application_context) + @engine.application_context[:work_directory] = "./work" - @engine.register_participant(:alice, @hpAlice) - #@engine.register_participant(:bob, @hpBob) - @hpBob = @engine.register_participant(:bob, YamlParticipant) + @hpAlice = OpenWFE::YamlParticipant.new( + "alice", @engine.application_context) + #@hpBob = OpenWFE::YamlParticipant.new( + # "bob", @engine.application_context) - do_test - end + @engine.register_participant(:alice, @hpAlice) + #@engine.register_participant(:bob, @hpBob) + @hpBob = @engine.register_participant(:bob, OpenWFE::YamlParticipant) - def do_test + do_test + end - id = @engine.launch HpDefinition0 + def do_test - assert \ - id.kind_of?(FlowExpressionId), - "engine.launch() doesn't return an instance of FlowExpressionId "+ - "but of #{id.class}" + id = @engine.launch HpDefinition0 - #puts id.to_s + assert \ + id.is_a?(OpenWFE::FlowExpressionId), + "engine.launch() doesn't return an instance of FlowExpressionId "+ + "but of #{id.class}" - #puts "alice count : #{@hpAlice.size}" - #puts "bob count : #{@hpBob.size}" + #puts id.to_s - sleep 0.350 + #puts "alice count : #{@hpAlice.size}" + #puts "bob count : #{@hpBob.size}" - assert_equal 0, @hpBob.size - assert_equal 1, @hpAlice.size + sleep 0.350 - wi = @hpAlice.list_workitems(id.workflow_instance_id)[0] + assert_equal 0, @hpBob.size + assert_equal 1, @hpAlice.size - assert \ - wi != nil, - "didn't find wi for flow #{id.workflow_instance_id}" + wi = @hpAlice.list_workitems(id.workflow_instance_id)[0] - wi.message = "Hello bob !" + assert \ + wi != nil, + "didn't find wi for flow #{id.workflow_instance_id}" - @hpAlice.forward(wi) + wi.message = "Hello bob !" - sleep 0.350 + @hpAlice.forward(wi) - assert_equal 0, @hpAlice.size - assert_equal 1, @hpBob.size + sleep 0.350 - wi = @hpBob.list_workitems(id.workflow_instance_id)[0] + assert_equal 0, @hpAlice.size + assert_equal 1, @hpBob.size - assert_equal wi.message, "Hello bob !" + wi = @hpBob.list_workitems(id.workflow_instance_id)[0] - @hpBob.proceed wi + assert_equal wi.message, "Hello bob !" - sleep 0.350 + @hpBob.proceed wi - assert_equal 0, @hpAlice.size - assert_equal 0, @hpBob.size + sleep 0.350 - assert_equal 1, @engine.get_expression_storage.size - end + assert_equal 0, @hpAlice.size + assert_equal 0, @hpBob.size - def test_d_0 + assert_equal 1, @engine.get_expression_storage.size + end - @hpAlice = HashParticipant.new - @hpBob = HashParticipant.new + def test_d_0 - @engine.register_participant :alice, @hpAlice - @engine.register_participant :bob, @hpBob + @hpAlice = OpenWFE::HashParticipant.new + @hpBob = OpenWFE::HashParticipant.new - id = @engine.launch HpDefinition0 + @engine.register_participant :alice, @hpAlice + @engine.register_participant :bob, @hpBob - sleep 0.350 + id = @engine.launch HpDefinition0 - assert_equal 1, @hpAlice.size - assert_equal 0, @hpBob.size + sleep 0.350 - wi = @hpAlice.first_workitem + assert_equal 1, @hpAlice.size + assert_equal 0, @hpBob.size - @hpAlice.delegate wi, @hpBob + wi = @hpAlice.first_workitem - assert_equal 0, @hpAlice.size - assert_equal 1, @hpBob.size + @hpAlice.delegate wi, @hpBob - wi = @hpBob.first_workitem + assert_equal 0, @hpAlice.size + assert_equal 1, @hpBob.size - @hpBob.proceed wi + wi = @hpBob.first_workitem - sleep 0.350 + @hpBob.proceed wi - assert_equal 0, @hpAlice.size - assert_equal 1, @hpBob.size + sleep 0.350 - wi = @hpBob.first_workitem + assert_equal 0, @hpAlice.size + assert_equal 1, @hpBob.size - @hpBob.delegate wi.fei, @hpAlice + wi = @hpBob.first_workitem - assert_equal 1, @hpAlice.size - assert_equal 0, @hpBob.size + @hpBob.delegate wi.fei, @hpAlice - wi = @hpAlice.first_workitem + assert_equal 1, @hpAlice.size + assert_equal 0, @hpBob.size - @hpAlice.forward wi + wi = @hpAlice.first_workitem - sleep 0.350 + @hpAlice.forward wi - assert_equal 0, @hpAlice.size - assert_equal 0, @hpBob.size + sleep 0.350 - assert_equal 1, @engine.get_expression_storage.size - end + assert_equal 0, @hpAlice.size + assert_equal 0, @hpBob.size + + assert_equal 1, @engine.get_expression_storage.size + end end