From d464704f111d211c1f1ff9ef23ef1d755054be00 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 15 Aug 2007 19:08:43 +0000 Subject: add tag v1_8_5_54 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_54@12952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby_1_8_5/test/wsdl/document/test_number.rb | 99 ++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 ruby_1_8_5/test/wsdl/document/test_number.rb (limited to 'ruby_1_8_5/test/wsdl/document/test_number.rb') diff --git a/ruby_1_8_5/test/wsdl/document/test_number.rb b/ruby_1_8_5/test/wsdl/document/test_number.rb new file mode 100644 index 0000000000..a640ef2a25 --- /dev/null +++ b/ruby_1_8_5/test/wsdl/document/test_number.rb @@ -0,0 +1,99 @@ +require 'test/unit' +require 'wsdl/parser' +require 'wsdl/soap/wsdl2ruby' +require 'soap/rpc/standaloneServer' +require 'soap/wsdlDriver' + + +module WSDL; module Document + + +class TestNumber < Test::Unit::TestCase + class Server < ::SOAP::RPC::StandaloneServer + Namespace = 'urn:foo' + + def on_init + add_document_method( + self, + Namespace + ':get_foo', + 'get_foo', + XSD::QName.new(Namespace, 'get_foo'), + XSD::QName.new(Namespace, 'get_foo_response') + ) + end + + def get_foo(arg) + arg.number + end + end + + DIR = File.dirname(File.expand_path(__FILE__)) + Port = 17171 + + def setup + setup_server + setup_classdef + @client = nil + end + + def teardown + teardown_server + File.unlink(pathname('foo.rb')) + @client.reset_stream if @client + end + + def setup_server + @server = Server.new('Test', "urn:rpc", '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @server_thread = start_server_thread(@server) + end + + def setup_classdef + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("number.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['force'] = true + gen.run + require pathname('foo') + end + + def teardown_server + @server.shutdown + @server_thread.kill + @server_thread.join + end + + def start_server_thread(server) + t = Thread.new { + Thread.current.abort_on_exception = true + server.start + } + t + end + + def pathname(filename) + File.join(DIR, filename) + end + + def test_wsdl + wsdl = File.join(DIR, 'number.wsdl') + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver + @client.endpoint_url = "http://localhost:#{Port}/" + @client.wiredump_dev = STDOUT if $DEBUG + + # with the Struct defined in foo.rb, which is generated from WSDL + assert_equal("12345", @client.get_foo(Get_foo.new("12345"))) + + # with Hash + assert_equal("12345", @client.get_foo({:number => "12345"})) + + # with Original struct + get_foo_struct = Struct.new(:number) + assert_equal("12345", @client.get_foo(get_foo_struct.new("12345"))) + end +end + + +end; end -- cgit v1.2.3