Sha256: 426b1ee961550db55f3001750be2e718cedb757f29aeb4d52eeb83bfb6905485

Contents?: true

Size: 1.28 KB

Versions: 15

Compression:

Stored size: 1.28 KB

Contents

# encoding: ASCII-8BIT
require 'helper'
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

15 entries across 15 versions & 9 rubygems

Version Path
malagant-soap4r-1.5.8.20141127181857 test/soap/fault/test_customfault.rb
rtiss_soap4r-1.6.1 test/soap/fault/test_customfault.rb
rtiss_soap4r-1.6.0 test/soap/fault/test_customfault.rb
eSpace_soap4r-1.5.8 test/soap/fault/test_customfault.rb
soap4r-ruby19-1.5.9 test/soap/fault/test_customfault.rb
tomdz-soap4r-1.5.8.20120202093209 test/soap/fault/test_customfault.rb
soap5r-2.0.3 test/soap/fault/test_customfault.rb
soap5r-2.0.2 test/soap/fault/test_customfault.rb
soap5r-2.0.1 test/soap/fault/test_customfault.rb
soap5r-2.0.0 test/soap/fault/test_customfault.rb
soap5r-2.0.0.20120130130121 test/soap/fault/test_customfault.rb
soap4r-sgonyea-1.5.9 test/soap/fault/test_customfault.rb
sunteya-soap4r-1.5.8.0 test/soap/fault/test_customfault.rb
tomdz-soap4r-1.5.8.20111103171510 test/soap/fault/test_customfault.rb
rubyjedi-soap4r-1.5.8.20100619003610 test/soap/fault/test_customfault.rb