diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-29 04:06:12 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-29 04:06:12 +0000 |
commit | 11dbedfaad4a9a9521ece2198a8dc491678b1902 (patch) | |
tree | 4806dc0ff0c3827ecc40921838c4507340cfdb3a /ruby_1_8_6/test/wsdl/simpletype | |
parent | 29e8d8b439b34c2a394407dc598fc01d14be0c20 (diff) |
add tag v1_8_6_5001v1_8_6_5001
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_5001@13304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/test/wsdl/simpletype')
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/rpc/expectedClient.rb | 34 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/rpc/expectedDriver.rb | 62 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/rpc/expectedEchoVersion.rb | 23 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/rpc/expectedServant.rb | 32 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/rpc/expectedService.rb | 60 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/rpc/rpc.wsdl | 80 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/rpc/test_rpc.rb | 62 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/simpletype.wsdl | 95 | ||||
-rw-r--r-- | ruby_1_8_6/test/wsdl/simpletype/test_simpletype.rb | 99 |
9 files changed, 547 insertions, 0 deletions
diff --git a/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedClient.rb b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedClient.rb new file mode 100644 index 0000000000..55eb58c3dd --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedClient.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +require 'echo_versionDriver.rb' + +endpoint_url = ARGV.shift +obj = Echo_version_port_type.new(endpoint_url) + +# run ruby with -d to see SOAP wiredumps. +obj.wiredump_dev = STDERR if $DEBUG + +# SYNOPSIS +# echo_version(version) +# +# ARGS +# version Version - {urn:example.com:simpletype-rpc-type}version +# +# RETURNS +# version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct +# +version = nil +puts obj.echo_version(version) + +# SYNOPSIS +# echo_version_r(version_struct) +# +# ARGS +# version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct +# +# RETURNS +# version Version - {urn:example.com:simpletype-rpc-type}version +# +version_struct = nil +puts obj.echo_version_r(version_struct) + + diff --git a/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedDriver.rb b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedDriver.rb new file mode 100644 index 0000000000..81c72d1acf --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedDriver.rb @@ -0,0 +1,62 @@ +require 'echo_version.rb' + +require 'soap/rpc/driver' + +class Echo_version_port_type < ::SOAP::RPC::Driver + DefaultEndpointUrl = "http://localhost:10080" + MappingRegistry = ::SOAP::Mapping::Registry.new + + MappingRegistry.set( + Version_struct, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("urn:example.com:simpletype-rpc-type", "version_struct") } + ) + + Methods = [ + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version"), + "urn:example.com:simpletype-rpc", + "echo_version", + [ ["in", "version", ["::SOAP::SOAPString"]], + ["retval", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ], + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version_r"), + "urn:example.com:simpletype-rpc", + "echo_version_r", + [ ["in", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]], + ["retval", "version", ["::SOAP::SOAPString"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ] + ] + + def initialize(endpoint_url = nil) + endpoint_url ||= DefaultEndpointUrl + super(endpoint_url, nil) + self.mapping_registry = MappingRegistry + init_methods + end + +private + + def init_methods + Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + add_document_operation(*definitions) + else + add_rpc_operation(*definitions) + qname = definitions[0] + name = definitions[2] + if qname.name != name and qname.name.capitalize == name.capitalize + ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg| + __send__(name, *arg) + end + end + end + end + end +end + diff --git a/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedEchoVersion.rb b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedEchoVersion.rb new file mode 100644 index 0000000000..806ece1626 --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedEchoVersion.rb @@ -0,0 +1,23 @@ +require 'xsd/qname' + +# {urn:example.com:simpletype-rpc-type}version_struct +class Version_struct + @@schema_type = "version_struct" + @@schema_ns = "urn:example.com:simpletype-rpc-type" + @@schema_element = [["version", ["SOAP::SOAPString", XSD::QName.new(nil, "version")]], ["msg", ["SOAP::SOAPString", XSD::QName.new(nil, "msg")]]] + + attr_accessor :version + attr_accessor :msg + + def initialize(version = nil, msg = nil) + @version = version + @msg = msg + end +end + +# {urn:example.com:simpletype-rpc-type}version +module Version + C_16 = "1.6" + C_18 = "1.8" + C_19 = "1.9" +end diff --git a/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedServant.rb b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedServant.rb new file mode 100644 index 0000000000..81cf50218e --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedServant.rb @@ -0,0 +1,32 @@ +require 'echo_version.rb' + +class Echo_version_port_type + # SYNOPSIS + # echo_version(version) + # + # ARGS + # version Version - {urn:example.com:simpletype-rpc-type}version + # + # RETURNS + # version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct + # + def echo_version(version) + p [version] + raise NotImplementedError.new + end + + # SYNOPSIS + # echo_version_r(version_struct) + # + # ARGS + # version_struct Version_struct - {urn:example.com:simpletype-rpc-type}version_struct + # + # RETURNS + # version Version - {urn:example.com:simpletype-rpc-type}version + # + def echo_version_r(version_struct) + p [version_struct] + raise NotImplementedError.new + end +end + diff --git a/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedService.rb b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedService.rb new file mode 100644 index 0000000000..be6f996562 --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/rpc/expectedService.rb @@ -0,0 +1,60 @@ +#!/usr/bin/env ruby +require 'echo_versionServant.rb' + +require 'soap/rpc/standaloneServer' +require 'soap/mapping/registry' + +class Echo_version_port_type + MappingRegistry = ::SOAP::Mapping::Registry.new + + MappingRegistry.set( + Version_struct, + ::SOAP::SOAPStruct, + ::SOAP::Mapping::Registry::TypedStructFactory, + { :type => XSD::QName.new("urn:example.com:simpletype-rpc-type", "version_struct") } + ) + + Methods = [ + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version"), + "urn:example.com:simpletype-rpc", + "echo_version", + [ ["in", "version", ["::SOAP::SOAPString"]], + ["retval", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ], + [ XSD::QName.new("urn:example.com:simpletype-rpc", "echo_version_r"), + "urn:example.com:simpletype-rpc", + "echo_version_r", + [ ["in", "version_struct", ["Version_struct", "urn:example.com:simpletype-rpc-type", "version_struct"]], + ["retval", "version", ["::SOAP::SOAPString"]] ], + { :request_style => :rpc, :request_use => :encoded, + :response_style => :rpc, :response_use => :encoded } + ] + ] +end + +class Echo_version_port_typeApp < ::SOAP::RPC::StandaloneServer + def initialize(*arg) + super(*arg) + servant = Echo_version_port_type.new + Echo_version_port_type::Methods.each do |definitions| + opt = definitions.last + if opt[:request_style] == :document + @router.add_document_operation(servant, *definitions) + else + @router.add_rpc_operation(servant, *definitions) + end + end + self.mapping_registry = Echo_version_port_type::MappingRegistry + end +end + +if $0 == __FILE__ + # Change listen port. + server = Echo_version_port_typeApp.new('app', nil, '0.0.0.0', 10080) + trap(:INT) do + server.shutdown + end + server.start +end diff --git a/ruby_1_8_6/test/wsdl/simpletype/rpc/rpc.wsdl b/ruby_1_8_6/test/wsdl/simpletype/rpc/rpc.wsdl new file mode 100644 index 0000000000..91f71a8831 --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/rpc/rpc.wsdl @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<definitions name="echo_version" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="urn:example.com:simpletype-rpc" + xmlns:txd="urn:example.com:simpletype-rpc-type" + targetNamespace="urn:example.com:simpletype-rpc" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + <types> + <xsd:schema targetNamespace="urn:example.com:simpletype-rpc-type"> + <xsd:complexType name="version_struct"> + <xsd:all> + <xsd:element name="version" type="txd:version" /> + <xsd:element name="msg" type="xsd:string" /> + </xsd:all> + </xsd:complexType> + + <xsd:simpleType name="version"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="1.6"/> + <xsd:enumeration value="1.8"/> + <xsd:enumeration value="1.9"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:schema> + </types> + + <message name="msg_version"> + <part name="version" type="txd:version"/> + </message> + + <message name="msg_version_struct"> + <part name="version_struct" type="txd:version_struct"/> + </message> + + <portType name="echo_version_port_type"> + <operation name="echo_version"> + <input message="tns:msg_version"/> + <output message="tns:msg_version_struct"/> + </operation> + + <operation name="echo_version_r"> + <input message="tns:msg_version_struct"/> + <output message="tns:msg_version"/> + </operation> + </portType> + + <binding name="echo_version_binding" type="tns:echo_version_port_type"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> + <operation name="echo_version"> + <soap:operation soapAction="urn:example.com:simpletype-rpc"/> + <input> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </input> + <output> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </output> + </operation> + + <operation name="echo_version_r"> + <soap:operation soapAction="urn:example.com:simpletype-rpc"/> + <input> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </input> + <output> + <soap:body use="encoded" namespace="urn:example.com:simpletype-rpc" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> + </output> + </operation> + </binding> + + <service name="echo_version_service"> + <port name="echo_version_port" binding="tns:echo_version_binding"> + <soap:address location="http://localhost:10080"/> + </port> + </service> +</definitions> diff --git a/ruby_1_8_6/test/wsdl/simpletype/rpc/test_rpc.rb b/ruby_1_8_6/test/wsdl/simpletype/rpc/test_rpc.rb new file mode 100644 index 0000000000..fdd55552d0 --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/rpc/test_rpc.rb @@ -0,0 +1,62 @@ +require 'test/unit' +require 'wsdl/parser' +require 'wsdl/soap/wsdl2ruby' + + +module WSDL; module SimpleType + + +class TestRPC < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + def pathname(filename) + File.join(DIR, filename) + end + + def test_rpc + gen = WSDL::SOAP::WSDL2Ruby.new + gen.location = pathname("rpc.wsdl") + gen.basedir = DIR + gen.logger.level = Logger::FATAL + gen.opt['classdef'] = nil + gen.opt['driver'] = nil + gen.opt['client_skelton'] = nil + gen.opt['servant_skelton'] = nil + gen.opt['standalone_server_stub'] = nil + gen.opt['force'] = true + suppress_warning do + gen.run + end + compare("expectedEchoVersion.rb", "echo_version.rb") + compare("expectedDriver.rb", "echo_versionDriver.rb") + compare("expectedService.rb", "echo_version_service.rb") + compare("expectedClient.rb", "echo_version_serviceClient.rb") + compare("expectedServant.rb", "echo_versionServant.rb") + + File.unlink(pathname("echo_version.rb")) + File.unlink(pathname("echo_versionDriver.rb")) + File.unlink(pathname("echo_version_service.rb")) + File.unlink(pathname("echo_version_serviceClient.rb")) + File.unlink(pathname("echo_versionServant.rb")) + end + + def compare(expected, actual) + assert_equal(loadfile(expected), loadfile(actual), actual) + end + + def loadfile(file) + File.open(pathname(file)) { |f| f.read } + end + + def suppress_warning + back = $VERBOSE + $VERBOSE = nil + begin + yield + ensure + $VERBOSE = back + end + end +end + + +end; end diff --git a/ruby_1_8_6/test/wsdl/simpletype/simpletype.wsdl b/ruby_1_8_6/test/wsdl/simpletype/simpletype.wsdl new file mode 100644 index 0000000000..623969c794 --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/simpletype.wsdl @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="utf-8"?> +<definitions name="ping_service" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="urn:example.com:simpletype" + targetNamespace="urn:example.com:simpletype" + xmlns="http://schemas.xmlsoap.org/wsdl/"> + <types> + <xsd:schema targetNamespace="urn:example.com:simpletype"> + <xsd:element name="ruby"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="1" maxOccurs="1" name="myversion" type="tns:myversion"/> + <xsd:element minOccurs="0" maxOccurs="1" name="date" type="xsd:dateTime"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:simpleType name="myversion"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="1.6"/> + <xsd:enumeration value="1.8"/> + <xsd:enumeration value="1.9"/> + </xsd:restriction> + </xsd:simpleType> + + <xsd:element name="myid" type="tns:ID"/> + + <xsd:simpleType name="ID"> + <xsd:restriction base="xsd:string"> + <xsd:length value="18"/> + <xsd:pattern value='[a-zA-Z0-9]{18}'/> + </xsd:restriction> + </xsd:simpleType> + </xsd:schema> + </types> + + <message name="ping_in"> + <part name="parameters" element="tns:ruby"/> + </message> + + <message name="ping_out"> + <part name="parameters" type="xsd:string"/> + </message> + + <message name="ping_id_in"> + <part name="parameters" element="tns:myid"/> + </message> + + <message name="ping_id_out"> + <part name="parameters" element="tns:myid"/> + </message> + + <message name="versionmsg"> + <part name="myversion" element="tns:myversion"/> + </message> + + <portType name="ping_port_type"> + <operation name="ping"> + <input message="tns:ping_in"/> + <output message="tns:ping_out"/> + </operation> + + <operation name="ping_id"> + <input message="tns:ping_id_in"/> + <output message="tns:ping_id_out"/> + </operation> + + <operation name="echo_version"> + <input message="tns:versionmsg"/> + <output message="tns:versionmsg"/> + </operation> + </portType> + + <binding name="ping_binding" type="tns:ping_port_type"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> + <operation name="ping"> + <soap:operation soapAction="urn:example.com:simpletype:ping" style="document"/> + <input><soap:body use="literal"/></input> + <output><soap:body use="literal"/></output> + </operation> + + <operation name="ping_id"> + <soap:operation soapAction="urn:example.com:simpletype:ping_id" style="document"/> + <input><soap:body use="literal"/></input> + <output><soap:body use="literal"/></output> + </operation> + </binding> + + <service name="ping_service"> + <port name="ping_port" binding="tns:ping_binding"> + <soap:address location="http://localhost:10080"/> + </port> + </service> +</definitions> diff --git a/ruby_1_8_6/test/wsdl/simpletype/test_simpletype.rb b/ruby_1_8_6/test/wsdl/simpletype/test_simpletype.rb new file mode 100644 index 0000000000..7e644c3042 --- /dev/null +++ b/ruby_1_8_6/test/wsdl/simpletype/test_simpletype.rb @@ -0,0 +1,99 @@ +require 'test/unit' +require 'soap/rpc/standaloneServer' +require 'soap/wsdlDriver' + + +module WSDL +module SimpleType + + +class TestSimpleType < Test::Unit::TestCase + class Server < ::SOAP::RPC::StandaloneServer + def on_init + add_document_method(self, 'urn:example.com:simpletype:ping', 'ping', + XSD::QName.new('urn:example.com:simpletype', 'ruby'), + XSD::QName.new('http://www.w3.org/2001/XMLSchema', 'string')) + add_document_method(self, 'urn:example.com:simpletype:ping_id', 'ping_id', + XSD::QName.new('urn:example.com:simpletype', 'myid'), + XSD::QName.new('urn:example.com:simpletype', 'myid')) + end + + def ping(ruby) + version = ruby["myversion"] + date = ruby["date"] + "#{version} (#{date})" + end + + def ping_id(id) + id + end + end + + DIR = File.dirname(File.expand_path(__FILE__)) + + Port = 17171 + + def setup + setup_server + setup_client + end + + def setup_server + @server = Server.new('Test', "urn:example.com:simpletype", '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @server_thread = start_server_thread(@server) + end + + def setup_client + wsdl = File.join(DIR, 'simpletype.wsdl') + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver + @client.endpoint_url = "http://localhost:#{Port}/" + @client.generate_explicit_type = false + @client.wiredump_dev = STDOUT if $DEBUG + end + + def teardown + teardown_server + teardown_client + end + + def teardown_server + @server.shutdown + @server_thread.kill + @server_thread.join + end + + def teardown_client + @client.reset_stream + end + + def start_server_thread(server) + t = Thread.new { + Thread.current.abort_on_exception = true + server.start + } + t + end + + def test_ping + ret = @client.ping({:myversion => "1.9", :date => "2004-01-01T00:00:00Z"}) + assert_equal("1.9 (2004-01-01T00:00:00Z)", ret) + end + + def test_ping_id + ret = @client.ping_id("012345678901234567") + assert_equal("012345678901234567", ret) + # length + assert_raise(XSD::ValueSpaceError) do + @client.ping_id("0123456789012345678") + end + # pattern + assert_raise(XSD::ValueSpaceError) do + @client.ping_id("01234567890123456;") + end + end +end + + +end +end |