| 1 |
require 'test/unit' |
|---|
| 2 |
require 'wsdl/parser' |
|---|
| 3 |
require 'wsdl/soap/wsdl2ruby' |
|---|
| 4 |
require 'soap/rpc/standaloneServer' |
|---|
| 5 |
require 'soap/wsdlDriver' |
|---|
| 6 |
require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', 'testutil.rb') |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
module WSDL; module ComplexContent |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
class TestEcho < Test::Unit::TestCase |
|---|
| 13 |
class Server < ::SOAP::RPC::StandaloneServer |
|---|
| 14 |
Namespace = 'urn:complexContent' |
|---|
| 15 |
|
|---|
| 16 |
def on_init |
|---|
| 17 |
add_document_method( |
|---|
| 18 |
self, |
|---|
| 19 |
nil, |
|---|
| 20 |
'echo', |
|---|
| 21 |
XSD::QName.new(Namespace, 'echo'), |
|---|
| 22 |
XSD::QName.new(Namespace, 'echo') |
|---|
| 23 |
) |
|---|
| 24 |
end |
|---|
| 25 |
|
|---|
| 26 |
def echo(arg) |
|---|
| 27 |
arg |
|---|
| 28 |
end |
|---|
| 29 |
end |
|---|
| 30 |
|
|---|
| 31 |
DIR = File.dirname(File.expand_path(__FILE__)) |
|---|
| 32 |
Port = 17171 |
|---|
| 33 |
|
|---|
| 34 |
def setup |
|---|
| 35 |
setup_server |
|---|
| 36 |
setup_classdef |
|---|
| 37 |
@client = nil |
|---|
| 38 |
end |
|---|
| 39 |
|
|---|
| 40 |
def teardown |
|---|
| 41 |
teardown_server if @server |
|---|
| 42 |
unless $DEBUG |
|---|
| 43 |
File.unlink(pathname('complexContent.rb')) |
|---|
| 44 |
File.unlink(pathname('complexContentMappingRegistry.rb')) |
|---|
| 45 |
end |
|---|
| 46 |
@client.reset_stream if @client |
|---|
| 47 |
end |
|---|
| 48 |
|
|---|
| 49 |
def setup_server |
|---|
| 50 |
@server = Server.new('Test', Server::Namespace, '0.0.0.0', Port) |
|---|
| 51 |
@server.level = Logger::Severity::ERROR |
|---|
| 52 |
@server_thread = TestUtil.start_server_thread(@server) |
|---|
| 53 |
end |
|---|
| 54 |
|
|---|
| 55 |
def setup_classdef |
|---|
| 56 |
gen = WSDL::SOAP::WSDL2Ruby.new |
|---|
| 57 |
gen.location = pathname("complexContent.wsdl") |
|---|
| 58 |
gen.basedir = DIR |
|---|
| 59 |
gen.logger.level = Logger::FATAL |
|---|
| 60 |
gen.opt['classdef'] = nil |
|---|
| 61 |
gen.opt['mapping_registry'] = nil |
|---|
| 62 |
gen.opt['force'] = true |
|---|
| 63 |
gen.run |
|---|
| 64 |
TestUtil.require(DIR, 'complexContentMappingRegistry.rb', 'complexContent.rb') |
|---|
| 65 |
end |
|---|
| 66 |
|
|---|
| 67 |
def teardown_server |
|---|
| 68 |
@server.shutdown |
|---|
| 69 |
@server_thread.kill |
|---|
| 70 |
@server_thread.join |
|---|
| 71 |
end |
|---|
| 72 |
|
|---|
| 73 |
def pathname(filename) |
|---|
| 74 |
File.join(DIR, filename) |
|---|
| 75 |
end |
|---|
| 76 |
|
|---|
| 77 |
def test_wsdl |
|---|
| 78 |
wsdl = File.join(DIR, 'complexContent.wsdl') |
|---|
| 79 |
@client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver |
|---|
| 80 |
@client.endpoint_url = "http://localhost:#{Port}/" |
|---|
| 81 |
@client.literal_mapping_registry = ComplexContentMappingRegistry::LiteralRegistry |
|---|
| 82 |
@client.wiredump_dev = STDOUT if $DEBUG |
|---|
| 83 |
d = Derived.new |
|---|
| 84 |
d.name = "NaHi" |
|---|
| 85 |
assert_instance_of(Echo, @client.echo(Echo.new(d))) |
|---|
| 86 |
end |
|---|
| 87 |
end |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
end; end |
|---|