Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/trunk/test/soap/test_nil.rb

Revision 1963, 1.1 kB (checked in by nahi, 1 year ago)
  • update tests. do not crash at teardown when setup failed. closes #396.
Line 
1 require 'test/unit'
2 require 'soap/rpc/standaloneServer'
3 require 'soap/rpc/driver'
4 require 'soap/header/handler'
5
6
7 module SOAP
8
9
10 class TestNil < Test::Unit::TestCase
11   Port = 17171
12
13   class NilServer < SOAP::RPC::StandaloneServer
14     def initialize(*arg)
15       super
16       add_method(self, 'nop')
17     end
18
19     def nop
20       1
21     end
22   end
23
24   def setup
25     @server = NilServer.new(self.class.name, nil, '0.0.0.0', Port)
26     @server.level = Logger::Severity::ERROR
27     @t = Thread.new {
28       @server.start
29     }
30     @endpoint = "http://localhost:#{Port}/"
31     @client = SOAP::RPC::Driver.new(@endpoint)
32     @client.add_rpc_method('nop')
33   end
34
35   def teardown
36     @server.shutdown if @server
37     if @t
38       @t.kill
39       @t.join
40     end
41     @client.reset_stream if @client
42   end
43
44   require 'rexml/document'
45   # emulates SOAP::Lite's nil request
46   def test_soaplite_nil
47     body = SOAP::SOAPBody.new(REXML::Document.new(<<-__XML__))
48       <nop xsi:nil="true"/>
49     __XML__
50     @client.wiredump_dev = STDOUT if $DEBUG
51     header, body = @client.invoke(nil, body)
52     assert_equal(1, body.root_node["return"].data)
53   end
54 end
55
56
57 end
Note: See TracBrowser for help on using the browser.