1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
require 'soap/rpc/router'
require 'soap/mapping/mapping'
require 'soap/processor'
require 'test/unit'
module SOAP
module Fault
class TestSOAPArray < Test::Unit::TestCase
# simulate the soap fault creation and parsing on the client
def test_parse_fault
router = SOAP::RPC::Router.new('parse_SOAPArray_error')
soap_fault = pump_stack rescue router.create_fault_response($!)
env = SOAP::Processor.unmarshal(soap_fault.send_string)
soap_fault = SOAP::FaultError.new(env.body.fault)
# in literal service, RuntimeError is raised (not an ArgumentError)
# any chance to use Ruby's exception encoding in literal service?
assert_raises(RuntimeError) do
registry = SOAP::Mapping::LiteralRegistry.new
SOAP::Mapping.fault2exception(soap_fault, registry)
end
end
def pump_stack(max = 0)
raise ArgumentError if max > 10
pump_stack(max+1)
end
end
end
end
|