# # Testing OpenWFE # # John Mettraux at openwfe.org # # Mon Oct 9 22:19:44 JST 2006 # require 'flowtestbase' class FlowTest4 < Test::Unit::TestCase include FlowTestBase #def setup #end #def teardown #end def test_print_0 dotest( ''' ${f:xxx} ''', "${f:xxx}") end class TestPrint1 < OpenWFE::ProcessDefinition sequence do _set :v => "toto", :value => '0' _print "${toto}" _print "${toto}", :escape => false _print "${toto}", :escape => true end end def test_print_1 dotest TestPrint1, "0\n0\n${toto}" end def test_reval_0 dotest( ''' ${f:from_ruby} ''', "ok") end def test_reval_1 dotest( ''' workitem.attributes["${field-name}"] = "ok" ${f:${field-name}} ''', "ok") end def test_reval_2 dotest( ''' workitem.attributes["from_ruby"] = "${field-value}" ${f:from_ruby} ''', "ok") end def test_reval_3 dotest( ''' ${v} ''', "false") end class Reval4 < OpenWFE::ProcessDefinition reval """ tracer = self.application_context['__tracer'] tracer << 'hello\n' tracer << workitem.attributes.length.to_s """ end def test_reval_4 dotest Reval4, [ "hello\n1", "hello\n0" ] end class Reval5 < OpenWFE::ProcessDefinition sequence do reval """ wi.customer_name = 'dubious' 'surf' """ _print "${f:customer_name}" _print "${f:__result__}" end end def test_reval_5 dotest Reval5, "dubious\nsurf" end # # DRU tests def test_dru_0 dotest( ''' ${r:1+2} ''', "3") end def test_dru_1 dotest( ''' ${r:"x"*3} ''', "xxx") end def test_dru_2 dotest( ''' ${v} ''', "10") end def test_dru_3 dotest( ''' "W" * 3 ${v} ''', "WWW") end def test_dru_4 dotest( ''' fei.workflow_definition_name ${v} ${r:fei.workflow_definition_name} ''', """dru_4 dru_4""") end class TestSetEscape0 < OpenWFE::ProcessDefinition sequence do _set :v => "t0" do "This is ${my template}" end _set :v => "t1", :escape => true do "This is ${my template}" end _set :v => "t2", :val => "This is ${my template}", :escape => "true" peek #_print { v "t0" } #_print { v "t1" } end end def test_set_escape_0 @engine.register_participant :peek do |fexp, wi| @tracer << fexp.get_environment.variables['t0'] @tracer << "\n" @tracer << fexp.get_environment.variables['t1'] @tracer << "\n" @tracer << fexp.get_environment.variables['t2'] @tracer << "\n" end dotest( TestSetEscape0, "This is \nThis is ${my template}\nThis is ${my template}") end end