diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-30 04:33:02 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-30 04:33:02 +0000 |
commit | d268bf305e926b5418d843098e35462cf97df662 (patch) | |
tree | 4268267cc8e52a533e4c78490ce6c2009971f972 | |
parent | 165d101eed53d09aa614d93557b077305a52006b (diff) |
* lib/soap/encodingstyle/soapHandler.rb: refactoring - Simplifying
Conditional Expressions.
* lib/wsdl/soap/definitions.rb: refactoring - Move Method.
* test/xsd/{test_noencoding.rb,noencoding.xml}: new files. test for
encoding unspecified XML file parsing.
* test/wsdl/{test_fault.rb,map,datetime}: new files. test of
SOAPFault, dateTime and Apache's Map.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | MANIFEST | 10 | ||||
-rw-r--r-- | lib/soap/encodingstyle/soapHandler.rb | 28 | ||||
-rw-r--r-- | lib/wsdl/soap/definitions.rb | 103 | ||||
-rw-r--r-- | test/wsdl/datetime/DatetimeService.rb | 38 | ||||
-rw-r--r-- | test/wsdl/datetime/datetime.rb | 0 | ||||
-rw-r--r-- | test/wsdl/datetime/datetime.wsdl | 45 | ||||
-rw-r--r-- | test/wsdl/datetime/datetimeServant.rb | 21 | ||||
-rw-r--r-- | test/wsdl/datetime/test_datetime.rb | 81 | ||||
-rw-r--r-- | test/wsdl/map/map.wsdl | 66 | ||||
-rw-r--r-- | test/wsdl/map/map.xml | 43 | ||||
-rw-r--r-- | test/wsdl/map/test_map.rb | 37 | ||||
-rw-r--r-- | test/wsdl/test_fault.rb | 51 | ||||
-rw-r--r-- | test/xsd/noencoding.xml | 4 | ||||
-rw-r--r-- | test/xsd/test_noencoding.rb | 21 |
15 files changed, 498 insertions, 63 deletions
@@ -1,3 +1,16 @@ +Sun Nov 30 13:02:00 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org> + + * lib/soap/encodingstyle/soapHandler.rb: refactoring - Simplifying + Conditional Expressions. + + * lib/wsdl/soap/definitions.rb: refactoring - Move Method. + + * test/xsd/{test_noencoding.rb,noencoding.xml}: new files. test for + encoding unspecified XML file parsing. + + * test/wsdl/{test_fault.rb,map,datetime}: new files. test of + SOAPFault, dateTime and Apache's Map. + Sun Nov 30 09:35:14 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> * string.c (rb_str_update): get rid of SEGV at just allocated String. @@ -729,7 +729,15 @@ test/uri/test_mailto.rb test/wsdl/axisArray/axisArray.wsdl test/wsdl/axisArray/itemList.rb test/wsdl/axisArray/test_axisarray.rb +test/wsdl/datetime/DatetimeService.rb +test/wsdl/datetime/datetime.rb +test/wsdl/datetime/datetime.wsdl +test/wsdl/datetime/datetimeServant.rb +test/wsdl/datetime/test_datetime.rb test/wsdl/emptycomplextype.wsdl +test/wsdl/map/map.wsdl +test/wsdl/map/map.xml +test/wsdl/map/test_map.rb test/wsdl/raa/RAA.rb test/wsdl/raa/README.txt test/wsdl/raa/RAAServant.rb @@ -737,6 +745,8 @@ test/wsdl/raa/RAAService.rb test/wsdl/raa/raa.wsdl test/wsdl/raa/test_raa.rb test/wsdl/test_emptycomplextype.rb +test/xsd/noencoding.xml +test/xsd/test_noencoding.rb test/xsd/test_xmlschemaparser.rb test/xsd/test_xsd.rb test/xsd/xmlschema.xml diff --git a/lib/soap/encodingstyle/soapHandler.rb b/lib/soap/encodingstyle/soapHandler.rb index 1f359bef4e..9aa732535e 100644 --- a/lib/soap/encodingstyle/soapHandler.rb +++ b/lib/soap/encodingstyle/soapHandler.rb @@ -331,30 +331,30 @@ private def decode_tag_by_wsdl(ns, elename, typestr, parent, arytypestr, extraattr) o = nil - # should branch by root attribute? if parent.class == SOAPBody + # root element: should branch by root attribute? if @is_first_top_ele # Unqualified name is allowed here. @is_first_top_ele = false type = @decode_typemap[elename] || @decode_typemap.find_name(elename.name) - unless type - raise EncodingStyleError.new("Unknown operation '#{ elename }'.") + if type + o = SOAPStruct.new(elename) + o.definedtype = type + return o end - o = SOAPStruct.new(elename) - o.definedtype = type - return o - elsif !typestr - # typeless multi-ref element. - return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, - extraattr) - else - # typed multi-ref element. + end + # multi-ref element. + if typestr typename = ns.parse(typestr) typedef = @decode_typemap[typename] - return decode_defined_compoundtype(elename, typename, typedef, - arytypestr) + if typedef + return decode_defined_compoundtype(elename, typename, typedef, + arytypestr) + end end + return decode_tag_by_type(ns, elename, typestr, parent, arytypestr, + extraattr) end if parent.type == XSD::AnyTypeName diff --git a/lib/wsdl/soap/definitions.rb b/lib/wsdl/soap/definitions.rb index 1a152ee693..7a62242204 100644 --- a/lib/wsdl/soap/definitions.rb +++ b/lib/wsdl/soap/definitions.rb @@ -15,59 +15,15 @@ module WSDL class Definitions < Info - def soap_rpc_complextypes(binding) - types = rpc_operation_complextypes(binding) + def self.soap_rpc_complextypes + types = XSD::NamedElements.new types << array_complextype types << fault_complextype types << exception_complextype types end -private - - def rpc_operation_complextypes(binding) - types = XSD::NamedElements.new - binding.operations.each do |op_bind| - if op_bind_rpc?(op_bind) - operation = op_bind.find_operation - if op_bind.input - type = XMLSchema::ComplexType.new(operation_input_name(operation)) - message = messages[operation.input.message] - type.sequence_elements = elements_from_message(message) - types << type - end - if op_bind.output - type = XMLSchema::ComplexType.new(operation_output_name(operation)) - message = messages[operation.output.message] - type.sequence_elements = elements_from_message(message) - types << type - end - end - end - types - end - - def operation_input_name(operation) - operation.input.name || operation.name - end - - def operation_output_name(operation) - operation.output.name || - XSD::QName.new(operation.name.namespace, operation.name.name + "Response") - end - - def op_bind_rpc?(op_bind) - op_bind.soapoperation and op_bind.soapoperation.operation_style == :rpc - end - - def elements_from_message(message) - message.parts.collect { |part| - qname = XSD::QName.new(nil, part.name) - XMLSchema::Element.new(qname, part.type) - } - end - - def array_complextype + def self.array_complextype type = XMLSchema::ComplexType.new(::SOAP::ValueArrayName) type.complexcontent = XMLSchema::ComplexContent.new type.complexcontent.base = ::SOAP::ValueArrayName @@ -90,7 +46,7 @@ private </xs:sequence> </xs:complexType> =end - def fault_complextype + def self.fault_complextype type = XMLSchema::ComplexType.new(::SOAP::EleFaultName) faultcode = XMLSchema::Element.new(::SOAP::EleFaultCodeName, XSD::XSDQName::Type) faultstring = XMLSchema::Element.new(::SOAP::EleFaultStringName, XSD::XSDString::Type) @@ -103,7 +59,7 @@ private type end - def exception_complextype + def self.exception_complextype type = XMLSchema::ComplexType.new(XSD::QName.new( ::SOAP::Mapping::RubyCustomTypeNamespace, 'SOAPException')) excn_name = XMLSchema::Element.new(XSD::QName.new(nil, 'excn_type_name'), XSD::XSDString::Type) @@ -113,6 +69,55 @@ private type.all_elements = [excn_name, cause, backtrace, message] type end + + def soap_rpc_complextypes(binding) + types = rpc_operation_complextypes(binding) + types + self.class.soap_rpc_complextypes + end + +private + + def rpc_operation_complextypes(binding) + types = XSD::NamedElements.new + binding.operations.each do |op_bind| + if op_bind_rpc?(op_bind) + operation = op_bind.find_operation + if op_bind.input + type = XMLSchema::ComplexType.new(operation_input_name(operation)) + message = messages[operation.input.message] + type.sequence_elements = elements_from_message(message) + types << type + end + if op_bind.output + type = XMLSchema::ComplexType.new(operation_output_name(operation)) + message = messages[operation.output.message] + type.sequence_elements = elements_from_message(message) + types << type + end + end + end + types + end + + def operation_input_name(operation) + operation.input.name || operation.name + end + + def operation_output_name(operation) + operation.output.name || + XSD::QName.new(operation.name.namespace, operation.name.name + "Response") + end + + def op_bind_rpc?(op_bind) + op_bind.soapoperation and op_bind.soapoperation.operation_style == :rpc + end + + def elements_from_message(message) + message.parts.collect { |part| + qname = XSD::QName.new(nil, part.name) + XMLSchema::Element.new(qname, part.type) + } + end end diff --git a/test/wsdl/datetime/DatetimeService.rb b/test/wsdl/datetime/DatetimeService.rb new file mode 100644 index 0000000000..91c006005d --- /dev/null +++ b/test/wsdl/datetime/DatetimeService.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +require 'datetimeServant.rb' + +require 'soap/rpc/standaloneServer' + +class DatetimePortType + MappingRegistry = SOAP::Mapping::Registry.new + + # No mapping definition + + Methods = [ + ["now", "now", [ + ["in", "now", + [SOAP::SOAPDateTime]], + ["retval", "now", + [SOAP::SOAPDateTime]]], "", "urn:jp.gr.jin.rrr.example.datetime"] + ] +end + +class DatetimePortTypeApp < SOAP::RPC::StandaloneServer + def initialize(*arg) + super + + servant = DatetimePortType.new + DatetimePortType::Methods.each do |name_as, name, params, soapaction, namespace| + qname = XSD::QName.new(namespace, name_as) + @soaplet.app_scope_router.add_method(servant, qname, soapaction, + name, params) + end + + self.mapping_registry = DatetimePortType::MappingRegistry + end +end + +# Change listen port. +if $0 == __FILE__ + DatetimePortTypeApp.new('app', nil, '0.0.0.0', 10080).start +end diff --git a/test/wsdl/datetime/datetime.rb b/test/wsdl/datetime/datetime.rb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/wsdl/datetime/datetime.rb diff --git a/test/wsdl/datetime/datetime.wsdl b/test/wsdl/datetime/datetime.wsdl new file mode 100644 index 0000000000..4998dc48d6 --- /dev/null +++ b/test/wsdl/datetime/datetime.wsdl @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<wsdl:definitions name = "datetime" + targetNamespace="urn:jp.gr.jin.rrr.example.datetime" + xmlns:tns="urn:jp.gr.jin.rrr.example.datetime" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <wsdl:message name="nowRequest"> + <wsdl:part name="now" type="xsd:dateTime"/> + </wsdl:message> + + <wsdl:message name="nowResponse"> + <wsdl:part name="now" type="xsd:dateTime"/> + </wsdl:message> + + <wsdl:portType name="DatetimePortType"> + <wsdl:operation name="now"> + <wsdl:input message="tns:nowRequest" name="nowRequest"/> + <wsdl:output message="tns:nowResponse" name="nowResponse"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="DatetimeBinding" type="tns:DatetimePortType"> + <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="now"> + <soap:operation soapAction=""/> + <wsdl:input name="nowRequest"> + <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" + namespace="urn:jp.gr.jin.rrr.example.datetime" use="encoded"/> + </wsdl:input> + <wsdl:output name="nowResponse"> + <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" + namespace="urn:jp.gr.jin.rrr.example.datetime" use="encoded"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="DatetimeService"> + <wsdl:port binding="tns:DatetimeBinding" name="DatetimePort"> + <soap:address location="http://localhost:10080/"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> diff --git a/test/wsdl/datetime/datetimeServant.rb b/test/wsdl/datetime/datetimeServant.rb new file mode 100644 index 0000000000..14145c42e5 --- /dev/null +++ b/test/wsdl/datetime/datetimeServant.rb @@ -0,0 +1,21 @@ +require 'datetime.rb' + +class DatetimePortType + # SYNOPSIS + # now(now) + # + # ARGS + # now - {http://www.w3.org/2001/XMLSchema}dateTime + # + # RETURNS + # now - {http://www.w3.org/2001/XMLSchema}dateTime + # + # RAISES + # (undefined) + # + def now(now) + #raise NotImplementedError.new + now + 1 + end +end + diff --git a/test/wsdl/datetime/test_datetime.rb b/test/wsdl/datetime/test_datetime.rb new file mode 100644 index 0000000000..a60d9b70a0 --- /dev/null +++ b/test/wsdl/datetime/test_datetime.rb @@ -0,0 +1,81 @@ +require 'test/unit' +require 'soap/wsdlDriver' + + +module WSDL +module Datetime + + +class TestDatetime < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + + Port = 17171 + + def setup + setup_server + setup_client + end + + def setup_server + $:.push(DIR) + require File.join(DIR, 'DatetimeService.rb') + $:.delete(DIR) + @server = DatetimePortTypeApp.new('Datetime server', nil, '0.0.0.0', Port) + @server.level = Logger::Severity::ERROR + @t = Thread.new { + Thread.current.abort_on_exception = true + @server.start + } + while @server.server.nil? or @server.server.status != :Running + sleep 0.1 + unless @t.alive? + @t.join + raise + end + end + end + + def setup_client + wsdl = File.join(DIR, 'datetime.wsdl') + @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_driver + @client.endpoint_url = "http://localhost:#{Port}/" + @client.generate_explicit_type = true + end + + def teardown + teardown_server + teardown_client + end + + def teardown_server + @server.server.shutdown + @t.kill + @t.join + end + + def teardown_client + @client.reset_stream + end + + def test_datetime + d = DateTime.now + assert_equal(d + 1, @client.now(d)) + end + + def test_time + d = DateTime.now + t = Time.gm(d.year, d.month, d.day, d.hour, d.min, d.sec) + d2 = d + 1 + t2 = @client.now(t) + assert_equal(d2.year, t2.year) + assert_equal(d2.month, t2.month) + assert_equal(d2.day, t2.day) + assert_equal(d2.hour, t2.hour) + assert_equal(d2.min, t2.min) + assert_equal(d2.sec, t2.sec) + end +end + + +end +end diff --git a/test/wsdl/map/map.wsdl b/test/wsdl/map/map.wsdl new file mode 100644 index 0000000000..7b1a140827 --- /dev/null +++ b/test/wsdl/map/map.wsdl @@ -0,0 +1,66 @@ +<?xml version="1.0"?> +<definitions + name="RAA" + targetNamespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" + xmlns:tns="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" + xmlns:txd="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:apachesoap="http://xml.apache.org/xml-soap"> + + <types> + <schema + xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://xml.apache.org/xml-soap"> + <complexType name="Map"> + <sequence> + <element name="item" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="key" type="anyType" /> + <element name="value" type="anyType" /> + </sequence> + </complexType> + </element> + </sequence> + </complexType> + </schema> + </types> + + <message name="mapRequest"/> + <message name="mapResponse"> + <part name="return" type="apachesoap:Map"/> + </message> + + <portType name="RAABaseServicePortType"> + <operation name="map" parameterOrder=""> + <input message="tns:mapRequest"/> + <output message="tns:mapResponse"/> + </operation> + </portType> + + <binding name="RAABaseServicePortBinding" type="tns:RAABaseServicePortType"> + <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + <operation name="map"> + <soap:operation soapAction=""/> + <input> + <soap:body use="encoded" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" + namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/> + </input> + <output> + <soap:body use="encoded" + encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" + namespace="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/"/> + </output> + </operation> + </binding> + + <service name="RAAService"> + <port name="RAABaseServicePort" binding="tns:RAABaseServicePortBinding"> + <soap:address location="http://raa.ruby-lang.org/soap/1.0.2/"/> + </port> + </service> +</definitions> diff --git a/test/wsdl/map/map.xml b/test/wsdl/map/map.xml new file mode 100644 index 0000000000..7106735ffc --- /dev/null +++ b/test/wsdl/map/map.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <n2:mapResponse xmlns:n1="http://schemas.xmlsoap.org/soap/encoding/" xmlns:n2="http://www.ruby-lang.org/xmlns/soap/interface/RAA/0.0.2/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> + <return xmlns:n3="http://xml.apache.org/xml-soap" xsi:type="n3:Map"> + <item> + <key xsi:type="xsd:string">a</key> + <value xsi:type="n3:Map"> + <item> + <key xsi:type="xsd:string">a1</key> + <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]"> + <item xsi:type="xsd:string">a1</item> + </value> + </item> + <item> + <key xsi:type="xsd:string">a2</key> + <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]"> + <item xsi:type="xsd:string">a2</item> + </value> + </item> + </value> + </item> + <item> + <key xsi:type="xsd:string">b</key> + <value xsi:type="n3:Map"> + <item> + <key xsi:type="xsd:string">b1</key> + <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]"> + <item xsi:type="xsd:string">b1</item> + </value> + </item> + <item> + <key xsi:type="xsd:string">b2</key> + <value xsi:type="n1:Array" n1:arrayType="xsd:anyType[1]"> + <item xsi:type="xsd:string">b2</item> + </value> + </item> + </value> + </item> + </return> + </n2:mapResponse> + </env:Body> +</env:Envelope> diff --git a/test/wsdl/map/test_map.rb b/test/wsdl/map/test_map.rb new file mode 100644 index 0000000000..b0f2fb5a53 --- /dev/null +++ b/test/wsdl/map/test_map.rb @@ -0,0 +1,37 @@ +require 'test/unit' +require 'soap/processor' +require 'soap/mapping' +require 'soap/rpc/element' +require 'wsdl/importer' + + +module WSDL + + +class TestMap < Test::Unit::TestCase + def setup + end + + def test_by_wsdl + dir = File.dirname(File.expand_path(__FILE__)) + wsdlfile = File.join(dir, 'map.wsdl') + xml = File.open(File.join(dir, 'map.xml')) { |f| f.read } + wsdl = WSDL::Importer.import(wsdlfile) + service = wsdl.services[0] + port = service.ports[0] + wsdl_types = wsdl.collect_complextypes + rpc_decode_typemap = wsdl_types + wsdl.soap_rpc_complextypes(port.find_binding) + opt = {} + opt[:default_encodingstyle] = ::SOAP::EncodingNamespace + opt[:decode_typemap] = rpc_decode_typemap + header, body = ::SOAP::Processor.unmarshal(xml, opt) + map = ::SOAP::Mapping.soap2obj(body.response) + assert_equal(["a1"], map["a"]["a1"]) + assert_equal(["a2"], map["a"]["a2"]) + assert_equal(["b1"], map["b"]["b1"]) + assert_equal(["b2"], map["b"]["b2"]) + end +end + + +end diff --git a/test/wsdl/test_fault.rb b/test/wsdl/test_fault.rb new file mode 100644 index 0000000000..ec414528ee --- /dev/null +++ b/test/wsdl/test_fault.rb @@ -0,0 +1,51 @@ +require 'test/unit' +require 'soap/processor' +require 'soap/mapping' +require 'soap/rpc/element' +require 'wsdl/parser' + + +module WSDL + + +class TestFault < Test::Unit::TestCase + def setup + @xml =<<__EOX__ +<?xml version="1.0" encoding="utf-8" ?> +<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <env:Body> + <env:Fault xmlns:n1="http://schemas.xmlsoap.org/soap/encoding/" + env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> + <faultcode xsi:type="xsd:string">Server</faultcode> + <faultstring xsi:type="xsd:string">faultstring</faultstring> + <faultactor xsi:type="xsd:string">faultactor</faultactor> + <detail xmlns:n2="http://www.ruby-lang.org/xmlns/ruby/type/custom" + xsi:type="n2:SOAPException"> + <excn_type_name xsi:type="xsd:string">type</excn_type_name> + <cause href="#id123"/> + </detail> + </env:Fault> + <cause id="id123" xsi:type="xsd:int">5</cause> + </env:Body> +</env:Envelope> +__EOX__ + end + + def test_by_wsdl + rpc_decode_typemap = WSDL::Definitions.soap_rpc_complextypes + opt = {} + opt[:default_encodingstyle] = ::SOAP::EncodingNamespace + opt[:decode_typemap] = rpc_decode_typemap + header, body = ::SOAP::Processor.unmarshal(@xml, opt) + fault = ::SOAP::Mapping.soap2obj(body.response) + assert_equal("Server", fault.faultcode) + assert_equal("faultstring", fault.faultstring) + assert_equal(URI.parse("faultactor"), fault.faultactor) + assert_equal(5, fault.detail.cause) + end +end + + +end diff --git a/test/xsd/noencoding.xml b/test/xsd/noencoding.xml new file mode 100644 index 0000000000..614ffa34ad --- /dev/null +++ b/test/xsd/noencoding.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="euc-jp"?> +<schema xmlns="http://www.w3.org/2001/XMLSchema"> + <!-- ¤¢¤¤¤¦ --> +</schema> diff --git a/test/xsd/test_noencoding.rb b/test/xsd/test_noencoding.rb new file mode 100644 index 0000000000..0f2daae05f --- /dev/null +++ b/test/xsd/test_noencoding.rb @@ -0,0 +1,21 @@ +require 'test/unit' +require 'wsdl/xmlSchema/parser' + + +module XSD + + +class TestEmptyCharset < Test::Unit::TestCase + def setup + @file = File.join(File.dirname(File.expand_path(__FILE__)), 'noencoding.xml') + end + + def test_wsdl + xml = WSDL::XMLSchema::Parser.new.parse(File.open(@file) { |f| f.read }) + assert_equal(WSDL::XMLSchema::Schema, xml.class) + assert_equal(0, xml.collect_elements.size) + end +end + + +end |