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

root/trunk/test/wsdl/document/test_nosoapaction.rb

Revision 1963, 2.5 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 'wsdl/parser'
3 require 'wsdl/soap/wsdl2ruby'
4 require 'soap/rpc/standaloneServer'
5 require 'soap/wsdlDriver'
6 require 'soap/rpc/driver'
7 require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'testutil.rb')
8
9
10 module WSDL; module Document
11
12
13 class TestNoSOAPAction < Test::Unit::TestCase
14   class Server < ::SOAP::RPC::StandaloneServer
15     Namespace = 'http://xmlsoap.org/Ping'
16
17     def on_init
18       add_document_method(
19         self,
20         Namespace + '/ping',
21         'ping_with_soapaction',
22         XSD::QName.new(Namespace, 'Ping'),
23         XSD::QName.new(Namespace, 'PingResponse')
24       )
25
26       add_document_method(
27         self,
28         nil,
29         'ping',
30         XSD::QName.new(Namespace, 'Ping'),
31         XSD::QName.new(Namespace, 'PingResponse')
32       )
33
34       # When no SOAPAction given, latter method(ping) is called.
35     end
36  
37     def ping(arg)
38       arg.text = 'ping'
39       arg
40     end
41  
42     def ping_with_soapaction(arg)
43       arg.text = 'ping_with_soapaction'
44       arg
45     end
46   end
47
48   DIR = File.dirname(File.expand_path(__FILE__))
49
50   Port = 17171
51
52   def setup
53     setup_server
54     @client = nil
55   end
56
57   def teardown
58     teardown_server if @server
59     @client.reset_stream if @client
60   end
61
62   def setup_server
63     @server = Server.new('Test', Server::Namespace, '0.0.0.0', Port)
64     @server.level = Logger::Severity::ERROR
65     @server_thread = TestUtil.start_server_thread(@server)
66   end
67
68   def teardown_server
69     @server.shutdown
70     @server_thread.kill
71     @server_thread.join
72   end
73
74   def test_with_soapaction
75     wsdl = File.join(DIR, 'ping_nosoapaction.wsdl')
76     @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
77     @client.endpoint_url = "http://localhost:#{Port}/"
78     @client.wiredump_dev = STDOUT if $DEBUG
79     rv = @client.ping(:scenario => 'scenario', :origin => 'origin',
80       :text => 'text')
81     assert_equal('scenario', rv.scenario)
82     assert_equal('origin', rv.origin)
83     assert_equal('ping', rv.text)
84   end
85
86   def test_without_soapaction
87     @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/",
88       Server::Namespace)
89     @client.add_document_method('ping', Server::Namespace + '/ping',
90       XSD::QName.new(Server::Namespace, 'Ping'),
91       XSD::QName.new(Server::Namespace, 'PingResponse'))
92     @client.wiredump_dev = STDOUT if $DEBUG
93     rv = @client.ping(:scenario => 'scenario', :origin => 'origin',
94       :text => 'text')
95     assert_equal('scenario', rv.scenario)
96     assert_equal('origin', rv.origin)
97     assert_equal('ping_with_soapaction', rv.text)
98   end
99 end
100
101
102 end; end
Note: See TracBrowser for help on using the browser.