Sha256: ce9f7671ff859c1fb40eeea9fb52abf347c6e3ac25e11ed8858004a208552f29

Contents?: true

Size: 1.26 KB

Versions: 30

Compression:

Stored size: 1.26 KB

Contents

require 'test/unit'
require 'soap/rpc/driver'
require 'soap/rpc/standaloneServer'


module SOAP
module Fault


class TestCustomFault < Test::Unit::TestCase
  Port = 17171

  class CustomFaultServer < SOAP::RPC::StandaloneServer
    def on_init
      add_method(self, 'fault', 'msg')
    end

    def fault(msg)
      SOAPFault.new(SOAPString.new("mycustom"),
        SOAPString.new("error: #{msg}"),
        SOAPString.new(self.class.name))
    end
  end

  def setup
    @server = CustomFaultServer.new('customfault', 'urn:customfault', '0.0.0.0', Port)
    @server.level = Logger::Severity::ERROR
    @t = Thread.new {
      Thread.current.abort_on_exception = true
      @server.start
    }
    @endpoint = "http://localhost:#{Port}/"
    @client = SOAP::RPC::Driver.new(@endpoint, 'urn:customfault')
    @client.wiredump_dev = STDERR if $DEBUG
    @client.add_method("fault", "msg")
  end

  def teardown
    @server.shutdown if @server
    if @t
      @t.kill
      @t.join
    end
    @client.reset_stream if @client
  end

  def test_custom_fault
    begin
      @client.fault("message")
      assert(false, 'exception not raised')
    rescue SOAP::FaultError => e
      assert(true, 'exception raised')
      assert_equal('error: message', e.message)
    end
  end
end


end
end

Version data entries

30 entries across 30 versions & 13 rubygems

Version Path
mumboe-soap4r-1.6.0.pre.beta test/soap/fault/test_customfault.rb
DefV-soap4r-1.5.8.2 test/soap/fault/test_customfault.rb
mumboe-soap4r-1.5.8.7 test/soap/fault/test_customfault.rb
teo-soap4r-1.5.9b test/soap/fault/test_customfault.rb
mumboe-soap4r-1.5.8.6 test/soap/fault/test_customfault.rb
soap4r-spox-1.6.0 test/soap/fault/test_customfault.rb
soap4r-r19-1.5.9 test/soap/fault/test_customfault.rb
mumboe-soap4r-1.5.8.5 test/soap/fault/test_customfault.rb
soap4r-ruby1.9-2.0.5 test/soap/fault/test_customfault.rb
soap4r-sgonyea-1.6.0 test/soap/fault/test_customfault.rb
soap4r-straightjacket-1.5.9 test/soap/fault/test_customfault.rb
soap4r-straightjacket-1.5.8 test/soap/fault/test_customfault.rb
soap4r-ruby1.9-2.0.3 test/soap/fault/test_customfault.rb
soap4r-ruby1.9-2.0.2 test/soap/fault/test_customfault.rb
soap4r-ruby1.9-2.0.1 test/soap/fault/test_customfault.rb
mumboe-soap4r-1.5.8.4 test/soap/fault/test_customfault.rb
soap4r-ruby1.9-2.0.0 test/soap/fault/test_customfault.rb
hands-soap4r-1.5.8.4 test/soap/fault/test_customfault.rb
soap4r-ruby1.9-1.0.0 test/soap/fault/test_customfault.rb
snaury-soap4r-1.5.8.1 test/soap/fault/test_customfault.rb