| 1 |
require 'test/unit' |
|---|
| 2 |
require 'soap/rpc/standaloneServer' |
|---|
| 3 |
require 'soap/wsdlDriver' |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
module WSDL |
|---|
| 7 |
module SOAP |
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
class TestSOAPBodyParts < Test::Unit::TestCase |
|---|
| 11 |
class Server < ::SOAP::RPC::StandaloneServer |
|---|
| 12 |
def on_init |
|---|
| 13 |
add_method(self, 'foo', 'p1', 'p2', 'p3') |
|---|
| 14 |
add_method(self, 'bar', 'p1', 'p2', 'p3') |
|---|
| 15 |
add_method(self, 'baz', 'p1', 'p2', 'p3') |
|---|
| 16 |
end |
|---|
| 17 |
|
|---|
| 18 |
def foo(p1, p2, p3) |
|---|
| 19 |
[p1, p2, p3] |
|---|
| 20 |
end |
|---|
| 21 |
|
|---|
| 22 |
alias bar foo |
|---|
| 23 |
|
|---|
| 24 |
def baz(p1, p2, p3) |
|---|
| 25 |
[p3, p2, p1] |
|---|
| 26 |
end |
|---|
| 27 |
end |
|---|
| 28 |
|
|---|
| 29 |
DIR = File.dirname(File.expand_path(__FILE__)) |
|---|
| 30 |
|
|---|
| 31 |
Port = 17171 |
|---|
| 32 |
|
|---|
| 33 |
def setup |
|---|
| 34 |
setup_server |
|---|
| 35 |
setup_client |
|---|
| 36 |
end |
|---|
| 37 |
|
|---|
| 38 |
def setup_server |
|---|
| 39 |
@server = Server.new('Test', "urn:www.example.com:soapbodyparts:v1", '0.0.0.0', Port) |
|---|
| 40 |
@server.level = Logger::Severity::ERROR |
|---|
| 41 |
@t = Thread.new { |
|---|
| 42 |
Thread.current.abort_on_exception = true |
|---|
| 43 |
@server.start |
|---|
| 44 |
} |
|---|
| 45 |
end |
|---|
| 46 |
|
|---|
| 47 |
def setup_client |
|---|
| 48 |
wsdl = File.join(DIR, 'soapbodyparts.wsdl') |
|---|
| 49 |
@client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver |
|---|
| 50 |
@client.endpoint_url = "http://localhost:#{Port}/" |
|---|
| 51 |
@client.wiredump_dev = STDERR if $DEBUG |
|---|
| 52 |
end |
|---|
| 53 |
|
|---|
| 54 |
def teardown |
|---|
| 55 |
teardown_server if @server |
|---|
| 56 |
teardown_client if @client |
|---|
| 57 |
end |
|---|
| 58 |
|
|---|
| 59 |
def teardown_server |
|---|
| 60 |
@server.shutdown |
|---|
| 61 |
@t.kill |
|---|
| 62 |
@t.join |
|---|
| 63 |
end |
|---|
| 64 |
|
|---|
| 65 |
def teardown_client |
|---|
| 66 |
@client.reset_stream |
|---|
| 67 |
end |
|---|
| 68 |
|
|---|
| 69 |
def test_soapbodyparts |
|---|
| 70 |
assert_equal(["1", "2", "3"], @client.foo("1", "2", "3")) |
|---|
| 71 |
assert_equal(["3", "2", "1"], @client.foo("3", "2", "1")) |
|---|
| 72 |
assert_equal(["1", "2", "3"], @client.bar("1", "2", "3")) |
|---|
| 73 |
assert_equal(["3", "2", "1"], @client.baz("1", "2", "3")) |
|---|
| 74 |
end |
|---|
| 75 |
end |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
end |
|---|
| 79 |
end |
|---|