File: test_nil.rb

package info (click to toggle)
ruby-soap4r 2.0.5-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,032 kB
  • sloc: ruby: 52,729; xml: 266; sh: 42; javascript: 20; makefile: 13; perl: 10
file content (57 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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

  require 'rexml/document'
  # emulates SOAP::Lite's nil request
  def test_soaplite_nil
    body = SOAP::SOAPBody.new(REXML::Document.new(<<-__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
end


end