2
require 'soap/rpc/driver'
3
require 'soap/rpc/standaloneServer'
10
class TestCustomFault < Test::Unit::TestCase
13
class CustomFaultServer < SOAP::RPC::StandaloneServer
15
add_method(self, 'fault', 'msg')
19
SOAPFault.new(SOAPString.new("mycustom"),
20
SOAPString.new("error: #{msg}"),
21
SOAPString.new(self.class.name))
26
@server = CustomFaultServer.new('customfault', 'urn:customfault', '0.0.0.0', Port)
27
@server.level = Logger::Severity::ERROR
29
Thread.current.abort_on_exception = true
32
@endpoint = "http://localhost:#{Port}/"
33
@client = SOAP::RPC::Driver.new(@endpoint, 'urn:customfault')
34
@client.wiredump_dev = STDERR if $DEBUG
35
@client.add_method("fault", "msg")
47
@client.fault("message")
48
assert(false, 'exception not raised')
49
rescue SOAP::FaultError => e
50
assert(true, 'exception raised')
51
assert_equal('error: message', e.message)