Sha256: 240fe87599db681c4ec9710bac1a8b10f82e28060780567b20a944ec43e14d0b

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

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


module SOAP


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

  class NilServer < SOAP::RPC::StandaloneServer
    def initialize(*arg)
      super
      add_method(self, 'nop')
    end

    def nop
      1
    end
  end

  def setup
    @server = NilServer.new(self.class.name, nil, '0.0.0.0', Port)
    @server.level = Logger::Severity::ERROR
    @t = Thread.new {
      @server.start
    }
    @endpoint = "http://localhost:#{Port}/"
    @client = SOAP::RPC::Driver.new(@endpoint)
    @client.add_rpc_method('nop')
  end

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

  begin
    require 'nokogiri'
    # emulates SOAP::Lite's nil request (Nokogiri)
    def test_soaplite_nil
       body = SOAP::SOAPBody.new(Nokogiri::XML(<<-__XML__))
         <nop xsi:nil="true"/>
       __XML__
      @client.wiredump_dev = STDOUT if $DEBUG
      header, body = @client.invoke(nil, body)
      assert_equal(1, body.root_node["return"].data)
    end
  rescue LoadError
    puts "Nokogiri Not Installed"
  end

  begin
    require 'rexml/document'
    # emulates SOAP::Lite's nil request (REXML)
    def test_soaplite_nil
      body = SOAP::SOAPBody.new(REXML::Document.new(<<-__XML__))
        <nop nil="true"/>
      __XML__
      @client.wiredump_dev = STDOUT if $DEBUG
      header, body = @client.invoke(nil, body)
      assert_equal(1, body.root_node["return"].data)
    end
  rescue LoadError
    puts "REXML Not Installed"
  end
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyjedi-soap4r-1.5.8.01 test/soap/test_nil.rb