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

- old
+ new

@@ -12,279 +12,279 @@ require 'openwfe/workitem' require 'openwfe/exceptions' class ParameterTest < Test::Unit::TestCase - include FlowTestBase + include FlowTestBase - #def setup - #end + #def setup + #end - #def teardown - #end + #def teardown + #end - # - # test 0 + # + # test 0 - def test_param_0 + def test_param_0 - definition = ''' + definition = ''' <process-definition name="reqtest" revision="0"> - <parameter field="address"/> - <print>${f:address}</print> + <parameter field="address"/> + <print>${f:address}</print> </process-definition>'''.strip - li = OpenWFE::LaunchItem.new(definition) + li = OpenWFE::LaunchItem.new(definition) - e = nil - - begin - @engine.launch li - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + e = nil - assert_equal "field 'address' is missing", e.to_s + begin + @engine.launch li + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) + end - # second round + assert_equal "field 'address' is missing", e.to_s - li = OpenWFE::LaunchItem.new(definition) - li.address = "rose garden 4" + # second round - #require 'pp' ; pp li + li = OpenWFE::LaunchItem.new(definition) + li.address = "rose garden 4" - fei = nil - e = nil - - begin - fei = @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + #require 'pp' ; pp li - assert_nil e + fei = nil + e = nil - sleep 0.350 - # let the flow terminate on its own + begin + fei = @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end + assert_nil e - # - # test 1 + sleep 0.350 + # let the flow terminate on its own + end - class TestParam1 < OpenWFE::ProcessDefinition - - param :field => "customer" - param :field => "address" - _print "#{f:customer}, #{f:address}" - end + # + # test 1 - def test_param_1 + class TestParam1 < OpenWFE::ProcessDefinition - li = OpenWFE::LaunchItem.new(TestParam1) + param :field => "customer" + param :field => "address" - e = nil - - begin - @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + _print "#{f:customer}, #{f:address}" + end - assert_equal "field 'customer' is missing", e.to_s + def test_param_1 - li = OpenWFE::LaunchItem.new(TestParam1) - li.customer = "bauhaus" - li.address = "rose garden 4" + li = OpenWFE::LaunchItem.new(TestParam1) - e = nil - - begin - @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + e = nil - assert_nil e + begin + @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end + assert_equal "field 'customer' is missing", e.to_s - # - # test 2 + li = OpenWFE::LaunchItem.new(TestParam1) + li.customer = "bauhaus" + li.address = "rose garden 4" - class TestParam2 < OpenWFE::ProcessDefinition - - param :field => "address", :default => "(unknown address)" + e = nil - sequence do - #pp_workitem - _print "${f:address}" - end + begin + @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end - def test_param_2 + assert_nil e + end - li = OpenWFE::LaunchItem.new(TestParam2) - e = nil + # + # test 2 - begin - @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + class TestParam2 < OpenWFE::ProcessDefinition - sleep 0.350 + param :field => "address", :default => "(unknown address)" - assert_nil e - assert_equal "(unknown address)", @tracer.to_s + sequence do + #pp_workitem + _print "${f:address}" end + end + def test_param_2 - # - # test 3 + li = OpenWFE::LaunchItem.new(TestParam2) - class TestParam3 < OpenWFE::ProcessDefinition - - param :field => :address, :type => :string + e = nil - sequence do - #pp_workitem - _print "${f:address}" - end + begin + @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end - def test_param_3 + sleep 0.350 - li = OpenWFE::LaunchItem.new(TestParam3) - li.address = 3 + assert_nil e + assert_equal "(unknown address)", @tracer.to_s + end - e = nil - begin - @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + # + # test 3 - sleep 0.350 + class TestParam3 < OpenWFE::ProcessDefinition - # well, I should maybe refactor the test into a method + param :field => :address, :type => :string - assert_nil e - assert_equal "3", @tracer.to_s + sequence do + #pp_workitem + _print "${f:address}" end + end + def test_param_3 - # - # test 4 + li = OpenWFE::LaunchItem.new(TestParam3) + li.address = 3 - class TestParam4 < OpenWFE::ProcessDefinition - - param :field => :zip, :type => :integer + e = nil - _print "${f:zip}" + begin + @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end - def test_param_4 + sleep 0.350 - li = OpenWFE::LaunchItem.new(TestParam4) - li.zip = "Colorado" + # well, I should maybe refactor the test into a method - e = nil + assert_nil e + assert_equal "3", @tracer.to_s + end - begin - @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end - assert_not_nil e - assert_equal 'invalid value for Integer: "Colorado"', e.to_s + # + # test 4 + + class TestParam4 < OpenWFE::ProcessDefinition + + param :field => :zip, :type => :integer + + _print "${f:zip}" + end + + def test_param_4 + + li = OpenWFE::LaunchItem.new(TestParam4) + li.zip = "Colorado" + + e = nil + + begin + @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end + assert_not_nil e + assert_equal 'invalid value for Integer: "Colorado"', e.to_s + end - # - # test 5 - def test_param_5 + # + # test 5 - definition = ''' + def test_param_5 + + definition = ''' <process-definition name="paramtest" revision="5"> - <parameter field="phone" match="^[0-9]{3}-[0-9]{3}-[0-9]{4}$" /> - <print>${field:phone}</print> + <parameter field="phone" match="^[0-9]{3}-[0-9]{3}-[0-9]{4}$" /> + <print>${field:phone}</print> </process-definition>'''.strip - li = OpenWFE::LaunchItem.new(definition) + li = OpenWFE::LaunchItem.new(definition) - e = nil - - begin - @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + e = nil - assert_equal "field 'phone' is missing", e.to_s - assert_equal OpenWFE::ParameterException, e.class + begin + @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) + end - # second round + assert_equal "field 'phone' is missing", e.to_s + assert_equal OpenWFE::ParameterException, e.class - li = OpenWFE::LaunchItem.new(definition) - li.phone = "4444-333-4444" + # second round - #require 'pp' ; pp li + li = OpenWFE::LaunchItem.new(definition) + li.phone = "4444-333-4444" - e = nil - - begin - @engine.launch(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + #require 'pp' ; pp li - assert_not_nil e - assert_equal "value of field 'phone' doesn't match", e.to_s + e = nil + + begin + @engine.launch(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end + assert_not_nil e + assert_equal "value of field 'phone' doesn't match", e.to_s + end - # - # test 6 - class TestParam6 < OpenWFE::ProcessDefinition - - param :field => "customer_type", :default => "2", :type => "int" + # + # test 6 - _print "#{f:customer}, #{f:address}" - end + class TestParam6 < OpenWFE::ProcessDefinition - def test_param_1 + param :field => "customer_type", :default => "2", :type => "int" - li = OpenWFE::LaunchItem.new(TestParam6) + _print "#{f:customer}, #{f:address}" + end - e = nil - begin - @engine.pre_launch_check(li) - rescue Exception => e - #puts e - #puts OpenWFE::exception_to_s(e) - end + def test_param_1 - #require 'pp'; pp li + li = OpenWFE::LaunchItem.new(TestParam6) - assert_nil e - assert li.customer_type - assert li.customer_type == 2 + e = nil + begin + @engine.pre_launch_check(li) + rescue Exception => e + #puts e + #puts OpenWFE::exception_to_s(e) end + + #require 'pp'; pp li + + assert_nil e + assert li.customer_type + assert li.customer_type == 2 + end end