Change soft-fail to use the config, rather than env
[rbx.git] / test / mri / wsdl / test_fault.rb
blobec414528eeae5023582d693e706169731fb48867
1 require 'test/unit'
2 require 'soap/processor'
3 require 'soap/mapping'
4 require 'soap/rpc/element'
5 require 'wsdl/parser'
8 module WSDL
11 class TestFault < Test::Unit::TestCase
12   def setup
13     @xml =<<__EOX__
14 <?xml version="1.0" encoding="utf-8" ?>
15 <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
16     xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
17     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
18   <env:Body>
19     <env:Fault xmlns:n1="http://schemas.xmlsoap.org/soap/encoding/"
20         env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
21       <faultcode xsi:type="xsd:string">Server</faultcode>
22       <faultstring xsi:type="xsd:string">faultstring</faultstring>
23       <faultactor xsi:type="xsd:string">faultactor</faultactor>
24       <detail xmlns:n2="http://www.ruby-lang.org/xmlns/ruby/type/custom"
25           xsi:type="n2:SOAPException">
26         <excn_type_name xsi:type="xsd:string">type</excn_type_name>
27         <cause href="#id123"/>
28       </detail>
29     </env:Fault>
30     <cause id="id123" xsi:type="xsd:int">5</cause>
31   </env:Body>
32 </env:Envelope>
33 __EOX__
34   end
36   def test_by_wsdl
37     rpc_decode_typemap = WSDL::Definitions.soap_rpc_complextypes
38     opt = {}
39     opt[:default_encodingstyle] = ::SOAP::EncodingNamespace
40     opt[:decode_typemap] = rpc_decode_typemap
41     header, body = ::SOAP::Processor.unmarshal(@xml, opt)
42     fault = ::SOAP::Mapping.soap2obj(body.response)
43     assert_equal("Server", fault.faultcode)
44     assert_equal("faultstring", fault.faultstring)
45     assert_equal(URI.parse("faultactor"), fault.faultactor)
46     assert_equal(5, fault.detail.cause)
47   end
48 end
51 end