summaryrefslogtreecommitdiff
path: root/ruby_1_8_5/test/soap
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_5/test/soap')
-rw-r--r--ruby_1_8_5/test/soap/asp.net/hello.wsdl96
-rw-r--r--ruby_1_8_5/test/soap/asp.net/test_aspdotnet.rb111
-rw-r--r--ruby_1_8_5/test/soap/calc/calc.rb17
-rw-r--r--ruby_1_8_5/test/soap/calc/calc2.rb29
-rw-r--r--ruby_1_8_5/test/soap/calc/server.cgi13
-rw-r--r--ruby_1_8_5/test/soap/calc/server.rb17
-rw-r--r--ruby_1_8_5/test/soap/calc/server2.rb20
-rw-r--r--ruby_1_8_5/test/soap/calc/test_calc.rb49
-rw-r--r--ruby_1_8_5/test/soap/calc/test_calc2.rb53
-rw-r--r--ruby_1_8_5/test/soap/calc/test_calc_cgi.rb69
-rw-r--r--ruby_1_8_5/test/soap/fault/test_customfault.rb58
-rw-r--r--ruby_1_8_5/test/soap/header/server.cgi119
-rw-r--r--ruby_1_8_5/test/soap/header/test_authheader.rb240
-rw-r--r--ruby_1_8_5/test/soap/header/test_authheader_cgi.rb121
-rw-r--r--ruby_1_8_5/test/soap/header/test_simplehandler.rb116
-rw-r--r--ruby_1_8_5/test/soap/helloworld/hw_s.rb16
-rw-r--r--ruby_1_8_5/test/soap/helloworld/test_helloworld.rb40
-rw-r--r--ruby_1_8_5/test/soap/marshal/test_digraph.rb56
-rw-r--r--ruby_1_8_5/test/soap/marshal/test_marshal.rb26
-rw-r--r--ruby_1_8_5/test/soap/marshal/test_struct.rb47
-rw-r--r--ruby_1_8_5/test/soap/ssl/README1
-rw-r--r--ruby_1_8_5/test/soap/ssl/ca.cert23
-rw-r--r--ruby_1_8_5/test/soap/ssl/client.cert19
-rw-r--r--ruby_1_8_5/test/soap/ssl/client.key15
-rw-r--r--ruby_1_8_5/test/soap/ssl/server.cert19
-rw-r--r--ruby_1_8_5/test/soap/ssl/server.key15
-rw-r--r--ruby_1_8_5/test/soap/ssl/sslsvr.rb57
-rw-r--r--ruby_1_8_5/test/soap/ssl/subca.cert21
-rw-r--r--ruby_1_8_5/test/soap/ssl/test_ssl.rb204
-rw-r--r--ruby_1_8_5/test/soap/struct/test_struct.rb77
-rw-r--r--ruby_1_8_5/test/soap/swa/test_file.rb73
-rw-r--r--ruby_1_8_5/test/soap/test_basetype.rb970
-rw-r--r--ruby_1_8_5/test/soap/test_envelopenamespace.rb92
-rw-r--r--ruby_1_8_5/test/soap/test_httpconfigloader.rb39
-rw-r--r--ruby_1_8_5/test/soap/test_mapping.rb59
-rw-r--r--ruby_1_8_5/test/soap/test_no_indent.rb86
-rw-r--r--ruby_1_8_5/test/soap/test_property.rb424
-rw-r--r--ruby_1_8_5/test/soap/test_soapelement.rb122
-rw-r--r--ruby_1_8_5/test/soap/test_streamhandler.rb209
-rw-r--r--ruby_1_8_5/test/soap/test_styleuse.rb333
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/README.txt2
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/calc.wsdl126
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/document.wsdl54
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/echo_version.rb20
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/simpletype.wsdl63
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/test_calc.rb100
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/test_document.rb78
-rw-r--r--ruby_1_8_5/test/soap/wsdlDriver/test_simpletype.rb87
48 files changed, 4701 insertions, 0 deletions
diff --git a/ruby_1_8_5/test/soap/asp.net/hello.wsdl b/ruby_1_8_5/test/soap/asp.net/hello.wsdl
new file mode 100644
index 0000000000..b94129c152
--- /dev/null
+++ b/ruby_1_8_5/test/soap/asp.net/hello.wsdl
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<wsdl:definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+xmlns:s="http://www.w3.org/2001/XMLSchema"
+xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+xmlns:tns="http://localhost/WebService/"
+xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
+xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+targetNamespace="http://localhost/WebService/"
+xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:types>
+ <s:schema elementFormDefault="qualified"
+targetNamespace="http://localhost/WebService/">
+ <s:element name="HelloWorld">
+ <s:complexType />
+ </s:element>
+ <s:element name="HelloWorldResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1"
+name="HelloWorldResult" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="SayHello">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1" name="name"
+type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ <s:element name="SayHelloResponse">
+ <s:complexType>
+ <s:sequence>
+ <s:element minOccurs="0" maxOccurs="1"
+name="SayHelloResult" type="s:string" />
+ </s:sequence>
+ </s:complexType>
+ </s:element>
+ </s:schema>
+ </wsdl:types>
+ <wsdl:message name="HelloWorldSoapIn">
+ <wsdl:part name="parameters" element="tns:HelloWorld" />
+ </wsdl:message>
+ <wsdl:message name="HelloWorldSoapOut">
+ <wsdl:part name="parameters" element="tns:HelloWorldResponse" />
+ </wsdl:message>
+ <wsdl:message name="SayHelloSoapIn">
+ <wsdl:part name="parameters" element="tns:SayHello" />
+ </wsdl:message>
+ <wsdl:message name="SayHelloSoapOut">
+ <wsdl:part name="parameters" element="tns:SayHelloResponse" />
+ </wsdl:message>
+ <wsdl:portType name="Service1Soap">
+ <wsdl:operation name="HelloWorld">
+ <wsdl:input message="tns:HelloWorldSoapIn" />
+ <wsdl:output message="tns:HelloWorldSoapOut" />
+ </wsdl:operation>
+ <wsdl:operation name="SayHello">
+ <wsdl:input message="tns:SayHelloSoapIn" />
+ <wsdl:output message="tns:SayHelloSoapOut" />
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
+style="document" />
+ <wsdl:operation name="HelloWorld">
+ <soap:operation
+soapAction="http://localhost/WebService/HelloWorld" style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="SayHello">
+ <soap:operation soapAction="http://localhost/WebService/SayHello"
+style="document" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="Service1">
+ <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
+ <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
+ <soap:address
+location="http://localhost/WebService/Service1.asmx" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/ruby_1_8_5/test/soap/asp.net/test_aspdotnet.rb b/ruby_1_8_5/test/soap/asp.net/test_aspdotnet.rb
new file mode 100644
index 0000000000..7d5f3fd288
--- /dev/null
+++ b/ruby_1_8_5/test/soap/asp.net/test_aspdotnet.rb
@@ -0,0 +1,111 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/rpc/driver'
+
+
+module SOAP; module ASPDotNet
+
+
+class TestASPDotNet < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::StandaloneServer
+ Namespace = "http://localhost/WebService/"
+
+ def on_init
+ add_document_method(
+ self,
+ Namespace + 'SayHello',
+ 'sayHello',
+ XSD::QName.new(Namespace, 'SayHello'),
+ XSD::QName.new(Namespace, 'SayHelloResponse')
+ )
+ end
+
+ def sayHello(arg)
+ name = arg['name']
+ "Hello #{name}"
+ end
+ end
+
+ Port = 17171
+ Endpoint = "http://localhost:#{Port}/"
+
+ def setup
+ setup_server
+ @client = nil
+ end
+
+ def teardown
+ teardown_server
+ @client.reset_stream if @client
+ end
+
+ def setup_server
+ @server = Server.new('Test', Server::Namespace, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ 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 test_document_method
+ @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace)
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.add_document_method('sayHello', Server::Namespace + 'SayHello',
+ XSD::QName.new(Server::Namespace, 'SayHello'),
+ XSD::QName.new(Server::Namespace, 'SayHelloResponse'))
+ assert_equal("Hello Mike", @client.sayHello(:name => "Mike"))
+ end
+
+ def test_aspdotnethandler
+ @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace)
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.add_method_with_soapaction('sayHello', Server::Namespace + 'SayHello', 'name')
+ @client.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
+ assert_equal("Hello Mike", @client.sayHello("Mike"))
+ end
+
+ if defined?(HTTPAccess2)
+
+ # qualified!
+ REQUEST_ASPDOTNETHANDLER =
+%q[<?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>
+ <n1:sayHello xmlns:n1="http://localhost/WebService/">
+ <n1:name>Mike</n1:name>
+ </n1:sayHello>
+ </env:Body>
+</env:Envelope>]
+
+ def test_aspdotnethandler_envelope
+ @client = SOAP::RPC::Driver.new(Endpoint, Server::Namespace)
+ @client.wiredump_dev = str = ''
+ @client.add_method_with_soapaction('sayHello', Server::Namespace + 'SayHello', 'name')
+ @client.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
+ assert_equal("Hello Mike", @client.sayHello("Mike"))
+ assert_equal(REQUEST_ASPDOTNETHANDLER, parse_requestxml(str))
+ end
+
+ def parse_requestxml(str)
+ str.split(/\r?\n\r?\n/)[3]
+ end
+
+ end
+end
+
+
+end; end
diff --git a/ruby_1_8_5/test/soap/calc/calc.rb b/ruby_1_8_5/test/soap/calc/calc.rb
new file mode 100644
index 0000000000..6bc78803b3
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/calc.rb
@@ -0,0 +1,17 @@
+module CalcService
+ def self.add(lhs, rhs)
+ lhs + rhs
+ end
+
+ def self.sub(lhs, rhs)
+ lhs - rhs
+ end
+
+ def self.multi(lhs, rhs)
+ lhs * rhs
+ end
+
+ def self.div(lhs, rhs)
+ lhs / rhs
+ end
+end
diff --git a/ruby_1_8_5/test/soap/calc/calc2.rb b/ruby_1_8_5/test/soap/calc/calc2.rb
new file mode 100644
index 0000000000..69495730e7
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/calc2.rb
@@ -0,0 +1,29 @@
+class CalcService2
+ def initialize(value = 0)
+ @value = value
+ end
+
+ def set_value(value)
+ @value = value
+ end
+
+ def get_value
+ @value
+ end
+
+ def +(rhs)
+ @value + rhs
+ end
+
+ def -(rhs)
+ @value - rhs
+ end
+
+ def *(rhs)
+ @value * rhs
+ end
+
+ def /(rhs)
+ @value / rhs
+ end
+end
diff --git a/ruby_1_8_5/test/soap/calc/server.cgi b/ruby_1_8_5/test/soap/calc/server.cgi
new file mode 100644
index 0000000000..1eb0d1d864
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/server.cgi
@@ -0,0 +1,13 @@
+require 'soap/rpc/cgistub'
+
+class CalcServer < SOAP::RPC::CGIStub
+ def initialize(*arg)
+ super
+
+ require 'calc'
+ servant = CalcService
+ add_servant(servant, 'http://tempuri.org/calcService')
+ end
+end
+
+status = CalcServer.new('CalcServer', nil).start
diff --git a/ruby_1_8_5/test/soap/calc/server.rb b/ruby_1_8_5/test/soap/calc/server.rb
new file mode 100644
index 0000000000..a93774d909
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/server.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'calc'
+
+class CalcServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+
+ servant = CalcService
+ add_servant(servant, 'http://tempuri.org/calcService')
+ end
+end
+
+if $0 == __FILE__
+ status = CalcServer.new('CalcServer', nil, '0.0.0.0', 17171).start
+end
diff --git a/ruby_1_8_5/test/soap/calc/server2.rb b/ruby_1_8_5/test/soap/calc/server2.rb
new file mode 100644
index 0000000000..01c6d75289
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/server2.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+
+require 'soap/rpc/standaloneServer'
+require 'calc2'
+
+class CalcServer2 < SOAP::RPC::StandaloneServer
+ def on_init
+ servant = CalcService2.new
+ add_method(servant, 'set_value', 'newValue')
+ add_method(servant, 'get_value')
+ add_method_as(servant, '+', 'add', 'lhs')
+ add_method_as(servant, '-', 'sub', 'lhs')
+ add_method_as(servant, '*', 'multi', 'lhs')
+ add_method_as(servant, '/', 'div', 'lhs')
+ end
+end
+
+if $0 == __FILE__
+ status = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', 17171).start
+end
diff --git a/ruby_1_8_5/test/soap/calc/test_calc.rb b/ruby_1_8_5/test/soap/calc/test_calc.rb
new file mode 100644
index 0000000000..88738716a6
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/test_calc.rb
@@ -0,0 +1,49 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'server.rb'
+
+
+module SOAP
+module Calc
+
+
+class TestCalc < Test::Unit::TestCase
+ Port = 17171
+
+ def setup
+ @server = CalcServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @calc = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
+ @calc.add_method('add', 'lhs', 'rhs')
+ @calc.add_method('sub', 'lhs', 'rhs')
+ @calc.add_method('multi', 'lhs', 'rhs')
+ @calc.add_method('div', 'lhs', 'rhs')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @calc.reset_stream
+ end
+
+ def test_calc
+ assert_equal(3, @calc.add(1, 2))
+ assert_equal(-1.1, @calc.sub(1.1, 2.2))
+ assert_equal(2.42, @calc.multi(1.1, 2.2))
+ assert_equal(2, @calc.div(5, 2))
+ assert_equal(2.5, @calc.div(5.0, 2))
+ assert_equal(1.0/0.0, @calc.div(1.1, 0))
+ assert_raises(ZeroDivisionError) do
+ @calc.div(1, 0)
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/calc/test_calc2.rb b/ruby_1_8_5/test/soap/calc/test_calc2.rb
new file mode 100644
index 0000000000..f334b29bdb
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/test_calc2.rb
@@ -0,0 +1,53 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'server2.rb'
+
+
+module SOAP
+module Calc
+
+
+class TestCalc2 < Test::Unit::TestCase
+ Port = 17171
+
+ def setup
+ @server = CalcServer2.new('CalcServer', 'http://tempuri.org/calcService', '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @var = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
+ @var.wiredump_dev = STDERR if $DEBUG
+ @var.add_method('set_value', 'newValue')
+ @var.add_method('get_value')
+ @var.add_method_as('+', 'add', 'rhs')
+ @var.add_method_as('-', 'sub', 'rhs')
+ @var.add_method_as('*', 'multi', 'rhs')
+ @var.add_method_as('/', 'div', 'rhs')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @var.reset_stream
+ end
+
+ def test_calc2
+ assert_equal(1, @var.set_value(1))
+ assert_equal(3, @var + 2)
+ assert_equal(-1.2, @var - 2.2)
+ assert_equal(2.2, @var * 2.2)
+ assert_equal(0, @var / 2)
+ assert_equal(0.5, @var / 2.0)
+ assert_raises(ZeroDivisionError) do
+ @var / 0
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/calc/test_calc_cgi.rb b/ruby_1_8_5/test/soap/calc/test_calc_cgi.rb
new file mode 100644
index 0000000000..d28830629f
--- /dev/null
+++ b/ruby_1_8_5/test/soap/calc/test_calc_cgi.rb
@@ -0,0 +1,69 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'logger'
+require 'webrick'
+require 'rbconfig'
+
+
+module SOAP
+module Calc
+
+
+class TestCalcCGI < Test::Unit::TestCase
+ # This test shuld be run after installing ruby.
+ RUBYBIN = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+ RUBYBIN << " -d" if $DEBUG
+
+ Port = 17171
+
+ def setup
+ logger = Logger.new(STDERR)
+ logger.level = Logger::Severity::ERROR
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__)),
+ :CGIPathEnv => ENV['PATH'],
+ :CGIInterpreter => RUBYBIN
+ )
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/server.cgi"
+ @calc = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
+ @calc.wiredump_dev = STDERR if $DEBUG
+ @calc.add_method('add', 'lhs', 'rhs')
+ @calc.add_method('sub', 'lhs', 'rhs')
+ @calc.add_method('multi', 'lhs', 'rhs')
+ @calc.add_method('div', 'lhs', 'rhs')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @calc.reset_stream
+ end
+
+ def test_calc_cgi
+ assert_equal(3, @calc.add(1, 2))
+ assert_equal(-1.1, @calc.sub(1.1, 2.2))
+ assert_equal(2.42, @calc.multi(1.1, 2.2))
+ assert_equal(2, @calc.div(5, 2))
+ assert_equal(2.5, @calc.div(5.0, 2))
+ assert_equal(1.0/0.0, @calc.div(1.1, 0))
+ assert_raises(ZeroDivisionError) do
+ @calc.div(1, 0)
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/fault/test_customfault.rb b/ruby_1_8_5/test/soap/fault/test_customfault.rb
new file mode 100644
index 0000000000..2f7bc2be6e
--- /dev/null
+++ b/ruby_1_8_5/test/soap/fault/test_customfault.rb
@@ -0,0 +1,58 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+
+
+module SOAP
+module Fault
+
+
+class TestCustomFault < Test::Unit::TestCase
+ Port = 17171
+
+ class CustomFaultServer < SOAP::RPC::StandaloneServer
+ def on_init
+ add_method(self, 'fault', 'msg')
+ end
+
+ def fault(msg)
+ SOAPFault.new(SOAPString.new("mycustom"),
+ SOAPString.new("error: #{msg}"),
+ SOAPString.new(self.class.name))
+ end
+ end
+
+ def setup
+ @server = CustomFaultServer.new('customfault', 'urn:customfault', '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint, 'urn:customfault')
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method("fault", "msg")
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ def test_custom_fault
+ begin
+ @client.fault("message")
+ assert(false, 'exception not raised')
+ rescue SOAP::FaultError => e
+ assert(true, 'exception raised')
+ assert_equal('error: message', e.message)
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/header/server.cgi b/ruby_1_8_5/test/soap/header/server.cgi
new file mode 100644
index 0000000000..2a188538d9
--- /dev/null
+++ b/ruby_1_8_5/test/soap/header/server.cgi
@@ -0,0 +1,119 @@
+require 'pstore'
+require 'soap/rpc/cgistub'
+require 'soap/header/simplehandler'
+
+
+class AuthHeaderPortServer < SOAP::RPC::CGIStub
+ PortName = 'http://tempuri.org/authHeaderPort'
+ SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+ SessionDB = File.join(File.expand_path(File.dirname(__FILE__)), 'session.pstoredb')
+
+ class AuthHeaderService
+ def self.create
+ new
+ end
+
+ def deposit(amt)
+ "deposit #{amt} OK"
+ end
+
+ def withdrawal(amt)
+ "withdrawal #{amt} OK"
+ end
+ end
+
+ class AuthHeaderSupportService
+ def delete_sessiondb
+ File.unlink(SessionDB) if File.file?(SessionDB)
+ backup = SessionDB + "~"
+ File.unlink(backup) if File.file?(backup)
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(AuthHeaderService.new, PortName)
+ add_rpc_servant(AuthHeaderSupportService.new, SupportPortName)
+ add_rpc_headerhandler(ServerAuthHeaderHandler.new)
+ end
+
+ class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
+ Users = {
+ 'NaHi' => 'passwd',
+ 'HiNa' => 'wspass'
+ }
+
+ def initialize
+ super(MyHeaderName)
+ @db = PStore.new(SessionDB)
+ @db.transaction do
+ @db["root"] = {} unless @db.root?("root")
+ end
+ @userid = @sessionid = nil
+ end
+
+ def login(userid, passwd)
+ userid and passwd and Users[userid] == passwd
+ end
+
+ def auth(sessionid)
+ in_sessiondb do |root|
+ root[sessionid][0]
+ end
+ end
+
+ def create_session(userid)
+ in_sessiondb do |root|
+ while true
+ key = create_sessionkey
+ break unless root[key]
+ end
+ root[key] = [userid]
+ key
+ end
+ end
+
+ def destroy_session(sessionkey)
+ in_sessiondb do |root|
+ root.delete(sessionkey)
+ end
+ end
+
+ def on_simple_outbound
+ { "sessionid" => @sessionid }
+ end
+
+ def on_simple_inbound(my_header, mu)
+ succeeded = false
+ userid = my_header["userid"]
+ passwd = my_header["passwd"]
+ if login(userid, passwd)
+ succeeded = true
+ elsif sessionid = my_header["sessionid"]
+ if userid = auth(sessionid)
+ destroy_session(sessionid)
+ succeeded = true
+ end
+ end
+ raise RuntimeError.new("authentication failed") unless succeeded
+ @userid = userid
+ @sessionid = create_session(userid)
+ end
+
+ private
+
+ def create_sessionkey
+ Time.now.usec.to_s
+ end
+
+ def in_sessiondb
+ @db.transaction do
+ yield(@db["root"])
+ end
+ end
+ end
+end
+
+
+status = AuthHeaderPortServer.new('AuthHeaderPortServer', nil).start
diff --git a/ruby_1_8_5/test/soap/header/test_authheader.rb b/ruby_1_8_5/test/soap/header/test_authheader.rb
new file mode 100644
index 0000000000..47e1e76b82
--- /dev/null
+++ b/ruby_1_8_5/test/soap/header/test_authheader.rb
@@ -0,0 +1,240 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+
+
+module SOAP
+module Header
+
+
+class TestAuthHeader < Test::Unit::TestCase
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+ DummyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "dummy")
+
+ class AuthHeaderPortServer < SOAP::RPC::StandaloneServer
+ class AuthHeaderService
+ def self.create
+ new
+ end
+
+ def deposit(amt)
+ "deposit #{amt} OK"
+ end
+
+ def withdrawal(amt)
+ "withdrawal #{amt} OK"
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(AuthHeaderService.new, PortName)
+ ServerAuthHeaderHandler.init
+ add_request_headerhandler(ServerAuthHeaderHandler)
+ end
+
+ class ServerAuthHeaderHandler < SOAP::Header::SimpleHandler
+ class << self
+ def create
+ new
+ end
+
+ def init
+ @users = {
+ 'NaHi' => 'passwd',
+ 'HiNa' => 'wspass'
+ }
+ @sessions = {}
+ end
+
+ def login(userid, passwd)
+ userid and passwd and @users[userid] == passwd
+ end
+
+ def auth(sessionid)
+ @sessions[sessionid][0]
+ end
+
+ def create_session(userid)
+ while true
+ key = create_sessionkey
+ break unless @sessions[key]
+ end
+ @sessions[key] = [userid]
+ key
+ end
+
+ def destroy_session(sessionkey)
+ @sessions.delete(sessionkey)
+ end
+
+ def sessions
+ @sessions
+ end
+
+ private
+
+ def create_sessionkey
+ Time.now.usec.to_s
+ end
+ end
+
+ def initialize
+ super(MyHeaderName)
+ @userid = @sessionid = nil
+ end
+
+ def on_simple_outbound
+ { "sessionid" => @sessionid }
+ end
+
+ def on_simple_inbound(my_header, mu)
+ auth = false
+ userid = my_header["userid"]
+ passwd = my_header["passwd"]
+ if self.class.login(userid, passwd)
+ auth = true
+ elsif sessionid = my_header["sessionid"]
+ if userid = self.class.auth(sessionid)
+ self.class.destroy_session(sessionid)
+ auth = true
+ end
+ end
+ raise RuntimeError.new("authentication failed") unless auth
+ @userid = userid
+ @sessionid = self.class.create_session(userid)
+ end
+ end
+ end
+
+ class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(userid, passwd, mustunderstand)
+ super(MyHeaderName)
+ @sessionid = nil
+ @userid = userid
+ @passwd = passwd
+ @mustunderstand = mustunderstand
+ end
+
+ def on_simple_outbound
+ if @sessionid
+ { "sessionid" => @sessionid }
+ else
+ { "userid" => @userid, "passwd" => @passwd }
+ end
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ @sessionid = my_header["sessionid"]
+ end
+
+ def sessionid
+ @sessionid
+ end
+ end
+
+ class DummyHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(mustunderstand)
+ super(DummyHeaderName)
+ @mustunderstand = mustunderstand
+ end
+
+ def on_simple_outbound
+ { XSD::QName.new("foo", "bar") => nil }
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = AuthHeaderPortServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('deposit', 'amt')
+ @client.add_method('withdrawal', 'amt')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def test_success_no_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', false)
+ @client.headerhandler << h
+ do_transaction_check(h)
+ end
+
+ def test_success_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ do_transaction_check(h)
+ end
+
+ def test_no_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ @client.headerhandler << DummyHeaderHandler.new(false)
+ do_transaction_check(h)
+ end
+
+ def test_mu
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd', true)
+ @client.headerhandler << h
+ @client.headerhandler << (h2 = DummyHeaderHandler.new(true))
+ assert_raise(SOAP::UnhandledMustUnderstandHeaderError) do
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ end
+ @client.headerhandler.delete(h2)
+ @client.headerhandler << (h2 = DummyHeaderHandler.new(false))
+ do_transaction_check(h)
+ end
+
+ def do_transaction_check(h)
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
+ assert_equal("NaHi", serversess[0])
+ assert_equal("withdrawal 120 OK", @client.withdrawal(120))
+ serversess = AuthHeaderPortServer::ServerAuthHeaderHandler.sessions[h.sessionid]
+ assert_equal("NaHi", serversess[0])
+ end
+
+ def test_authfailure
+ h = ClientAuthHeaderHandler.new('NaHi', 'pa', false)
+ @client.headerhandler << h
+ assert_raises(RuntimeError) do
+ @client.deposit(150)
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/header/test_authheader_cgi.rb b/ruby_1_8_5/test/soap/header/test_authheader_cgi.rb
new file mode 100644
index 0000000000..d70b022ad8
--- /dev/null
+++ b/ruby_1_8_5/test/soap/header/test_authheader_cgi.rb
@@ -0,0 +1,121 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+require 'logger'
+require 'webrick'
+require 'rbconfig'
+
+
+module SOAP
+module Header
+
+
+class TestAuthHeaderCGI < Test::Unit::TestCase
+ # This test shuld be run after installing ruby.
+ RUBYBIN = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+ RUBYBIN << " -d" if $DEBUG
+
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+ SupportPortName = 'http://tempuri.org/authHeaderSupportPort'
+ MyHeaderName = XSD::QName.new("http://tempuri.org/authHeader", "auth")
+
+ class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
+ def initialize(userid, passwd)
+ super(MyHeaderName)
+ @sessionid = nil
+ @userid = userid
+ @passwd = passwd
+ end
+
+ def on_simple_outbound
+ if @sessionid
+ { "sessionid" => @sessionid }
+ else
+ { "userid" => @userid, "passwd" => @passwd }
+ end
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ @sessionid = my_header["sessionid"]
+ end
+
+ def sessionid
+ @sessionid
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @endpoint = "http://localhost:#{Port}/server.cgi"
+ logger = Logger.new(STDERR)
+ logger.level = Logger::Severity::ERROR
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__)),
+ :CGIPathEnv => ENV['PATH'],
+ :CGIInterpreter => RUBYBIN
+ )
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('deposit', 'amt')
+ @client.add_method('withdrawal', 'amt')
+ @supportclient = SOAP::RPC::Driver.new(@endpoint, SupportPortName)
+ @supportclient.add_method('delete_sessiondb')
+ end
+
+ def teardown
+ @supportclient.delete_sessiondb
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ @supportclient.reset_stream
+ end
+
+ def test_success
+ h = ClientAuthHeaderHandler.new('NaHi', 'passwd')
+ @client.headerhandler << h
+ assert_equal("deposit 150 OK", @client.deposit(150))
+ assert_equal("withdrawal 120 OK", @client.withdrawal(120))
+ end
+
+ def test_authfailure
+ h = ClientAuthHeaderHandler.new('NaHi', 'pa')
+ @client.headerhandler << h
+ assert_raises(RuntimeError) do
+ @client.deposit(150)
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/header/test_simplehandler.rb b/ruby_1_8_5/test/soap/header/test_simplehandler.rb
new file mode 100644
index 0000000000..75dbd4a550
--- /dev/null
+++ b/ruby_1_8_5/test/soap/header/test_simplehandler.rb
@@ -0,0 +1,116 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/header/simplehandler'
+
+
+module SOAP
+module Header
+
+
+class TestSimpleHandler < Test::Unit::TestCase
+ Port = 17171
+ PortName = 'http://tempuri.org/authHeaderPort'
+
+ class PingPortServer < SOAP::RPC::StandaloneServer
+ class PingService
+ def self.create
+ new
+ end
+
+ def ping
+ Thread.current[:pingheader]
+ end
+ end
+
+ def initialize(*arg)
+ super
+ add_rpc_servant(PingService.new, PortName)
+ add_request_headerhandler(PingServerHeaderHandler)
+ end
+
+ class PingServerHeaderHandler < SOAP::Header::SimpleHandler
+ MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader")
+
+ def self.create
+ new
+ end
+
+ def initialize()
+ super(MyHeaderName)
+ end
+
+ def on_simple_outbound
+ "dummy"
+ end
+
+ def on_simple_inbound(my_header, mu)
+ Thread.current[:pingheader] = my_header
+ end
+ end
+ end
+
+ class PingClientHeaderHandler < SOAP::Header::SimpleHandler
+ MyHeaderName = XSD::QName.new("http://xmlsoap.org/Ping", "PingHeader")
+
+ def initialize(pingHeader)
+ super(MyHeaderName)
+ @pingHeader = pingHeader
+ @mustunderstand = false
+ end
+
+ def on_simple_outbound
+ @pingHeader # --- note, not a Hash
+ end
+
+ def on_simple_inbound(my_header, mustunderstand)
+ Thread.current[:pingheader] = my_header
+ end
+ end
+
+ def setup
+ @endpoint = "http://localhost:#{Port}/"
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = PingPortServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@endpoint, PortName)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('ping')
+ end
+
+ def teardown
+ teardown_server
+ teardown_client
+ end
+
+ def teardown_server
+ @server.shutdown
+ @t.kill
+ @t.join
+ end
+
+ def teardown_client
+ @client.reset_stream
+ end
+
+ def test_string
+ h = PingClientHeaderHandler.new('pingheader')
+ @client.headerhandler << h
+ assert_equal("pingheader", @client.ping)
+ assert_equal("dummy", Thread.current[:pingheader])
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/helloworld/hw_s.rb b/ruby_1_8_5/test/soap/helloworld/hw_s.rb
new file mode 100644
index 0000000000..1a54adb924
--- /dev/null
+++ b/ruby_1_8_5/test/soap/helloworld/hw_s.rb
@@ -0,0 +1,16 @@
+require 'soap/rpc/standaloneServer'
+
+class HelloWorldServer < SOAP::RPC::StandaloneServer
+ def on_init
+ add_method(self, 'hello_world', 'from')
+ end
+
+ def hello_world(from)
+ "Hello World, from #{ from }"
+ end
+end
+
+if $0 == __FILE__
+ server = HelloWorldServer.new('hws', 'urn:hws', '0.0.0.0', 17171)
+ server.start
+end
diff --git a/ruby_1_8_5/test/soap/helloworld/test_helloworld.rb b/ruby_1_8_5/test/soap/helloworld/test_helloworld.rb
new file mode 100644
index 0000000000..40c35b57fb
--- /dev/null
+++ b/ruby_1_8_5/test/soap/helloworld/test_helloworld.rb
@@ -0,0 +1,40 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'hw_s.rb'
+
+
+module SOAP
+module HelloWorld
+
+
+class TestHelloWorld < Test::Unit::TestCase
+ Port = 17171
+
+ def setup
+ @server = HelloWorldServer.new('hws', 'urn:hws', '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ Thread.current.abort_on_exception = true
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint, 'urn:hws')
+ @client.add_method("hello_world", "from")
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ def test_hello_world
+ assert_equal("Hello World, from NaHi", @client.hello_world("NaHi"))
+ assert_equal("Hello World, from <&>", @client.hello_world("<&>"))
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/marshal/test_digraph.rb b/ruby_1_8_5/test/soap/marshal/test_digraph.rb
new file mode 100644
index 0000000000..d7f30654f8
--- /dev/null
+++ b/ruby_1_8_5/test/soap/marshal/test_digraph.rb
@@ -0,0 +1,56 @@
+require 'test/unit'
+require 'soap/marshal'
+
+
+module SOAP
+module Marshal
+
+
+class Node; include SOAP::Marshallable
+ attr_reader :first, :second, :str
+
+ def initialize(*init_next)
+ @first = init_next[0]
+ @second = init_next[1]
+ end
+end
+
+class TestDigraph < Test::Unit::TestCase
+ def setup
+ @n9 = Node.new
+ @n81 = Node.new(@n9)
+ @n82 = Node.new(@n9)
+ @n7 = Node.new(@n81, @n82)
+ @n61 = Node.new(@n7)
+ @n62 = Node.new(@n7)
+ @n5 = Node.new(@n61, @n62)
+ @n41 = Node.new(@n5)
+ @n42 = Node.new(@n5)
+ @n3 = Node.new(@n41, @n42)
+ @n21 = Node.new(@n3)
+ @n22 = Node.new(@n3)
+ @n1 = Node.new(@n21, @n22)
+ end
+
+ def test_marshal
+ f = File.open("digraph_marshalled_string.soap", "wb")
+ SOAP::Marshal.dump(@n1, f)
+ f.close
+ f = File.open("digraph_marshalled_string.soap")
+ str = f.read
+ f.close
+ newnode = SOAP::Marshal.unmarshal(str)
+ assert_equal(newnode.first.first.__id__, newnode.second.first.__id__)
+ assert_equal(newnode.first.first.first.first.__id__, newnode.second.first.second.first.__id__)
+ end
+
+ def teardown
+ if File.exist?("digraph_marshalled_string.soap")
+ File.unlink("digraph_marshalled_string.soap")
+ end
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/marshal/test_marshal.rb b/ruby_1_8_5/test/soap/marshal/test_marshal.rb
new file mode 100644
index 0000000000..5cc30a2b5d
--- /dev/null
+++ b/ruby_1_8_5/test/soap/marshal/test_marshal.rb
@@ -0,0 +1,26 @@
+require 'test/unit'
+require 'soap/marshal'
+dir = File.join(File.dirname(File.expand_path(__FILE__)), '../../ruby')
+orgpath = $:.dup
+begin
+ $:.push(dir)
+ require 'marshaltestlib'
+ensure
+ $:.replace(orgpath)
+end
+
+module SOAP
+module Marshal
+class TestMarshal < Test::Unit::TestCase
+ include MarshalTestLib
+
+ def encode(o)
+ SOAPMarshal.dump(o)
+ end
+
+ def decode(s)
+ SOAPMarshal.load(s)
+ end
+end
+end
+end
diff --git a/ruby_1_8_5/test/soap/marshal/test_struct.rb b/ruby_1_8_5/test/soap/marshal/test_struct.rb
new file mode 100644
index 0000000000..33975c31b0
--- /dev/null
+++ b/ruby_1_8_5/test/soap/marshal/test_struct.rb
@@ -0,0 +1,47 @@
+require 'test/unit'
+require 'soap/marshal'
+
+
+module SOAP
+module Marshal
+
+
+Foo1 = ::Struct.new("Foo1", :m)
+Foo2 = ::Struct.new(:m)
+class Foo3
+ attr_accessor :m
+end
+
+class TestStruct < Test::Unit::TestCase
+ def test_foo1
+ org = Foo1.new
+ org.m = org
+ obj = convert(org)
+ assert_equal(Foo1, obj.class)
+ assert_equal(obj.m, obj)
+ end
+
+ def test_foo2
+ org = Foo2.new
+ org.m = org
+ obj = convert(org)
+ assert_equal(Foo2, obj.class)
+ assert_equal(obj.m, obj)
+ end
+
+ def test_foo3
+ org = Foo3.new
+ org.m = org
+ obj = convert(org)
+ assert_equal(Foo3, obj.class)
+ assert_equal(obj.m, obj)
+ end
+
+ def convert(obj)
+ SOAP::Marshal.unmarshal(SOAP::Marshal.marshal(obj))
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/ssl/README b/ruby_1_8_5/test/soap/ssl/README
new file mode 100644
index 0000000000..98ebcf7c23
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/README
@@ -0,0 +1 @@
+* certificates and keys in this directory is copied from http-access2 test.
diff --git a/ruby_1_8_5/test/soap/ssl/ca.cert b/ruby_1_8_5/test/soap/ssl/ca.cert
new file mode 100644
index 0000000000..bcabbee4ad
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/ca.cert
@@ -0,0 +1,23 @@
+-----BEGIN CERTIFICATE-----
+MIID0DCCArigAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMDAwNDIzMloXDTM2MDEyMjAwNDIzMlowPDELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQswCQYDVQQDDAJDQTCCASIw
+DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANbv0x42BTKFEQOE+KJ2XmiSdZpR
+wjzQLAkPLRnLB98tlzs4xo+y4RyY/rd5TT9UzBJTIhP8CJi5GbS1oXEerQXB3P0d
+L5oSSMwGGyuIzgZe5+vZ1kgzQxMEKMMKlzA73rbMd4Jx3u5+jdbP0EDrPYfXSvLY
+bS04n2aX7zrN3x5KdDrNBfwBio2/qeaaj4+9OxnwRvYP3WOvqdW0h329eMfHw0pi
+JI0drIVdsEqClUV4pebT/F+CPUPkEh/weySgo9wANockkYu5ujw2GbLFcO5LXxxm
+dEfcVr3r6t6zOA4bJwL0W/e6LBcrwiG/qPDFErhwtgTLYf6Er67SzLyA66UCAwEA
+AaOB3DCB2TAPBgNVHRMBAf8EBTADAQH/MDEGCWCGSAGG+EIBDQQkFiJSdWJ5L09w
+ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBRJ7Xd380KzBV7f
+USKIQ+O/vKbhDzAOBgNVHQ8BAf8EBAMCAQYwZAYDVR0jBF0wW4AUSe13d/NCswVe
+31EiiEPjv7ym4Q+hQKQ+MDwxCzAJBgNVBAYMAkpQMRIwEAYDVQQKDAlKSU4uR1Iu
+SlAxDDAKBgNVBAsMA1JSUjELMAkGA1UEAwwCQ0GCAQAwDQYJKoZIhvcNAQEFBQAD
+ggEBAIu/mfiez5XN5tn2jScgShPgHEFJBR0BTJBZF6xCk0jyqNx/g9HMj2ELCuK+
+r/Y7KFW5c5M3AQ+xWW0ZSc4kvzyTcV7yTVIwj2jZ9ddYMN3nupZFgBK1GB4Y05GY
+MJJFRkSu6d/Ph5ypzBVw2YMT/nsOo5VwMUGLgS7YVjU+u/HNWz80J3oO17mNZllj
+PvORJcnjwlroDnS58KoJ7GDgejv3ESWADvX1OHLE4cRkiQGeLoEU4pxdCxXRqX0U
+PbwIkZN9mXVcrmPHq8MWi4eC/V7hnbZETMHuWhUoiNdOEfsAXr3iP4KjyyRdwc7a
+d/xgcK06UVQRL/HbEYGiQL056mc=
+-----END CERTIFICATE-----
diff --git a/ruby_1_8_5/test/soap/ssl/client.cert b/ruby_1_8_5/test/soap/ssl/client.cert
new file mode 100644
index 0000000000..ad13c4b735
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/client.cert
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDKDCCAhCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMTAzMTQ1OFoXDTM1MDEyMzAzMTQ1OFowZTELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRAwDgYDVQQDDAdleGFtcGxl
+MSIwIAYJKoZIhvcNAQkBDBNleGFtcGxlQGV4YW1wbGUub3JnMIGfMA0GCSqGSIb3
+DQEBAQUAA4GNADCBiQKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLW
+jTkvsgOwbYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQ
+gNS6ew7/Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2Xf
+ewIDAQABo4GPMIGMMAwGA1UdEwEB/wQCMAAwMQYJYIZIAYb4QgENBCQWIlJ1Ynkv
+T3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFOFvay0H7lr2
+xUx6waYEV2bVDYQhMAsGA1UdDwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAgYI
+KwYBBQUHAwQwDQYJKoZIhvcNAQEFBQADggEBABd2dYWqbDIWf5sWFvslezxJv8gI
+w64KCJBuyJAiDuf+oazr3016kMzAlt97KecLZDusGNagPrq02UX7YMoQFsWJBans
+cDtHrkM0al5r6/WGexNMgtYbNTYzt/IwodISGBgZ6dsOuhznwms+IBsTNDAvWeLP
+lt2tOqD8kEmjwMgn0GDRuKjs4EoboA3kMULb1p9akDV9ZESU3eOtpS5/G5J5msLI
+9WXbYBjcjvkLuJH9VsJhb+R58Vl0ViemvAHhPilSl1SPWVunGhv6FcIkdBEi1k9F
+e8BNMmsEjFiANiIRvpdLRbiGBt0KrKTndVfsmoKCvY48oCOvnzxtahFxfs8=
+-----END CERTIFICATE-----
diff --git a/ruby_1_8_5/test/soap/ssl/client.key b/ruby_1_8_5/test/soap/ssl/client.key
new file mode 100644
index 0000000000..37bc62f259
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/client.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICWwIBAAKBgQDRWssrK8Gyr+500hpLjCGR3+AHL8/hEJM5zKi/MgLWjTkvsgOw
+bYwXOiNtAbR9y4/ucDq7EY+cMUMHES4uFaPTcOaAV0aZRmk8AgslN1tQgNS6ew7/
+Luq3DcVeWkX8PYgR9VG0mD1MPfJ6+IFA5d3vKpdBkBgN4l46jjO0/2XfewIDAQAB
+AoGAZcz8llWErtsV3QB9gNb3S/PNADGjqBFjReva8n3jG2k4sZSibpwWTwUaTNtT
+ZQgjSRKRvH1hk9XwffNAvXAQZNNkuj/16gO2oO45nyLj4dO365ujLptWnVIWDHOE
+uN0GeiZO+VzcCisT0WCq4tvtLeH8svrxzA8cbXIEyOK7NiECQQDwo2zPFyKAZ/Cu
+lDJ6zKT+RjfWwW7DgWzirAlTrt4ViMaW+IaDH29TmQpb4V4NuR3Xi+2Xl4oicu6S
+36TW9+/FAkEA3rgfOQJuLlWSnw1RTGwvnC816a/W7iYYY7B+0U4cDbfWl7IoXT4y
+M8nV/HESooviZLqBwzAYSoj3fFKYBKpGPwJAUO8GN5iWWA2dW3ooiDiv/X1sZmRk
+dojfMFWgRW747tEzya8Ivq0h6kH8w+5GjeMG8Gn1nRiwsulo6Ckj7dEx6QJACyui
+7UIQ8qP6GZ4aYMHgVW4Mvy7Bkeo5OO7GPYs0Xv/EdJFL8vlGnVBXOjUVoS9w6Gpu
+TbLg1QQvnX2rADjmEwJANxZO2GUkaWGsEif8aGW0x5g/IdaMGG27pTWk5zqix7P3
+1UDrdo/JOXhptovhRi06EppIxAxYmbh9vd9VN8Itlw==
+-----END RSA PRIVATE KEY-----
diff --git a/ruby_1_8_5/test/soap/ssl/server.cert b/ruby_1_8_5/test/soap/ssl/server.cert
new file mode 100644
index 0000000000..998ccc5892
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/server.cert
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIC/zCCAeegAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxDjAMBgNVBAMMBVN1YkNB
+MB4XDTA0MDEzMTAzMTMxNloXDTMzMDEyMzAzMTMxNlowQzELMAkGA1UEBgwCSlAx
+EjAQBgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMRIwEAYDVQQDDAlsb2Nh
+bGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANFJTxWqup3nV9dsJAku
+p+WaXnPNIzcpAA3qMGZDJTJsfa8Du7ZxTP0XJK5mETttBrn711cJxAuP3KjqnW9S
+vtZ9lY2sXJ6Zj62sN5LwG3VVe25dI28yR1EsbHjJ5Zjf9tmggMC6am52dxuHbt5/
+vHo4ngJuKE/U+eeGRivMn6gFAgMBAAGjgYUwgYIwDAYDVR0TAQH/BAIwADAxBglg
+hkgBhvhCAQ0EJBYiUnVieS9PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAd
+BgNVHQ4EFgQUpZIyygD9JxFYHHOTEuWOLbCKfckwCwYDVR0PBAQDAgWgMBMGA1Ud
+JQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBBQUAA4IBAQBwAIj5SaBHaA5X31IP
+CFCJiep96awfp7RANO0cuUj+ZpGoFn9d6FXY0g+Eg5wAkCNIzZU5NHN9xsdOpnUo
+zIBbyTfQEPrge1CMWMvL6uGaoEXytq84VTitF/xBTky4KtTn6+es4/e7jrrzeUXQ
+RC46gkHObmDT91RkOEGjHLyld2328jo3DIN/VTHIryDeVHDWjY5dENwpwdkhhm60
+DR9IrNBbXWEe9emtguNXeN0iu1ux0lG1Hc6pWGQxMlRKNvGh0yZB9u5EVe38tOV0
+jQaoNyL7qzcQoXD3Dmbi1p0iRmg/+HngISsz8K7k7MBNVsSclztwgCzTZOBiVtkM
+rRlQ
+-----END CERTIFICATE-----
diff --git a/ruby_1_8_5/test/soap/ssl/server.key b/ruby_1_8_5/test/soap/ssl/server.key
new file mode 100644
index 0000000000..9ba2218a03
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/server.key
@@ -0,0 +1,15 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIICXQIBAAKBgQDRSU8Vqrqd51fXbCQJLqflml5zzSM3KQAN6jBmQyUybH2vA7u2
+cUz9FySuZhE7bQa5+9dXCcQLj9yo6p1vUr7WfZWNrFyemY+trDeS8Bt1VXtuXSNv
+MkdRLGx4yeWY3/bZoIDAumpudncbh27ef7x6OJ4CbihP1PnnhkYrzJ+oBQIDAQAB
+AoGBAIf4CstW2ltQO7+XYGoex7Hh8s9lTSW/G2vu5Hbr1LTHy3fzAvdq8MvVR12O
+rk9fa+lU9vhzPc0NMB0GIDZ9GcHuhW5hD1Wg9OSCbTOkZDoH3CAFqonjh4Qfwv5W
+IPAFn9KHukdqGXkwEMdErsUaPTy9A1V/aROVEaAY+HJgq/eZAkEA/BP1QMV04WEZ
+Oynzz7/lLizJGGxp2AOvEVtqMoycA/Qk+zdKP8ufE0wbmCE3Qd6GoynavsHb6aGK
+gQobb8zDZwJBANSK6MrXlrZTtEaeZuyOB4mAmRzGzOUVkUyULUjEx2GDT93ujAma
+qm/2d3E+wXAkNSeRpjUmlQXy/2oSqnGvYbMCQQDRM+cYyEcGPUVpWpnj0shrF/QU
+9vSot/X1G775EMTyaw6+BtbyNxVgOIu2J+rqGbn3c+b85XqTXOPL0A2RLYkFAkAm
+syhSDtE9X55aoWsCNZY/vi+i4rvaFoQ/WleogVQAeGVpdo7/DK9t9YWoFBIqth0L
+mGSYFu9ZhvZkvQNV8eYrAkBJ+rOIaLDsmbrgkeDruH+B/9yrm4McDtQ/rgnOGYnH
+LjLpLLOrgUxqpzLWe++EwSLwK2//dHO+SPsQJ4xsyQJy
+-----END RSA PRIVATE KEY-----
diff --git a/ruby_1_8_5/test/soap/ssl/sslsvr.rb b/ruby_1_8_5/test/soap/ssl/sslsvr.rb
new file mode 100644
index 0000000000..4f67eb9485
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/sslsvr.rb
@@ -0,0 +1,57 @@
+require 'webrick/https'
+require 'logger'
+require 'rbconfig'
+
+require 'soap/rpc/httpserver'
+
+class HelloWorldServer < SOAP::RPC::HTTPServer
+private
+
+ def on_init
+ self.level = Logger::Severity::FATAL
+ @default_namespace = 'urn:ssltst'
+ add_method(self, 'hello_world', 'from')
+ end
+
+ def hello_world(from)
+ "Hello World, from #{ from }"
+ end
+end
+
+
+if $0 == __FILE__
+ PORT = 17171
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ def cert(filename)
+ OpenSSL::X509::Certificate.new(File.open(File.join(DIR, filename)) { |f|
+ f.read
+ })
+ end
+
+ def key(filename)
+ OpenSSL::PKey::RSA.new(File.open(File.join(DIR, filename)) { |f|
+ f.read
+ })
+ end
+
+ $server = HelloWorldServer.new(
+ :BindAddress => "0.0.0.0",
+ :Port => PORT,
+ :AccessLog => [],
+ :SSLEnable => true,
+ :SSLCACertificateFile => File.join(DIR, 'ca.cert'),
+ :SSLCertificate => cert('server.cert'),
+ :SSLPrivateKey => key('server.key'),
+ :SSLVerifyClient => nil, #OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT|OpenSSL::SSL::VERIFY_PEER,
+ :SSLClientCA => cert('ca.cert'),
+ :SSLCertName => nil
+ )
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ $server.start
+ }
+ STDOUT.sync = true
+ puts $$
+ t.join
+end
diff --git a/ruby_1_8_5/test/soap/ssl/subca.cert b/ruby_1_8_5/test/soap/ssl/subca.cert
new file mode 100644
index 0000000000..1e471851b8
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/subca.cert
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGDAJKUDES
+MBAGA1UECgwJSklOLkdSLkpQMQwwCgYDVQQLDANSUlIxCzAJBgNVBAMMAkNBMB4X
+DTA0MDEzMDAwNDMyN1oXDTM1MDEyMjAwNDMyN1owPzELMAkGA1UEBgwCSlAxEjAQ
+BgNVBAoMCUpJTi5HUi5KUDEMMAoGA1UECwwDUlJSMQ4wDAYDVQQDDAVTdWJDQTCC
+ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ0Ou7AyRcRXnB/kVHv/6kwe
+ANzgg/DyJfsAUqW90m7Lu1nqyug8gK0RBd77yU0w5HOAMHTVSdpjZK0g2sgx4Mb1
+d/213eL9TTl5MRVEChTvQr8q5DVG/8fxPPE7fMI8eOAzd98/NOAChk+80r4Sx7fC
+kGVEE1bKwY1MrUsUNjOY2d6t3M4HHV3HX1V8ShuKfsHxgCmLzdI8U+5CnQedFgkm
+3e+8tr8IX5RR1wA1Ifw9VadF7OdI/bGMzog/Q8XCLf+WPFjnK7Gcx6JFtzF6Gi4x
+4dp1Xl45JYiVvi9zQ132wu8A1pDHhiNgQviyzbP+UjcB/tsOpzBQF8abYzgEkWEC
+AwEAAaNyMHAwDwYDVR0TAQH/BAUwAwEB/zAxBglghkgBhvhCAQ0EJBYiUnVieS9P
+cGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUlCjXWLsReYzH
+LzsxwVnCXmKoB/owCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQCJ/OyN
+rT8Cq2Y+G2yA/L1EMRvvxwFBqxavqaqHl/6rwsIBFlB3zbqGA/0oec6MAVnYynq4
+c4AcHTjx3bQ/S4r2sNTZq0DH4SYbQzIobx/YW8PjQUJt8KQdKMcwwi7arHP7A/Ha
+LKu8eIC2nsUBnP4NhkYSGhbmpJK+PFD0FVtD0ZIRlY/wsnaZNjWWcnWF1/FNuQ4H
+ySjIblqVQkPuzebv3Ror6ZnVDukn96Mg7kP4u6zgxOeqlJGRe1M949SS9Vudjl8X
+SF4aZUUB9pQGhsqQJVqaz2OlhGOp9D0q54xko/rekjAIcuDjl1mdX4F2WRrzpUmZ
+uY/bPeOBYiVsOYVe
+-----END CERTIFICATE-----
diff --git a/ruby_1_8_5/test/soap/ssl/test_ssl.rb b/ruby_1_8_5/test/soap/ssl/test_ssl.rb
new file mode 100644
index 0000000000..f0a1e18971
--- /dev/null
+++ b/ruby_1_8_5/test/soap/ssl/test_ssl.rb
@@ -0,0 +1,204 @@
+require 'test/unit'
+begin
+ require 'http-access2'
+rescue LoadError
+end
+require 'soap/rpc/driver'
+
+if defined?(HTTPAccess2) and defined?(OpenSSL)
+
+module SOAP; module SSL
+
+
+class TestSSL < Test::Unit::TestCase
+ PORT = 17171
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ require 'rbconfig'
+ RUBY = File.join(
+ Config::CONFIG["bindir"],
+ Config::CONFIG["ruby_install_name"] + Config::CONFIG["EXEEXT"]
+ )
+
+ def setup
+ @url = "https://localhost:#{PORT}/hello"
+ @serverpid = @client = nil
+ @verify_callback_called = false
+ setup_server
+ setup_client
+ end
+
+ def teardown
+ teardown_client
+ teardown_server
+ end
+
+ def test_options
+ cfg = @client.streamhandler.client.ssl_config
+ assert_nil(cfg.client_cert)
+ assert_nil(cfg.client_key)
+ assert_nil(cfg.client_ca)
+ assert_equal(OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT, cfg.verify_mode)
+ assert_nil(cfg.verify_callback)
+ assert_nil(cfg.timeout)
+ assert_equal(OpenSSL::SSL::OP_ALL | OpenSSL::SSL::OP_NO_SSLv2, cfg.options)
+ assert_equal("ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH", cfg.ciphers)
+ assert_instance_of(OpenSSL::X509::Store, cfg.cert_store)
+ # dummy call to ensure sslsvr initialization finished.
+ assert_raise(OpenSSL::SSL::SSLError) do
+ @client.hello_world("ssl client")
+ end
+ end
+
+ def test_verification
+ cfg = @client.options
+ cfg["protocol.http.ssl_config.verify_callback"] = method(:verify_callback).to_proc
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.client_cert"] = File.join(DIR, "client.cert")
+ cfg["protocol.http.ssl_config.client_key"] = File.join(DIR, "client.key")
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "ca.cert")
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "subca.cert")
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.verify_depth"] = "1"
+ @verify_callback_called = false
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ #
+ cfg["protocol.http.ssl_config.verify_depth"] = ""
+ cfg["protocol.http.ssl_config.cert_store"] = OpenSSL::X509::Store.new
+ cfg["protocol.http.ssl_config.verify_mode"] = OpenSSL::SSL::VERIFY_PEER.to_s
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ #
+ cfg["protocol.http.ssl_config.verify_mode"] = ""
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ end
+
+ def test_property
+ testpropertyname = File.join(DIR, 'soapclient.properties')
+ File.open(testpropertyname, "w") do |f|
+ f <<<<__EOP__
+protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
+# depth: 1 causes an error (intentional)
+protocol.http.ssl_config.verify_depth = 1
+protocol.http.ssl_config.client_cert = #{File.join(DIR, 'client.cert')}
+protocol.http.ssl_config.client_key = #{File.join(DIR, 'client.key')}
+protocol.http.ssl_config.ca_file = #{File.join(DIR, 'ca.cert')}
+protocol.http.ssl_config.ca_file = #{File.join(DIR, 'subca.cert')}
+protocol.http.ssl_config.ciphers = ALL
+__EOP__
+ end
+ begin
+ @client.loadproperty(testpropertyname)
+ @client.options["protocol.http.ssl_config.verify_callback"] = method(:verify_callback).to_proc
+ @verify_callback_called = false
+ # NG with String
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ # NG with Integer
+ @client.options["protocol.http.ssl_config.verify_depth"] = 0
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ assert_equal("certificate verify failed", ssle.message)
+ assert(@verify_callback_called)
+ # OK with empty
+ @client.options["protocol.http.ssl_config.verify_depth"] = ""
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ # OK with nil
+ @client.options["protocol.http.ssl_config.verify_depth"] = nil
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ # OK with String
+ @client.options["protocol.http.ssl_config.verify_depth"] = "3"
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ # OK with Integer
+ @client.options["protocol.http.ssl_config.verify_depth"] = 3
+ @verify_callback_called = false
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ assert(@verify_callback_called)
+ ensure
+ File.unlink(testpropertyname)
+ end
+ end
+
+ def test_ciphers
+ cfg = @client.options
+ cfg["protocol.http.ssl_config.client_cert"] = File.join(DIR, 'client.cert')
+ cfg["protocol.http.ssl_config.client_key"] = File.join(DIR, 'client.key')
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "ca.cert")
+ cfg["protocol.http.ssl_config.ca_file"] = File.join(DIR, "subca.cert")
+ #cfg.timeout = 123
+ cfg["protocol.http.ssl_config.ciphers"] = "!ALL"
+ #
+ ssle = assert_raise(OpenSSL::SSL::SSLError) {@client.hello_world("ssl client")}
+ # depends on OpenSSL version. (?:0.9.8|0.9.7)
+ assert_match(/\A(?:SSL_CTX_set_cipher_list:: no cipher match|no ciphers available)\z/, ssle.message)
+ #
+ cfg["protocol.http.ssl_config.ciphers"] = "ALL"
+ assert_equal("Hello World, from ssl client", @client.hello_world("ssl client"))
+ end
+
+private
+
+ def q(str)
+ %Q["#{str}"]
+ end
+
+ def setup_server
+ svrcmd = "#{q(RUBY)} "
+ #svrcmd << "-d " if $DEBUG
+ svrcmd << File.join(DIR, "sslsvr.rb")
+ svrout = IO.popen(svrcmd)
+ @serverpid = Integer(svrout.gets.chomp)
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@url, 'urn:ssltst')
+ @client.add_method("hello_world", "from")
+ end
+
+ def teardown_server
+ if @serverpid
+ Process.kill('KILL', @serverpid)
+ Process.waitpid(@serverpid)
+ end
+ end
+
+ def teardown_client
+ @client.reset_stream if @client
+ end
+
+ def verify_callback(ok, cert)
+ @verify_callback_called = true
+ p ["client", ok, cert] if $DEBUG
+ ok
+ end
+end
+
+
+end; end
+
+end
diff --git a/ruby_1_8_5/test/soap/struct/test_struct.rb b/ruby_1_8_5/test/soap/struct/test_struct.rb
new file mode 100644
index 0000000000..d92f4bc18a
--- /dev/null
+++ b/ruby_1_8_5/test/soap/struct/test_struct.rb
@@ -0,0 +1,77 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/rpc/driver'
+
+
+module SOAP; module Struct
+
+
+class TestStruct < Test::Unit::TestCase
+ Namespace = "urn:example.com:simpletype-rpc"
+ class Server < ::SOAP::RPC::HTTPServer
+ @@test_struct = ::Struct.new(:one, :two)
+
+ def on_init
+ add_method(self, 'a_method')
+ end
+
+ def a_method
+ @@test_struct.new("string", 1)
+ end
+ end
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :Port => Port,
+ :BindAddress => "0.0.0.0",
+ :AccessLog => [],
+ :SOAPDefaultNamespace => Namespace
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/", Namespace)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_method('a_method')
+ 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_struct
+ assert_equal("string", @client.a_method.one)
+ assert_equal(1, @client.a_method.two)
+ end
+end
+
+
+end; end
diff --git a/ruby_1_8_5/test/soap/swa/test_file.rb b/ruby_1_8_5/test/soap/swa/test_file.rb
new file mode 100644
index 0000000000..1ec7aa92a7
--- /dev/null
+++ b/ruby_1_8_5/test/soap/swa/test_file.rb
@@ -0,0 +1,73 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'soap/rpc/standaloneServer'
+require 'soap/attachment'
+
+
+module SOAP
+module SWA
+
+
+class TestFile < Test::Unit::TestCase
+ Port = 17171
+ THIS_FILE = File.expand_path(__FILE__)
+
+ class SwAService
+ def get_file
+ return {
+ 'name' => $0,
+ 'file' => SOAP::Attachment.new(File.open(THIS_FILE)) # closed when GCed.
+ }
+ end
+
+ def put_file(name, file)
+ "File '#{name}' was received ok."
+ end
+ end
+
+ def setup
+ @server = SOAP::RPC::StandaloneServer.new('SwAServer',
+ 'http://www.acmetron.com/soap', '0.0.0.0', Port)
+ @server.add_servant(SwAService.new)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint, 'http://www.acmetron.com/soap')
+ @client.add_method('get_file')
+ @client.add_method('put_file', 'name', 'file')
+ @client.wiredump_dev = STDERR if $DEBUG
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ def test_get_file
+ assert_equal(
+ File.open(THIS_FILE) { |f| f.read },
+ @client.get_file['file'].content
+ )
+ end
+
+ def test_put_file
+ assert_equal(
+ "File 'foo' was received ok.",
+ @client.put_file('foo',
+ SOAP::Attachment.new(File.open(THIS_FILE)))
+ )
+ assert_equal(
+ "File 'bar' was received ok.",
+ @client.put_file('bar',
+ SOAP::Attachment.new(File.open(THIS_FILE) { |f| f.read }))
+ )
+ end
+end
+
+
+end
+end
diff --git a/ruby_1_8_5/test/soap/test_basetype.rb b/ruby_1_8_5/test/soap/test_basetype.rb
new file mode 100644
index 0000000000..3785873560
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_basetype.rb
@@ -0,0 +1,970 @@
+require 'test/unit'
+require 'soap/baseData'
+
+
+module SOAP
+
+
+class TestSOAP < Test::Unit::TestCase
+ NegativeZero = (-1.0 / (1.0 / 0.0))
+
+ def setup
+ # Nothing to do.
+ end
+
+ def teardown
+ # Nothing to do.
+ end
+
+ def assert_parsed_result(klass, str)
+ o = klass.new(str)
+ assert_equal(str, o.to_s)
+ end
+
+ def test_SOAPNil
+ o = SOAP::SOAPNil.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::NilLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ o = SOAP::SOAPNil.new(nil)
+ assert_equal(true, o.is_nil)
+ assert_equal(nil, o.data)
+ assert_equal("", o.to_s)
+ o = SOAP::SOAPNil.new('var')
+ assert_equal(false, o.is_nil)
+ assert_equal('var', o.data)
+ assert_equal('var', o.to_s)
+ end
+
+ def test_SOAPString
+ o = SOAP::SOAPString.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::StringLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ str = "abc"
+ assert_equal(str, SOAP::SOAPString.new(str).data)
+ assert_equal(str, SOAP::SOAPString.new(str).to_s)
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPString.new("\0")
+ end
+ assert_raises(XSD::ValueSpaceError) do
+ p SOAP::SOAPString.new("\xC0\xC0").to_s
+ end
+ end
+
+ def test_SOAPBoolean
+ o = SOAP::SOAPBoolean.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::BooleanLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ ["true", true],
+ ["1", true],
+ ["false", false],
+ ["0", false],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPBoolean.new(data).data)
+ assert_equal(expected.to_s, SOAP::SOAPBoolean.new(data).to_s)
+ end
+
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPBoolean.new("nil").to_s
+ end
+ end
+
+ def test_SOAPDecimal
+ o = SOAP::SOAPDecimal.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DecimalLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 1000000000,
+ -9999999999,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ -1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789,
+ ]
+ targets.each do |dec|
+ assert_equal(dec.to_s, SOAP::SOAPDecimal.new(dec).data)
+ end
+
+ targets = [
+ "0",
+ "0.00000001",
+ "1000000000",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123.45678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPDecimal.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["0.0", "0"],
+ ["-0.0", "0"],
+ ["+0.0", "0"],
+ ["0.", "0"],
+ [".0", "0"],
+ [
+ "+0.12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "0.1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
+ ],
+ [
+ ".0000012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "0.000001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
+ ],
+ [
+ "-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.",
+ "-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ ],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDecimal.new(data).to_s)
+ end
+
+ targets = [
+ "0.000000000000a",
+ "00a.0000000000001",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPDecimal.new(d)
+ end
+ end
+ end
+
+ def test_SOAPFloat
+ o = SOAP::SOAPFloat.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::FloatLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 3.14159265358979,
+ 12.34e36,
+ 1.402e-45,
+ -1.402e-45,
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPFloat.new(f).data)
+ end
+
+ targets = [
+ "+3.141592654",
+ "+1.234e+37",
+ "+1.402e-45",
+ "-1.402e-45",
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPFloat.new(f).to_s)
+ end
+
+ targets = [
+ [3, "+3"], # should be 3.0?
+ [-2, "-2"], # ditto
+ [3.14159265358979, "+3.141592654"],
+ [12.34e36, "+1.234e+37"],
+ [1.402e-45, "+1.402e-45"],
+ [-1.402e-45, "-1.402e-45"],
+ ["1.402e", "+1.402"],
+ ["12.34E36", "+1.234e+37"],
+ ["1.402E-45", "+1.402e-45"],
+ ["-1.402E-45", "-1.402e-45"],
+ ["1.402E", "+1.402"],
+ ]
+ targets.each do |f, str|
+ assert_equal(str, SOAP::SOAPFloat.new(f).to_s)
+ end
+
+ assert_equal("+0", SOAP::SOAPFloat.new(+0.0).to_s)
+ assert_equal("-0", SOAP::SOAPFloat.new(NegativeZero).to_s)
+ assert(SOAP::SOAPFloat.new(0.0/0.0).data.nan?)
+ assert_equal("INF", SOAP::SOAPFloat.new(1.0/0.0).to_s)
+ assert_equal(1, SOAP::SOAPFloat.new(1.0/0.0).data.infinite?)
+ assert_equal("-INF", SOAP::SOAPFloat.new(-1.0/0.0).to_s)
+ assert_equal(-1, SOAP::SOAPFloat.new(-1.0/0.0).data.infinite?)
+
+ targets = [
+ "0.000000000000a",
+ "00a.0000000000001",
+ "+-5",
+ "5_0",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPFloat.new(d)
+ end
+ end
+ end
+
+ def test_SOAPDouble
+ o = SOAP::SOAPDouble.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DoubleLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 3.14159265358979,
+ 12.34e36,
+ 1.402e-45,
+ -1.402e-45,
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPDouble.new(f).data)
+ end
+
+ targets = [
+ "+3.14159265358979",
+ "+1.234e+37",
+ "+1.402e-45",
+ "-1.402e-45",
+ ]
+ targets.each do |f|
+ assert_equal(f, SOAP::SOAPDouble.new(f).to_s)
+ end
+
+ targets = [
+ [3, "+3"], # should be 3.0?
+ [-2, "-2"], # ditto.
+ [3.14159265358979, "+3.14159265358979"],
+ [12.34e36, "+1.234e+37"],
+ [1.402e-45, "+1.402e-45"],
+ [-1.402e-45, "-1.402e-45"],
+ ["1.402e", "+1.402"],
+ ["12.34E36", "+1.234e+37"],
+ ["1.402E-45", "+1.402e-45"],
+ ["-1.402E-45", "-1.402e-45"],
+ ["1.402E", "+1.402"],
+ ]
+ targets.each do |f, str|
+ assert_equal(str, SOAP::SOAPDouble.new(f).to_s)
+ end
+
+ assert_equal("+0", SOAP::SOAPFloat.new(+0.0).to_s)
+ assert_equal("-0", SOAP::SOAPFloat.new(NegativeZero).to_s)
+ assert_equal("NaN", SOAP::SOAPDouble.new(0.0/0.0).to_s)
+ assert(SOAP::SOAPDouble.new(0.0/0.0).data.nan?)
+ assert_equal("INF", SOAP::SOAPDouble.new(1.0/0.0).to_s)
+ assert_equal(1, SOAP::SOAPDouble.new(1.0/0.0).data.infinite?)
+ assert_equal("-INF", SOAP::SOAPDouble.new(-1.0/0.0).to_s)
+ assert_equal(-1, SOAP::SOAPDouble.new(-1.0/0.0).data.infinite?)
+
+ targets = [
+ "0.000000000000a",
+ "00a.0000000000001",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPDouble.new(d)
+ end
+ end
+ end
+
+ def test_SOAPDuration
+ o = SOAP::SOAPDuration.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DurationLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "P1Y2M3DT4H5M6S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S",
+ "P0DT3456H7890M1234.5678S",
+ "P1234Y5678M9012D",
+ "-P1234Y5678M9012DT3456H7890M1234.5678S",
+ "P5678M9012DT3456H7890M1234.5678S",
+ "-P1234Y9012DT3456H7890M1234.5678S",
+ "+P1234Y5678MT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT7890M1234.5678S",
+ "-P1234Y5678M9012DT3456H1234.5678S",
+ "+P1234Y5678M9012DT3456H7890M",
+ "P123400000000000Y",
+ "-P567800000000000M",
+ "+P901200000000000D",
+ "P0DT345600000000000H",
+ "-P0DT789000000000000M",
+ "+P0DT123400000000000.000000000005678S",
+ "P1234YT1234.5678S",
+ "-P5678MT7890M",
+ "+P9012DT3456H",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPDuration, str)
+ end
+
+ targets = [
+ ["P0Y0M0DT0H0M0S",
+ "P0D"],
+ ["-P0DT0S",
+ "-P0D"],
+ ["P01234Y5678M9012DT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y005678M9012DT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M0009012DT3456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M9012DT00003456H7890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M9012DT3456H000007890M1234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ["P1234Y5678M9012DT3456H7890M0000001234.5678S",
+ "P1234Y5678M9012DT3456H7890M1234.5678S"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDuration.new(data).to_s)
+ end
+ end
+
+ def test_SOAPDateTime
+ o = SOAP::SOAPDateTime.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DateTimeLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002-05-18T16:52:20Z",
+ "0001-01-01T00:00:00Z",
+ "9999-12-31T23:59:59Z",
+ "19999-12-31T23:59:59Z",
+ "2002-12-31T23:59:59.999Z",
+ "2002-12-31T23:59:59.001Z",
+ "2002-12-31T23:59:59.99999999999999999999Z",
+ "2002-12-31T23:59:59.00000000000000000001Z",
+ "2002-12-31T23:59:59+09:00",
+ "2002-12-31T23:59:59+00:01",
+ "2002-12-31T23:59:59-00:01",
+ "2002-12-31T23:59:59-23:59",
+ "2002-12-31T23:59:59.00000000000000000001+13:30",
+ "2002-12-31T23:59:59.51375Z",
+ "2002-12-31T23:59:59.51345+12:34",
+ "-2002-05-18T16:52:20Z",
+ "-4711-12-31T23:59:59Z",
+ "-4713-01-01T12:00:00Z",
+ "-19999-12-31T23:59:59Z",
+ "-2002-12-31T23:59:59+00:01",
+ "-0001-12-31T23:59:59.00000000000000000001+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPDateTime, str)
+ end
+
+ targets = [
+ ["2002-12-31T23:59:59.00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59+00:00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59-00:00",
+ "2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59.00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59+00:00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59-00:00",
+ "-2002-12-31T23:59:59Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDateTime.new(data).to_s)
+ d = DateTime.parse(data)
+ d >>= 12 if d.year < 0 # XSDDateTime.year(-1) == DateTime.year(0)
+ assert_equal(expected, SOAP::SOAPDateTime.new(d).to_s)
+ end
+
+ targets = [
+ "1-05-18T16:52:20Z",
+ "05-18T16:52:20Z",
+ "2002-05T16:52:20Z",
+ "2002-05-18T16:52Z",
+ "",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError, d.to_s) do
+ SOAP::SOAPDateTime.new(d)
+ end
+ end
+ end
+
+ def test_SOAPTime
+ o = SOAP::SOAPTime.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::TimeLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "16:52:20Z",
+ "00:00:00Z",
+ "23:59:59Z",
+ "23:59:59.999Z",
+ "23:59:59.001Z",
+ "23:59:59.99999999999999999999Z",
+ "23:59:59.00000000000000000001Z",
+ "23:59:59+09:00",
+ "23:59:59+00:01",
+ "23:59:59-00:01",
+ "23:59:59-23:59",
+ "23:59:59.00000000000000000001+13:30",
+ "23:59:59.51375Z",
+ "23:59:59.51375+12:34",
+ "23:59:59+00:01",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPTime, str)
+ end
+
+ targets = [
+ ["23:59:59.00",
+ "23:59:59Z"],
+ ["23:59:59+00:00",
+ "23:59:59Z"],
+ ["23:59:59-00:00",
+ "23:59:59Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPTime.new(data).to_s)
+ end
+ end
+
+ def test_SOAPDate
+ o = SOAP::SOAPDate.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::DateLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002-05-18Z",
+ "0001-01-01Z",
+ "9999-12-31Z",
+ "19999-12-31Z",
+ "2002-12-31+09:00",
+ "2002-12-31+00:01",
+ "2002-12-31-00:01",
+ "2002-12-31-23:59",
+ "2002-12-31+13:30",
+ "-2002-05-18Z",
+ "-19999-12-31Z",
+ "-2002-12-31+00:01",
+ "-0001-12-31+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPDate, str)
+ end
+
+ targets = [
+ ["2002-12-31",
+ "2002-12-31Z"],
+ ["2002-12-31+00:00",
+ "2002-12-31Z"],
+ ["2002-12-31-00:00",
+ "2002-12-31Z"],
+ ["-2002-12-31",
+ "-2002-12-31Z"],
+ ["-2002-12-31+00:00",
+ "-2002-12-31Z"],
+ ["-2002-12-31-00:00",
+ "-2002-12-31Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPDate.new(data).to_s)
+ d = Date.parse(data)
+ d >>= 12 if d.year < 0 # XSDDate.year(-1) == Date.year(0)
+ assert_equal(expected, SOAP::SOAPDate.new(d).to_s)
+ end
+ end
+
+ def test_SOAPGYearMonth
+ o = SOAP::SOAPGYearMonth.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GYearMonthLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002-05Z",
+ "0001-01Z",
+ "9999-12Z",
+ "19999-12Z",
+ "2002-12+09:00",
+ "2002-12+00:01",
+ "2002-12-00:01",
+ "2002-12-23:59",
+ "2002-12+13:30",
+ "-2002-05Z",
+ "-19999-12Z",
+ "-2002-12+00:01",
+ "-0001-12+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGYearMonth, str)
+ end
+
+ targets = [
+ ["2002-12",
+ "2002-12Z"],
+ ["2002-12+00:00",
+ "2002-12Z"],
+ ["2002-12-00:00",
+ "2002-12Z"],
+ ["-2002-12",
+ "-2002-12Z"],
+ ["-2002-12+00:00",
+ "-2002-12Z"],
+ ["-2002-12-00:00",
+ "-2002-12Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGYearMonth.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGYear
+ o = SOAP::SOAPGYear.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GYearLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "2002Z",
+ "0001Z",
+ "9999Z",
+ "19999Z",
+ "2002+09:00",
+ "2002+00:01",
+ "2002-00:01",
+ "2002-23:59",
+ "2002+13:30",
+ "-2002Z",
+ "-19999Z",
+ "-2002+00:01",
+ "-0001+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGYear, str)
+ end
+
+ targets = [
+ ["2002",
+ "2002Z"],
+ ["2002+00:00",
+ "2002Z"],
+ ["2002-00:00",
+ "2002Z"],
+ ["-2002",
+ "-2002Z"],
+ ["-2002+00:00",
+ "-2002Z"],
+ ["-2002-00:00",
+ "-2002Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGYear.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGMonthDay
+ o = SOAP::SOAPGMonthDay.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GMonthDayLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "05-18Z",
+ "01-01Z",
+ "12-31Z",
+ "12-31+09:00",
+ "12-31+00:01",
+ "12-31-00:01",
+ "12-31-23:59",
+ "12-31+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGMonthDay, str)
+ end
+
+ targets = [
+ ["12-31",
+ "12-31Z"],
+ ["12-31+00:00",
+ "12-31Z"],
+ ["12-31-00:00",
+ "12-31Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGMonthDay.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGDay
+ o = SOAP::SOAPGDay.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GDayLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "18Z",
+ "01Z",
+ "31Z",
+ "31+09:00",
+ "31+00:01",
+ "31-00:01",
+ "31-23:59",
+ "31+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGDay, str)
+ end
+
+ targets = [
+ ["31",
+ "31Z"],
+ ["31+00:00",
+ "31Z"],
+ ["31-00:00",
+ "31Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGDay.new(data).to_s)
+ end
+ end
+
+ def test_SOAPGMonth
+ o = SOAP::SOAPGMonth.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::GMonthLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "05Z",
+ "01Z",
+ "12Z",
+ "12+09:00",
+ "12+00:01",
+ "12-00:01",
+ "12-23:59",
+ "12+13:30",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPGMonth, str)
+ end
+
+ targets = [
+ ["12",
+ "12Z"],
+ ["12+00:00",
+ "12Z"],
+ ["12-00:00",
+ "12Z"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPGMonth.new(data).to_s)
+ end
+ end
+
+ def test_SOAPHexBinary
+ o = SOAP::SOAPHexBinary.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::HexBinaryLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "abcdef",
+ "\xe3\x81\xaa\xe3\x81\xb2",
+ "\0",
+ "",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPHexBinary.new(str).string)
+ assert_equal(str.unpack("H*")[0].tr('a-f', 'A-F'),
+ SOAP::SOAPHexBinary.new(str).data)
+ o = SOAP::SOAPHexBinary.new
+ o.set_encoded(str.unpack("H*")[0].tr('a-f', 'A-F'))
+ assert_equal(str, o.string)
+ o.set_encoded(str.unpack("H*")[0].tr('A-F', 'a-f'))
+ assert_equal(str, o.string)
+ end
+
+ targets = [
+ "0FG7",
+ "0fg7",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError, d.to_s) do
+ o = SOAP::SOAPHexBinary.new
+ o.set_encoded(d)
+ p o.string
+ end
+ end
+ end
+
+ def test_SOAPBase64Binary
+ o = SOAP::SOAPBase64.new
+ assert_equal(SOAP::EncodingNamespace, o.type.namespace)
+ assert_equal(SOAP::Base64Literal, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ "abcdef",
+ "\xe3\x81\xaa\xe3\x81\xb2",
+ "\0",
+ "",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPBase64.new(str).string)
+ assert_equal([str].pack("m").chomp, SOAP::SOAPBase64.new(str).data)
+ o = SOAP::SOAPBase64.new
+ o.set_encoded([str].pack("m").chomp)
+ assert_equal(str, o.string)
+ end
+
+ targets = [
+ "-",
+ "*",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError, d.to_s) do
+ o = SOAP::SOAPBase64.new
+ o.set_encoded(d)
+ p o.string
+ end
+ end
+ end
+
+ def test_SOAPAnyURI
+ o = SOAP::SOAPAnyURI.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::AnyURILiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ # Too few tests here I know. Believe uri module. :)
+ targets = [
+ "foo",
+ "http://foo",
+ "http://foo/bar/baz",
+ "http://foo/bar#baz",
+ "http://foo/bar%20%20?a+b",
+ "HTTP://FOO/BAR%20%20?A+B",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPAnyURI, str)
+ end
+ end
+
+ def test_SOAPQName
+ o = SOAP::SOAPQName.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::QNameLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ # More strict test is needed but current implementation allows all non-':'
+ # chars like ' ', C0 or C1...
+ targets = [
+ "foo",
+ "foo:bar",
+ "a:b",
+ ]
+ targets.each do |str|
+ assert_parsed_result(SOAP::SOAPQName, str)
+ end
+ end
+
+
+ ###
+ ## Derived types
+ #
+
+ def test_SOAPInteger
+ o = SOAP::SOAPInteger.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::IntegerLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 1000000000,
+ -9999999999,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,
+ -1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789,
+ ]
+ targets.each do |int|
+ assert_equal(int, SOAP::SOAPInteger.new(int).data)
+ end
+
+ targets = [
+ "0",
+ "1000000000",
+ "-9999999999",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "-1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPInteger.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["000123", "123"],
+ ["-000123", "-123"],
+ [
+ "+12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ ],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPInteger.new(data).to_s)
+ end
+
+ targets = [
+ "0.0",
+ "-5.2",
+ "0.000000000000a",
+ "+-5",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890."
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPInteger.new(d)
+ end
+ end
+ end
+
+ def test_SOAPLong
+ o = SOAP::SOAPLong.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::LongLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 123,
+ -123,
+ 9223372036854775807,
+ -9223372036854775808,
+ ]
+ targets.each do |lng|
+ assert_equal(lng, SOAP::SOAPLong.new(lng).data)
+ end
+
+ targets = [
+ "0",
+ "123",
+ "-123",
+ "9223372036854775807",
+ "-9223372036854775808",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPLong.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["000123", "123"],
+ ["-000123", "-123"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPLong.new(data).to_s)
+ end
+
+ targets = [
+ 9223372036854775808,
+ -9223372036854775809,
+ "0.0",
+ "-5.2",
+ "0.000000000000a",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPLong.new(d)
+ end
+ end
+ end
+
+ def test_SOAPInt
+ o = SOAP::SOAPInt.new
+ assert_equal(XSD::Namespace, o.type.namespace)
+ assert_equal(XSD::IntLiteral, o.type.name)
+ assert_equal(nil, o.data)
+ assert_equal(true, o.is_nil)
+
+ targets = [
+ 0,
+ 123,
+ -123,
+ 2147483647,
+ -2147483648,
+ ]
+ targets.each do |lng|
+ assert_equal(lng, SOAP::SOAPInt.new(lng).data)
+ end
+
+ targets = [
+ "0",
+ "123",
+ "-123",
+ "2147483647",
+ "-2147483648",
+ ]
+ targets.each do |str|
+ assert_equal(str, SOAP::SOAPInt.new(str).to_s)
+ end
+
+ targets = [
+ ["-0", "0"],
+ ["+0", "0"],
+ ["000123", "123"],
+ ["-000123", "-123"],
+ ]
+ targets.each do |data, expected|
+ assert_equal(expected, SOAP::SOAPInt.new(data).to_s)
+ end
+
+ targets = [
+ 2147483648,
+ -2147483649,
+ "0.0",
+ "-5.2",
+ "0.000000000000a",
+ "+-5",
+ ]
+ targets.each do |d|
+ assert_raises(XSD::ValueSpaceError) do
+ SOAP::SOAPInt.new(d)
+ end
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/test_envelopenamespace.rb b/ruby_1_8_5/test/soap/test_envelopenamespace.rb
new file mode 100644
index 0000000000..5b7d281341
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_envelopenamespace.rb
@@ -0,0 +1,92 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'webrick'
+require 'logger'
+
+
+module SOAP
+
+
+class TestEnvelopeNamespace < Test::Unit::TestCase
+ Port = 17171
+ TemporaryNamespace = 'urn:foo'
+
+ def setup
+ @logger = Logger.new(STDERR)
+ @logger.level = Logger::Severity::ERROR
+ @url = "http://localhost:#{Port}/"
+ @server = @client = nil
+ @server_thread = nil
+ setup_server
+ setup_client
+ end
+
+ def teardown
+ teardown_client
+ teardown_server
+ end
+
+ def setup_server
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => @logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__))
+ )
+ @server.mount(
+ '/',
+ WEBrick::HTTPServlet::ProcHandler.new(method(:do_server_proc).to_proc)
+ )
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@url, '')
+ @client.add_method("do_server_proc")
+ 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 do_server_proc(req, res)
+ res['content-type'] = 'text/xml'
+ res.body = <<__EOX__
+<?xml version="1.0" encoding="utf-8" ?>
+<env:Envelope xmlns:env="#{TemporaryNamespace}">
+ <env:Body>
+ <n1:do_server_proc xmlns:n1="urn:foo" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <return>hello world</return>
+ </n1:do_server_proc>
+ </env:Body>
+</env:Envelope>
+__EOX__
+ end
+
+ def test_normal
+ assert_raise(SOAP::ResponseFormatError) do
+ @client.do_server_proc
+ end
+ @client.options["soap.envelope.requestnamespace"] = TemporaryNamespace
+ @client.options["soap.envelope.responsenamespace"] = TemporaryNamespace
+ assert_equal('hello world', @client.do_server_proc)
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/test_httpconfigloader.rb b/ruby_1_8_5/test/soap/test_httpconfigloader.rb
new file mode 100644
index 0000000000..b06243f661
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_httpconfigloader.rb
@@ -0,0 +1,39 @@
+require 'test/unit'
+require 'soap/httpconfigloader'
+require 'soap/rpc/driver'
+
+if defined?(HTTPAccess2)
+
+module SOAP
+
+
+class TestHTTPConfigLoader < Test::Unit::TestCase
+ DIR = File.dirname(File.expand_path(__FILE__))
+
+ def setup
+ @client = SOAP::RPC::Driver.new(nil, nil)
+ end
+
+ def test_property
+ testpropertyname = File.join(DIR, 'soapclient.properties')
+ File.open(testpropertyname, "w") do |f|
+ f <<<<__EOP__
+protocol.http.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_PEER
+# depth: 1 causes an error (intentional)
+protocol.http.ssl_config.verify_depth = 1
+protocol.http.ssl_config.ciphers = ALL
+__EOP__
+ end
+ begin
+ @client.loadproperty(testpropertyname)
+ assert_equal('ALL', @client.options['protocol.http.ssl_config.ciphers'])
+ ensure
+ File.unlink(testpropertyname)
+ end
+ end
+end
+
+
+end
+
+end
diff --git a/ruby_1_8_5/test/soap/test_mapping.rb b/ruby_1_8_5/test/soap/test_mapping.rb
new file mode 100644
index 0000000000..26222e6719
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_mapping.rb
@@ -0,0 +1,59 @@
+require 'test/unit'
+require 'soap/mapping'
+
+
+module SOAP
+
+
+class TestMapping < Test::Unit::TestCase
+ def test_date
+ targets = [
+ ["2002-12-31",
+ "2002-12-31Z"],
+ ["2002-12-31+00:00",
+ "2002-12-31Z"],
+ ["2002-12-31-00:00",
+ "2002-12-31Z"],
+ ["-2002-12-31",
+ "-2002-12-31Z"],
+ ["-2002-12-31+00:00",
+ "-2002-12-31Z"],
+ ["-2002-12-31-00:00",
+ "-2002-12-31Z"],
+ ]
+ targets.each do |str, expectec|
+ d = Date.parse(str)
+ assert_equal(d.class, convert(d).class)
+ assert_equal(d, convert(d))
+ end
+ end
+
+ def test_datetime
+ targets = [
+ ["2002-12-31T23:59:59.00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59+00:00",
+ "2002-12-31T23:59:59Z"],
+ ["2002-12-31T23:59:59-00:00",
+ "2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59.00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59+00:00",
+ "-2002-12-31T23:59:59Z"],
+ ["-2002-12-31T23:59:59-00:00",
+ "-2002-12-31T23:59:59Z"],
+ ]
+ targets.each do |str, expectec|
+ d = DateTime.parse(str)
+ assert_equal(d.class, convert(d).class)
+ assert_equal(d, convert(d))
+ end
+ end
+
+ def convert(obj)
+ SOAP::Mapping.soap2obj(SOAP::Mapping.obj2soap(obj))
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/test_no_indent.rb b/ruby_1_8_5/test/soap/test_no_indent.rb
new file mode 100644
index 0000000000..f49fb7389f
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_no_indent.rb
@@ -0,0 +1,86 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/rpc/driver'
+
+if defined?(HTTPAccess2)
+
+module SOAP
+
+
+class TestNoIndent < Test::Unit::TestCase
+ Port = 17171
+
+ class NopServer < SOAP::RPC::StandaloneServer
+ def initialize(*arg)
+ super
+ add_rpc_method(self, 'nop')
+ end
+
+ def nop
+ SOAP::RPC::SOAPVoid.new
+ end
+ end
+
+ def setup
+ @server = NopServer.new(self.class.name, nil, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @t = Thread.new {
+ @server.start
+ }
+ @endpoint = "http://localhost:#{Port}/"
+ @client = SOAP::RPC::Driver.new(@endpoint)
+ @client.add_rpc_method('nop')
+ end
+
+ def teardown
+ @server.shutdown
+ @t.kill
+ @t.join
+ @client.reset_stream
+ end
+
+ INDENT_XML =
+%q[<?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>
+ <nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ </nop>
+ </env:Body>
+</env:Envelope>]
+
+ NO_INDENT_XML =
+%q[<?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>
+<nop env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+</nop>
+</env:Body>
+</env:Envelope>]
+
+ def test_indent
+ @client.wiredump_dev = str = ''
+ @client.options["soap.envelope.no_indent"] = false
+ @client.nop
+ assert_equal(INDENT_XML, parse_requestxml(str))
+ end
+
+ def test_no_indent
+ @client.wiredump_dev = str = ''
+ @client.options["soap.envelope.no_indent"] = true
+ @client.nop
+ assert_equal(NO_INDENT_XML, parse_requestxml(str))
+ end
+
+ def parse_requestxml(str)
+ str.split(/\r?\n\r?\n/)[3]
+ end
+end
+
+
+end
+
+end
diff --git a/ruby_1_8_5/test/soap/test_property.rb b/ruby_1_8_5/test/soap/test_property.rb
new file mode 100644
index 0000000000..7acd2c8437
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_property.rb
@@ -0,0 +1,424 @@
+require 'test/unit'
+require 'soap/property'
+
+
+module SOAP
+
+
+class TestProperty < Test::Unit::TestCase
+ FrozenError = (RUBY_VERSION >= "1.9.0") ? RuntimeError : TypeError
+
+ def setup
+ @prop = ::SOAP::Property.new
+ end
+
+ def teardown
+ # Nothing to do.
+ end
+
+ def test_s_load
+ propstr = <<__EOP__
+
+# comment1
+
+# comment2\r
+# comment2
+
+\r
+a.b.0 = 1
+a.b.1 = 2
+a.b.2 = 3
+client.protocol.http.proxy=http://myproxy:8080 \r
+client.protocol.http.no_proxy: intranet.example.com,local.example.com\r
+client.protocol.http.protocol_version = 1.0
+foo\\:bar\\=baz = qux
+foo\\\\.bar.baz=\tq\\\\ux\ttab
+ a\\ b = 1
+[ppp.qqq.rrr]
+sss = 3
+ttt.uuu = 4
+
+[ sss.ttt.uuu ]
+vvv.www = 5
+[ ]
+xxx.yyy.zzz = 6
+__EOP__
+ prop = Property.load(propstr)
+ assert_equal(["1", "2", "3"], prop["a.b"].values.sort)
+ assert_equal("intranet.example.com,local.example.com",
+ prop["client.protocol.http.no_proxy"])
+ assert_equal("http://myproxy:8080", prop["client.protocol.http.proxy"])
+ assert_equal("1.0", prop["client.protocol.http.protocol_version"])
+ assert_equal("q\\ux\ttab", prop['foo\.bar.baz'])
+ assert_equal("1", prop['a b'])
+ assert_equal("3", prop['ppp.qqq.rrr.sss'])
+ assert_equal("4", prop['ppp.qqq.rrr.ttt.uuu'])
+ assert_equal("5", prop['sss.ttt.uuu.vvv.www'])
+ assert_equal("6", prop['xxx.yyy.zzz'])
+ end
+
+ def test_load
+ prop = Property.new
+ hooked = false
+ prop.add_hook("foo.bar.baz") do |name, value|
+ assert_equal(["foo", "bar", "baz"], name)
+ assert_equal("123", value)
+ hooked = true
+ end
+ prop.lock
+ prop["foo.bar"].lock
+ prop.load("foo.bar.baz = 123")
+ assert(hooked)
+ assert_raises(FrozenError) do
+ prop.load("foo.bar.qux = 123")
+ end
+ prop.load("foo.baz = 456")
+ assert_equal("456", prop["foo.baz"])
+ end
+
+ def test_initialize
+ prop = ::SOAP::Property.new
+ # store is empty
+ assert_nil(prop["a"])
+ # does hook work?
+ assert_equal(1, prop["a"] = 1)
+ end
+
+ def test_aref
+ # name_to_a
+ assert_nil(@prop[:foo])
+ assert_nil(@prop["foo"])
+ assert_nil(@prop[[:foo]])
+ assert_nil(@prop[["foo"]])
+ assert_raises(ArgumentError) do
+ @prop[1]
+ end
+ @prop[:foo] = :foo
+ assert_equal(:foo, @prop[:foo])
+ assert_equal(:foo, @prop["foo"])
+ assert_equal(:foo, @prop[[:foo]])
+ assert_equal(:foo, @prop[["foo"]])
+ end
+
+ def test_referent
+ # referent(1)
+ assert_nil(@prop["foo.foo"])
+ assert_nil(@prop[["foo", "foo"]])
+ assert_nil(@prop[["foo", :foo]])
+ @prop["foo.foo"] = :foo
+ assert_equal(:foo, @prop["foo.foo"])
+ assert_equal(:foo, @prop[["foo", "foo"]])
+ assert_equal(:foo, @prop[[:foo, "foo"]])
+ # referent(2)
+ @prop["bar.bar.bar"] = :bar
+ assert_equal(:bar, @prop["bar.bar.bar"])
+ assert_equal(:bar, @prop[["bar", "bar", "bar"]])
+ assert_equal(:bar, @prop[[:bar, "bar", :bar]])
+ end
+
+ def test_to_key_and_deref
+ @prop["foo.foo"] = :foo
+ assert_equal(:foo, @prop["fOo.FoO"])
+ assert_equal(:foo, @prop[[:fOO, :FOO]])
+ assert_equal(:foo, @prop[["FoO", :Foo]])
+ # deref_key negative test
+ assert_raises(ArgumentError) do
+ @prop["baz"] = 1
+ @prop["baz.qux"] = 2
+ end
+ end
+
+ def test_hook_name
+ tag = Object.new
+ tested = false
+ @prop.add_hook("foo.bar") do |key, value|
+ assert_raise(FrozenError) do
+ key << "baz"
+ end
+ tested = true
+ end
+ @prop["foo.bar"] = tag
+ assert(tested)
+ end
+
+ def test_value_hook
+ tag = Object.new
+ tested = false
+ @prop.add_hook("FOO.BAR.BAZ") do |key, value|
+ assert_equal(["Foo", "baR", "baZ"], key)
+ assert_equal(tag, value)
+ tested = true
+ end
+ @prop["Foo.baR.baZ"] = tag
+ assert_equal(tag, @prop["foo.bar.baz"])
+ assert(tested)
+ @prop["foo.bar"] = 1 # unhook the above block
+ assert_equal(1, @prop["foo.bar"])
+ end
+
+ def test_key_hook_no_cascade
+ tag = Object.new
+ tested = 0
+ @prop.add_hook do |key, value|
+ assert(false)
+ end
+ @prop.add_hook(false) do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo") do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar", false) do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar.baz") do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar.baz.qux", false) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop["foo.bar.baz.qux"] = tag
+ assert_equal(tag, @prop["foo.bar.baz.qux"])
+ assert_equal(1, tested)
+ end
+
+ def test_key_hook_cascade
+ tag = Object.new
+ tested = 0
+ @prop.add_hook(true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar.baz", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar.baz.qux", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop["foo.bar.baz.qux"] = tag
+ assert_equal(tag, @prop["foo.bar.baz.qux"])
+ assert_equal(5, tested)
+ end
+
+ def test_keys
+ assert(@prop.keys.empty?)
+ @prop["foo"] = 1
+ @prop["bar"]
+ @prop["BAz"] = 2
+ assert_equal(2, @prop.keys.size)
+ assert(@prop.keys.member?("foo"))
+ assert(@prop.keys.member?("baz"))
+ #
+ assert_nil(@prop["a"])
+ @prop["a.a"] = 1
+ assert_instance_of(::SOAP::Property, @prop["a"])
+ @prop["a.b"] = 1
+ @prop["a.c"] = 1
+ assert_equal(3, @prop["a"].keys.size)
+ assert(@prop["a"].keys.member?("a"))
+ assert(@prop["a"].keys.member?("b"))
+ assert(@prop["a"].keys.member?("c"))
+ end
+
+ def test_lshift
+ assert(@prop.empty?)
+ @prop << 1
+ assert_equal([1], @prop.values)
+ assert_equal(1, @prop["0"])
+ @prop << 1
+ assert_equal([1, 1], @prop.values)
+ assert_equal(1, @prop["1"])
+ @prop << 1
+ assert_equal([1, 1, 1], @prop.values)
+ assert_equal(1, @prop["2"])
+ #
+ @prop["abc.def"] = o = SOAP::Property.new
+ tested = 0
+ o.add_hook do |k, v|
+ tested += 1
+ end
+ @prop["abc.def"] << 1
+ @prop["abc.def"] << 2
+ @prop["abc.def"] << 3
+ @prop["abc.def"] << 4
+ assert_equal(4, tested)
+ end
+
+ def test_lock_each
+ @prop["a.b.c.d.e"] = 1
+ @prop["a.b.d"] = branch = ::SOAP::Property.new
+ @prop["a.b.d.e.f"] = 2
+ @prop.lock
+ assert(@prop.locked?)
+ assert_instance_of(::SOAP::Property, @prop["a"])
+ assert_raises(FrozenError) do
+ @prop["b"]
+ end
+ #
+ @prop["a"].lock
+ assert_raises(FrozenError) do
+ @prop["a"]
+ end
+ assert_instance_of(::SOAP::Property, @prop["a.b"])
+ #
+ @prop["a.b"].lock
+ assert_raises(FrozenError) do
+ @prop["a.b"]
+ end
+ assert_raises(FrozenError) do
+ @prop["a"]
+ end
+ #
+ @prop["a.b.c.d"].lock
+ assert_instance_of(::SOAP::Property, @prop["a.b.c"])
+ assert_raises(FrozenError) do
+ @prop["a.b.c.d"]
+ end
+ assert_instance_of(::SOAP::Property, @prop["a.b.d"])
+ #
+ branch["e"].lock
+ assert_instance_of(::SOAP::Property, @prop["a.b.d"])
+ assert_raises(FrozenError) do
+ @prop["a.b.d.e"]
+ end
+ assert_raises(FrozenError) do
+ branch["e"]
+ end
+ end
+
+ def test_lock_cascade
+ @prop["a.a"] = nil
+ @prop["a.b.c"] = 1
+ @prop["b"] = false
+ @prop.lock(true)
+ assert(@prop.locked?)
+ assert_equal(nil, @prop["a.a"])
+ assert_equal(1, @prop["a.b.c"])
+ assert_equal(false, @prop["b"])
+ assert_raises(FrozenError) do
+ @prop["c"]
+ end
+ assert_raises(FrozenError) do
+ @prop["c"] = 2
+ end
+ assert_raises(FrozenError) do
+ @prop["a.b.R"]
+ end
+ assert_raises(FrozenError) do
+ @prop.add_hook do
+ assert(false)
+ end
+ end
+ assert_raises(FrozenError) do
+ @prop.add_hook("c") do
+ assert(false)
+ end
+ end
+ assert_raises(FrozenError) do
+ @prop.add_hook("a.c") do
+ assert(false)
+ end
+ end
+ assert_nil(@prop["a.a"])
+ @prop["a.a"] = 2
+ assert_equal(2, @prop["a.a"])
+ #
+ @prop.unlock(true)
+ assert_nil(@prop["c"])
+ @prop["c"] = 2
+ assert_equal(2, @prop["c"])
+ @prop["a.d.a.a"] = :foo
+ assert_equal(:foo, @prop["a.d.a.a"])
+ tested = false
+ @prop.add_hook("a.c") do |name, value|
+ assert(true)
+ tested = true
+ end
+ @prop["a.c"] = 3
+ assert(tested)
+ end
+
+ def test_hook_then_lock
+ tested = false
+ @prop.add_hook("a.b.c") do |name, value|
+ assert_equal(["a", "b", "c"], name)
+ tested = true
+ end
+ @prop["a.b"].lock
+ assert(!tested)
+ @prop["a.b.c"] = 5
+ assert(tested)
+ assert_equal(5, @prop["a.b.c"])
+ assert_raises(FrozenError) do
+ @prop["a.b.d"] = 5
+ end
+ end
+
+ def test_lock_unlock_return
+ assert_equal(@prop, @prop.lock)
+ assert_equal(@prop, @prop.unlock)
+ end
+
+ def test_lock_split
+ @prop["a.b.c"] = 1
+ assert_instance_of(::SOAP::Property, @prop["a.b"])
+ @prop["a.b.d"] = branch = ::SOAP::Property.new
+ @prop["a.b.d.e"] = 2
+ assert_equal(branch, @prop["a.b.d"])
+ assert_equal(branch, @prop[:a][:b][:d])
+ @prop.lock(true)
+ # split error 1
+ assert_raises(FrozenError) do
+ @prop["a.b"]
+ end
+ # split error 2
+ assert_raises(FrozenError) do
+ @prop["a"]
+ end
+ @prop["a.b.c"] = 2
+ assert_equal(2, @prop["a.b.c"])
+ # replace error
+ assert_raises(FrozenError) do
+ @prop["a.b.c"] = ::SOAP::Property.new
+ end
+ # override error
+ assert_raises(FrozenError) do
+ @prop["a.b"] = 1
+ end
+ #
+ assert_raises(FrozenError) do
+ @prop["a.b.d"] << 1
+ end
+ assert_raises(FrozenError) do
+ branch << 1
+ end
+ branch.unlock(true)
+ branch << 1
+ branch << 2
+ branch << 3
+ assert_equal(2, @prop["a.b.d.e"])
+ assert_equal(1, @prop["a.b.d.1"])
+ assert_equal(2, @prop["a.b.d.2"])
+ assert_equal(3, @prop["a.b.d.3"])
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/test_soapelement.rb b/ruby_1_8_5/test/soap/test_soapelement.rb
new file mode 100644
index 0000000000..66e2a836a4
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_soapelement.rb
@@ -0,0 +1,122 @@
+require 'test/unit'
+require 'soap/baseData'
+require 'soap/mapping'
+
+
+module SOAP
+
+
+class TestSOAPElement < Test::Unit::TestCase
+ include SOAP
+
+ def setup
+ # Nothing to do.
+ end
+
+ def teardown
+ # Nothing to do.
+ end
+
+ def d(elename = nil, text = nil)
+ elename ||= n(nil, nil)
+ if text
+ SOAPElement.new(elename, text)
+ else
+ SOAPElement.new(elename) # do not merge.
+ end
+ end
+
+ def n(namespace, name)
+ XSD::QName.new(namespace, name)
+ end
+
+ def test_initialize
+ elename = n(nil, nil)
+ obj = d(elename)
+ assert_equal(elename, obj.elename)
+ assert_equal(LiteralNamespace, obj.encodingstyle)
+ assert_equal({}, obj.extraattr)
+ assert_equal([], obj.precedents)
+ assert_equal(nil, obj.qualified)
+ assert_equal(nil, obj.text)
+ assert(obj.members.empty?)
+
+ obj = d("foo", "text")
+ assert_equal(n(nil, "foo"), obj.elename)
+ assert_equal("text", obj.text)
+ end
+
+ def test_add
+ obj = d()
+ child = d("abc")
+ obj.add(child)
+ assert(obj.key?("abc"))
+ assert_same(child, obj["abc"])
+ assert_same(child, obj.abc)
+ def obj.foo; 1; end
+ child = d("foo")
+ obj.add(child)
+ assert_equal(1, obj.foo)
+ assert_equal(child, obj.var_foo)
+ child = d("_?a?b_")
+ obj.add(child)
+ assert_equal(child, obj.__send__('_?a?b_'))
+ end
+
+ def test_member
+ obj = d()
+ c1 = d("c1")
+ obj.add(c1)
+ c2 = d("c2")
+ obj.add(c2)
+ assert(obj.key?("c1"))
+ assert(obj.key?("c2"))
+ assert_equal(c1, obj["c1"])
+ assert_equal(c2, obj["c2"])
+ c22 = d("c22")
+ obj["c2"] = c22
+ assert(obj.key?("c2"))
+ assert_equal(c22, obj["c2"])
+ assert_equal(["c1", "c2"], obj.members.sort)
+ #
+ k_expect = ["c1", "c2"]
+ v_expect = [c1, c22]
+ obj.each do |k, v|
+ assert(k_expect.include?(k))
+ assert(v_expect.include?(v))
+ k_expect.delete(k)
+ v_expect.delete(v)
+ end
+ assert(k_expect.empty?)
+ assert(v_expect.empty?)
+ end
+
+ def test_to_obj
+ obj = d("root")
+ ct1 = d("ct1", "t1")
+ obj.add(ct1)
+ c2 = d("c2")
+ ct2 = d("ct2", "t2")
+ c2.add(ct2)
+ obj.add(c2)
+ assert_equal({ "ct1" => "t1", "c2" => { "ct2" => "t2" }}, obj.to_obj)
+ #
+ assert_equal(nil, d().to_obj)
+ assert_equal("abc", d(nil, "abc").to_obj)
+ assert_equal(nil, d("abc", nil).to_obj)
+ end
+
+ def test_from_obj
+ source = { "ct1" => "t1", "c2" => { "ct2" => "t2" }}
+ assert_equal(source, SOAPElement.from_obj(source).to_obj)
+ source = { "1" => nil }
+ assert_equal(source, SOAPElement.from_obj(source).to_obj)
+ source = {}
+ assert_equal(nil, SOAPElement.from_obj(source).to_obj) # not {}
+ source = nil
+ assert_equal(nil, SOAPElement.from_obj(source).to_obj)
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/test_streamhandler.rb b/ruby_1_8_5/test/soap/test_streamhandler.rb
new file mode 100644
index 0000000000..c31254513f
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_streamhandler.rb
@@ -0,0 +1,209 @@
+require 'test/unit'
+require 'soap/rpc/driver'
+require 'webrick'
+require 'webrick/httpproxy'
+require 'logger'
+
+
+module SOAP
+
+
+class TestStreamHandler < Test::Unit::TestCase
+ Port = 17171
+ ProxyPort = 17172
+
+ def setup
+ @logger = Logger.new(STDERR)
+ @logger.level = Logger::Severity::ERROR
+ @url = "http://localhost:#{Port}/"
+ @proxyurl = "http://localhost:#{ProxyPort}/"
+ @server = @proxyserver = @client = nil
+ @server_thread = @proxyserver_thread = nil
+ setup_server
+ setup_client
+ end
+
+ def teardown
+ teardown_client
+ teardown_proxyserver if @proxyserver
+ teardown_server
+ end
+
+ def setup_server
+ @server = WEBrick::HTTPServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => @logger,
+ :Port => Port,
+ :AccessLog => [],
+ :DocumentRoot => File.dirname(File.expand_path(__FILE__))
+ )
+ @server.mount(
+ '/',
+ WEBrick::HTTPServlet::ProcHandler.new(method(:do_server_proc).to_proc)
+ )
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_proxyserver
+ @proxyserver = WEBrick::HTTPProxyServer.new(
+ :BindAddress => "0.0.0.0",
+ :Logger => @logger,
+ :Port => ProxyPort,
+ :AccessLog => []
+ )
+ @proxyserver_thread = start_server_thread(@proxyserver)
+ end
+
+ def setup_client
+ @client = SOAP::RPC::Driver.new(@url, '')
+ @client.add_method("do_server_proc")
+ end
+
+ def teardown_server
+ @server.shutdown
+ @server_thread.kill
+ @server_thread.join
+ end
+
+ def teardown_proxyserver
+ @proxyserver.shutdown
+ @proxyserver_thread.kill
+ @proxyserver_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 do_server_proc(req, res)
+ res['content-type'] = 'text/xml'
+ res.body = <<__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>
+ <n1:do_server_proc xmlns:n1="urn:foo" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
+ <return xsi:nil="true"/>
+ </n1:do_server_proc>
+ </env:Body>
+</env:Envelope>
+__EOX__
+ end
+
+ def parse_req_header(str)
+ if ::SOAP::HTTPStreamHandler::Client.to_s == 'SOAP::NetHttpClient'
+ str = eval(str.split(/\r?\n/)[4][3..-1])
+ end
+ parse_req_header_http_access2(str)
+ end
+
+ def parse_req_header_http_access2(str)
+ headerp = false
+ headers = {}
+ req = nil
+ str.split(/(?:\r?\n)/).each do |line|
+ if headerp and /^$/ =~line
+ headerp = false
+ break
+ end
+ if headerp
+ k, v = line.scan(/^([^:]+):\s*(.*)$/)[0]
+ headers[k.downcase] = v
+ end
+ if /^POST/ =~ line
+ req = line
+ headerp = true
+ end
+ end
+ return req, headers
+ end
+
+ def test_normal
+ str = ""
+ @client.wiredump_dev = str
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_match(%r"POST / HTTP/1.", r)
+ assert(/^text\/xml;/ =~ h["content-type"])
+ end
+
+ def test_uri
+ # initialize client with URI object
+ @client = SOAP::RPC::Driver.new(URI.parse(@url), '')
+ @client.add_method("do_server_proc")
+ # same as test_normal
+ str = ""
+ @client.wiredump_dev = str
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_match(%r"POST / HTTP/1.", r)
+ assert(/^text\/xml;/ =~ h["content-type"])
+ end
+
+ def test_basic_auth
+ unless Object.const_defined?('HTTPAccess2')
+ # soap4r + net/http + basic_auth is not supported.
+ # use http-access2 instead.
+ assert(true)
+ return
+ end
+ str = ""
+ @client.wiredump_dev = str
+ @client.options["protocol.http.basic_auth"] << [@url, "foo", "bar"]
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_equal("Basic Zm9vOmJhcg==", h["authorization"])
+ end
+
+ def test_proxy
+ if Object.const_defined?('HTTPAccess2')
+ backup = HTTPAccess2::Client::NO_PROXY_HOSTS.dup
+ HTTPAccess2::Client::NO_PROXY_HOSTS.clear
+ else
+ backup = SOAP::NetHttpClient::NO_PROXY_HOSTS.dup
+ SOAP::NetHttpClient::NO_PROXY_HOSTS.clear
+ end
+ setup_proxyserver
+ str = ""
+ @client.wiredump_dev = str
+ @client.options["protocol.http.proxy"] = @proxyurl
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_match(%r"POST http://localhost:17171/ HTTP/1.", r)
+ # illegal proxy uri
+ assert_raise(ArgumentError) do
+ @client.options["protocol.http.proxy"] = 'ftp://foo:8080'
+ end
+ ensure
+ if Object.const_defined?('HTTPAccess2')
+ HTTPAccess2::Client::NO_PROXY_HOSTS.replace(backup)
+ else
+ SOAP::NetHttpClient::NO_PROXY_HOSTS.replace(backup)
+ end
+ end
+
+ def test_charset
+ str = ""
+ @client.wiredump_dev = str
+ @client.options["protocol.http.charset"] = "iso-8859-8"
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_equal("text/xml; charset=iso-8859-8", h["content-type"])
+ #
+ str.replace("")
+ @client.options["protocol.http.charset"] = "iso-8859-3"
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_equal("text/xml; charset=iso-8859-3", h["content-type"])
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/test_styleuse.rb b/ruby_1_8_5/test/soap/test_styleuse.rb
new file mode 100644
index 0000000000..4ea321848d
--- /dev/null
+++ b/ruby_1_8_5/test/soap/test_styleuse.rb
@@ -0,0 +1,333 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/rpc/driver'
+
+
+module SOAP
+
+
+class TestStyleUse < Test::Unit::TestCase
+ # rpc driver: obj in(Hash allowed for literal), obj out
+ #
+ # style: not visible from user
+ # rpc: wrapped element
+ # document: unwrappted element
+ #
+ # use:
+ # encoding: a graph (SOAP Data Model)
+ # literal: not a graph (SOAPElement)
+ #
+ # rpc stub: obj in, obj out(Hash is allowed for literal)
+ #
+ # style: not visible from user
+ # rpc: wrapped element
+ # document: unwrappted element
+ #
+ # use:
+ # encoding: a graph (SOAP Data Model)
+ # literal: not a graph (SOAPElement)
+ #
+ # document driver: SOAPElement in, SOAPElement out? [not implemented]
+ #
+ # style: ditto
+ # use: ditto
+ #
+ #
+ # document stub: SOAPElement in, SOAPElement out? [not implemented]
+ #
+ # style: ditto
+ # use: ditto
+ #
+ class GenericServant
+ # method name style: requeststyle_requestuse_responsestyle_responseuse
+
+ # 2 params -> array
+ def rpc_enc_rpc_enc(obj1, obj2)
+ [obj1, [obj1, obj2]]
+ end
+
+ # 2 objs -> array
+ def rpc_lit_rpc_enc(obj1, obj2)
+ [obj2, obj1]
+ end
+
+ # 2 params -> 2 params
+ def rpc_enc_rpc_lit(obj1, obj2)
+ klass = [obj1.class.name, obj2.class.name]
+ [obj2, obj1]
+ end
+
+ # 2 objs -> 2 objs
+ def rpc_lit_rpc_lit(obj1, obj2)
+ [obj1, obj2]
+ end
+
+ # 2 params -> array
+ def doc_enc_doc_enc(obj1, obj2)
+ [obj1, [obj1, obj2]]
+ end
+
+ # 2 objs -> array
+ def doc_lit_doc_enc(obj1, obj2)
+ [obj2, obj1]
+ end
+
+ # 2 params -> 2 hashes
+ def doc_enc_doc_lit(obj1, obj2)
+ klass = [obj1.class.name, obj2.class.name]
+ return {'obj1' => {'klass' => klass}, 'misc' => 'hash does not have an order'},
+ {'obj2' => {'klass' => klass}}
+ end
+
+ # 2 objs -> 2 objs
+ def doc_lit_doc_lit(obj1, obj2)
+ return obj1, obj2
+ end
+ end
+
+ Namespace = "urn:styleuse"
+
+ module Op
+ def self.opt(request_style, request_use, response_style, response_use)
+ {
+ :request_style => request_style,
+ :request_use => request_use,
+ :response_style => response_style,
+ :response_use => response_use
+ }
+ end
+
+ Op_rpc_enc_rpc_enc = [
+ XSD::QName.new(Namespace, 'rpc_enc_rpc_enc'),
+ nil,
+ 'rpc_enc_rpc_enc', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'return', nil]],
+ opt(:rpc, :encoded, :rpc, :encoded)
+ ]
+
+ Op_rpc_lit_rpc_enc = [
+ XSD::QName.new(Namespace, 'rpc_lit_rpc_enc'),
+ nil,
+ 'rpc_lit_rpc_enc', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'return', nil]],
+ opt(:rpc, :literal, :rpc, :encoded)
+ ]
+
+ Op_rpc_enc_rpc_lit = [
+ XSD::QName.new(Namespace, 'rpc_enc_rpc_lit'),
+ nil,
+ 'rpc_enc_rpc_lit', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'ret1', nil],
+ ['out', 'ret2', nil]],
+ opt(:rpc, :encoded, :rpc, :literal)
+ ]
+
+ Op_rpc_lit_rpc_lit = [
+ XSD::QName.new(Namespace, 'rpc_lit_rpc_lit'),
+ nil,
+ 'rpc_lit_rpc_lit', [
+ ['in', 'obj1', nil],
+ ['in', 'obj2', nil],
+ ['retval', 'ret1', nil],
+ ['out', 'ret2', nil]],
+ opt(:rpc, :literal, :rpc, :literal)
+ ]
+
+ Op_doc_enc_doc_enc = [
+ Namespace + 'doc_enc_doc_enc',
+ 'doc_enc_doc_enc', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :encoded, :document, :encoded)
+ ]
+
+ Op_doc_lit_doc_enc = [
+ Namespace + 'doc_lit_doc_enc',
+ 'doc_lit_doc_enc', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :literal, :document, :encoded)
+ ]
+
+ Op_doc_enc_doc_lit = [
+ Namespace + 'doc_enc_doc_lit',
+ 'doc_enc_doc_lit', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :encoded, :document, :literal)
+ ]
+
+ Op_doc_lit_doc_lit = [
+ Namespace + 'doc_lit_doc_lit',
+ 'doc_lit_doc_lit', [
+ ['in', 'obj1', [nil, Namespace, 'obj1']],
+ ['in', 'obj2', [nil, Namespace, 'obj2']],
+ ['out', 'ret1', [nil, Namespace, 'ret1']],
+ ['out', 'ret2', [nil, Namespace, 'ret2']]],
+ opt(:document, :literal, :document, :literal)
+ ]
+ end
+
+ include Op
+
+ class Server < ::SOAP::RPC::HTTPServer
+ include Op
+
+ def on_init
+ @servant = GenericServant.new
+ add_rpc_operation(@servant, *Op_rpc_enc_rpc_enc)
+ add_rpc_operation(@servant, *Op_rpc_lit_rpc_enc)
+ add_rpc_operation(@servant, *Op_rpc_enc_rpc_lit)
+ add_rpc_operation(@servant, *Op_rpc_lit_rpc_lit)
+ add_document_operation(@servant, *Op_doc_enc_doc_enc)
+ add_document_operation(@servant, *Op_doc_lit_doc_enc)
+ add_document_operation(@servant, *Op_doc_enc_doc_lit)
+ add_document_operation(@servant, *Op_doc_lit_doc_lit)
+ end
+ end
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :BindAddress => "0.0.0.0",
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => Namespace
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @client = ::SOAP::RPC::Driver.new("http://localhost:#{Port}/", Namespace)
+ @client.wiredump_dev = STDERR if $DEBUG
+ @client.add_rpc_operation(*Op_rpc_enc_rpc_enc)
+ @client.add_rpc_operation(*Op_rpc_lit_rpc_enc)
+ @client.add_rpc_operation(*Op_rpc_enc_rpc_lit)
+ @client.add_rpc_operation(*Op_rpc_lit_rpc_lit)
+ @client.add_document_operation(*Op_doc_enc_doc_enc)
+ @client.add_document_operation(*Op_doc_lit_doc_enc)
+ @client.add_document_operation(*Op_doc_enc_doc_lit)
+ @client.add_document_operation(*Op_doc_lit_doc_lit)
+ 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_rpc_enc_rpc_enc
+ o = "hello"
+ obj1 = o
+ obj2 = [1]
+ ret = @client.rpc_enc_rpc_enc(obj1, obj2)
+ # server returns [obj1, [obj1, obj2]]
+ assert_equal([obj1, [obj1, obj2]], ret)
+ assert_same(ret[0], ret[1][0])
+ end
+
+ S1 = ::Struct.new(:a)
+ S2 = ::Struct.new(:c)
+ def test_rpc_lit_rpc_enc
+ ret1, ret2 = @client.rpc_lit_rpc_enc(S1.new('b'), S2.new('d'))
+ assert_equal('d', ret1.c)
+ assert_equal('b', ret2.a)
+ # Hash is allowed for literal
+ ret1, ret2 = @client.rpc_lit_rpc_enc({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('d', ret1.c)
+ assert_equal('b', ret2.a)
+ # simple value
+ assert_equal(
+ ['1', 'a'],
+ @client.rpc_lit_rpc_enc('a', 1)
+ )
+ end
+
+ def test_rpc_enc_rpc_lit
+ assert_equal(
+ ['1', 'a'],
+ @client.rpc_enc_rpc_lit('a', '1')
+ )
+ end
+
+ def test_rpc_lit_rpc_lit
+ ret1, ret2 = @client.rpc_lit_rpc_lit({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('b', ret1["a"])
+ assert_equal('d', ret2["c"])
+ end
+
+ def test_doc_enc_doc_enc
+ o = "hello"
+ obj1 = o
+ obj2 = [1]
+ ret = @client.rpc_enc_rpc_enc(obj1, obj2)
+ # server returns [obj1, [obj1, obj2]]
+ assert_equal([obj1, [obj1, obj2]], ret)
+ assert_same(ret[0], ret[1][0])
+ end
+
+ def test_doc_lit_doc_enc
+ ret1, ret2 = @client.doc_lit_doc_enc({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('d', ret1.c)
+ assert_equal('b', ret2.a)
+ assert_equal(
+ ['a', '1'],
+ @client.doc_lit_doc_enc(1, 'a')
+ )
+ end
+
+ def test_doc_enc_doc_lit
+ ret1, ret2 = @client.doc_enc_doc_lit('a', 1)
+ # literal Array
+ assert_equal(['String', 'Fixnum'], ret1['obj1']['klass'])
+ # same value
+ assert_equal(ret1['obj1']['klass'], ret2['obj2']['klass'])
+ # not the same object (not encoded)
+ assert_not_same(ret1['obj1']['klass'], ret2['obj2']['klass'])
+ end
+
+ def test_doc_lit_doc_lit
+ ret1, ret2 = @client.doc_lit_doc_lit({'a' => 'b'}, {'c' => 'd'})
+ assert_equal('b', ret1["a"])
+ assert_equal('d', ret2["c"])
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/wsdlDriver/README.txt b/ruby_1_8_5/test/soap/wsdlDriver/README.txt
new file mode 100644
index 0000000000..b4d45a0486
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/README.txt
@@ -0,0 +1,2 @@
+echo_version.rb is generated by wsdl2ruby.rb;
+% wsdl2ruby.rb --wsdl simpletype.wsdl --classdef --force
diff --git a/ruby_1_8_5/test/soap/wsdlDriver/calc.wsdl b/ruby_1_8_5/test/soap/wsdlDriver/calc.wsdl
new file mode 100644
index 0000000000..694a01e87e
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/calc.wsdl
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--generated by GLUE Standard 4.0.1 on Wed Mar 09 10:20:07 GMT-08:00
+2005-->
+<wsdl:definitions name='Calculator'
+targetNamespace='http://www.themindelectric.com/wsdl/Calculator/'
+ xmlns:tns='http://www.themindelectric.com/wsdl/Calculator/'
+ xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
+ xmlns:http='http://schemas.xmlsoap.org/wsdl/http/'
+ xmlns:mime='http://schemas.xmlsoap.org/wsdl/mime/'
+ xmlns:xsd='http://www.w3.org/2001/XMLSchema'
+ xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
+ xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
+ xmlns:tme='http://www.themindelectric.com/'>
+ <wsdl:message name='add0In'>
+ <wsdl:part name='x' type='xsd:float'/>
+ <wsdl:part name='y' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='add0Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='divide1In'>
+ <wsdl:part name='numerator' type='xsd:float'/>
+ <wsdl:part name='denominator' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='divide1Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='multiply2In'>
+ <wsdl:part name='x' type='xsd:float'/>
+ <wsdl:part name='y' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='multiply2Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='subtract3In'>
+ <wsdl:part name='x' type='xsd:float'/>
+ <wsdl:part name='y' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:message name='subtract3Out'>
+ <wsdl:part name='Result' type='xsd:float'/>
+ </wsdl:message>
+ <wsdl:portType name='ICalculator'>
+ <wsdl:operation name='add' parameterOrder='x y'>
+ <wsdl:input name='add0In' message='tns:add0In'/>
+ <wsdl:output name='add0Out' message='tns:add0Out'/>
+ </wsdl:operation>
+ <wsdl:operation name='divide' parameterOrder='numerator
+denominator'>
+ <wsdl:input name='divide1In' message='tns:divide1In'/>
+ <wsdl:output name='divide1Out' message='tns:divide1Out'/>
+ </wsdl:operation>
+ <wsdl:operation name='multiply' parameterOrder='x y'>
+ <wsdl:input name='multiply2In' message='tns:multiply2In'/>
+ <wsdl:output name='multiply2Out'
+message='tns:multiply2Out'/>
+ </wsdl:operation>
+ <wsdl:operation name='subtract' parameterOrder='x y'>
+ <wsdl:input name='subtract3In' message='tns:subtract3In'/>
+ <wsdl:output name='subtract3Out'
+message='tns:subtract3Out'/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name='ICalculator' type='tns:ICalculator'>
+ <soap:binding style='rpc'
+transport='http://schemas.xmlsoap.org/soap/http'/>
+ <wsdl:operation name='add'>
+ <soap:operation soapAction='add' style='rpc'/>
+ <wsdl:input name='add0In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='add0Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name='divide'>
+ <soap:operation soapAction='divide' style='rpc'/>
+ <wsdl:input name='divide1In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='divide1Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name='multiply'>
+ <soap:operation soapAction='multiply' style='rpc'/>
+ <wsdl:input name='multiply2In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='multiply2Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name='subtract'>
+ <soap:operation soapAction='subtract' style='rpc'/>
+ <wsdl:input name='subtract3In'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:input>
+ <wsdl:output name='subtract3Out'>
+ <soap:body use='encoded'
+namespace='http://www.fred.com'
+encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name='Calculator'>
+ <wsdl:documentation>calculator service</wsdl:documentation>
+ <wsdl:port name='ICalculator' binding='tns:ICalculator'>
+ <soap:address
+location='http://ukulele:8080/calcapp/services/calculator'/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/ruby_1_8_5/test/soap/wsdlDriver/document.wsdl b/ruby_1_8_5/test/soap/wsdlDriver/document.wsdl
new file mode 100644
index 0000000000..5e9e74b9df
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/document.wsdl
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<definitions name="submit_service"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="urn:example.com:document"
+ targetNamespace="urn:example.com:document"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xsd:schema targetNamespace="urn:example.com:document">
+ <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:schema>
+ </types>
+
+ <message name="submit_msg">
+ <part name="parameters" element="tns:ruby"/>
+ </message>
+
+ <portType name="submit_port_type">
+ <operation name="submit">
+ <input message="tns:submit_msg"/>
+ <output message="tns:submit_msg"/>
+ </operation>
+ </portType>
+
+ <binding name="submit_binding" type="tns:submit_port_type">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="submit">
+ <soap:operation soapAction="urn:example.com:document#submit" style="document"/>
+ <input><soap:body use="literal"/></input>
+ <output><soap:body use="literal"/></output>
+ </operation>
+ </binding>
+
+ <service name="submit_service">
+ <port name="submit_port" binding="tns:submit_binding">
+ <soap:address location="http://localhost:10080"/>
+ </port>
+ </service>
+</definitions>
diff --git a/ruby_1_8_5/test/soap/wsdlDriver/echo_version.rb b/ruby_1_8_5/test/soap/wsdlDriver/echo_version.rb
new file mode 100644
index 0000000000..7d76fb7587
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/echo_version.rb
@@ -0,0 +1,20 @@
+# urn:example.com:simpletype-rpc-type
+class Version_struct
+ @@schema_type = "version_struct"
+ @@schema_ns = "urn:example.com:simpletype-rpc-type"
+
+ attr_accessor :version
+ attr_accessor :msg
+
+ def initialize(version = nil, msg = nil)
+ @version = version
+ @msg = msg
+ end
+end
+
+# urn:example.com:simpletype-rpc-type
+module Versions
+ C_16 = "1.6"
+ C_18 = "1.8"
+ C_19 = "1.9"
+end
diff --git a/ruby_1_8_5/test/soap/wsdlDriver/simpletype.wsdl b/ruby_1_8_5/test/soap/wsdlDriver/simpletype.wsdl
new file mode 100644
index 0000000000..6781dda552
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/simpletype.wsdl
@@ -0,0 +1,63 @@
+<?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="myversion" type="txd:myversions" />
+ <xsd:element name="msg" type="xsd:string" />
+ </xsd:all>
+ </xsd:complexType>
+
+ <xsd:simpleType name="myversions">
+ <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="myversion" type="txd:myversions"/>
+ </message>
+
+ <message name="msg_version_struct">
+ <part name="return" 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>
+ </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>
+ </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_5/test/soap/wsdlDriver/test_calc.rb b/ruby_1_8_5/test/soap/wsdlDriver/test_calc.rb
new file mode 100644
index 0000000000..d031f663a3
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/test_calc.rb
@@ -0,0 +1,100 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/wsdlDriver'
+
+
+module SOAP
+
+
+class TestCalc < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::HTTPServer
+ def on_init
+ add_method(self, 'add', 'x', 'y')
+ end
+
+ def add(x, y)
+ x.to_f + y.to_f
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :BindAddress => "0.0.0.0",
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => 'http://www.fred.com'
+ )
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ @wsdl = File.join(DIR, 'calc.wsdl')
+ 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 if @client
+ end
+
+ def start_server_thread(server)
+ t = Thread.new {
+ Thread.current.abort_on_exception = true
+ server.start
+ }
+ t
+ end
+
+ def test_rpc_driver
+ @client = ::SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = true
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ @client.generate_explicit_type = false
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ end
+
+ def test_old_driver
+ silent do
+ @client = ::SOAP::WSDLDriverFactory.new(@wsdl).create_driver
+ end
+ @client.wiredump_dev = STDOUT if $DEBUG
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = true
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ @client.generate_explicit_type = false
+ assert_equal(0.3, @client.add(0.1, 0.2))
+ end
+
+ def silent
+ back = $VERBOSE
+ $VERBOSE = nil
+ begin
+ yield
+ ensure
+ $VERBOSE = back
+ end
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/wsdlDriver/test_document.rb b/ruby_1_8_5/test/soap/wsdlDriver/test_document.rb
new file mode 100644
index 0000000000..634b827aae
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/test_document.rb
@@ -0,0 +1,78 @@
+require 'test/unit'
+require 'soap/rpc/standaloneServer'
+require 'soap/wsdlDriver'
+
+
+module SOAP
+
+
+class TestDocument < Test::Unit::TestCase
+ Namespace = 'urn:example.com:document'
+
+ class Server < ::SOAP::RPC::StandaloneServer
+ def on_init
+ add_document_method(self, 'urn:example.com:document#submit', 'submit', XSD::QName.new(Namespace, 'ruby'), XSD::QName.new(Namespace, 'ruby'))
+ end
+
+ def submit(ruby)
+ ruby
+ 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', Namespace, '0.0.0.0', Port)
+ @server.level = Logger::Severity::ERROR
+ @server_thread = start_server_thread(@server)
+ end
+
+ def setup_client
+ wsdl = File.join(DIR, 'document.wsdl')
+ @client = ::SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @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_document
+ msg = {'myversion' => "1.9", 'date' => "2004-01-01T00:00:00Z"}
+ reply_msg = @client.submit(msg)
+ assert_equal('1.9', reply_msg.myversion)
+ assert_equal('1.9', reply_msg['myversion'])
+ assert_equal('2004-01-01T00:00:00Z', reply_msg.date)
+ assert_equal('2004-01-01T00:00:00Z', reply_msg['date'])
+ end
+end
+
+
+end
diff --git a/ruby_1_8_5/test/soap/wsdlDriver/test_simpletype.rb b/ruby_1_8_5/test/soap/wsdlDriver/test_simpletype.rb
new file mode 100644
index 0000000000..76b3a32df7
--- /dev/null
+++ b/ruby_1_8_5/test/soap/wsdlDriver/test_simpletype.rb
@@ -0,0 +1,87 @@
+require 'test/unit'
+require 'soap/rpc/httpserver'
+require 'soap/wsdlDriver'
+
+
+module SOAP
+
+
+class TestSimpleType < Test::Unit::TestCase
+ class Server < ::SOAP::RPC::HTTPServer
+ def on_init
+ add_method(self, 'echo_version', 'version')
+ end
+
+ def echo_version(version)
+ # "2.0" is out of range.
+ Version_struct.new(version || "2.0", 'checked')
+ end
+ end
+
+ DIR = File.dirname(File.expand_path(__FILE__))
+ require File.join(DIR, 'echo_version')
+
+ Port = 17171
+
+ def setup
+ setup_server
+ setup_client
+ end
+
+ def setup_server
+ @server = Server.new(
+ :BindAddress => "0.0.0.0",
+ :Port => Port,
+ :AccessLog => [],
+ :SOAPDefaultNamespace => "urn:example.com:simpletype-rpc"
+ )
+ @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.wiredump_dev = STDOUT if $DEBUG
+ @client.endpoint_url = "http://localhost:#{Port}/"
+ @client.generate_explicit_type = false
+ 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
+ result = @client.echo_version("1.9")
+ assert_equal("1.9", result.version)
+ assert_equal("checked", result.msg)
+ assert_raise(XSD::ValueSpaceError) do
+ @client.echo_version("2.0")
+ end
+ assert_raise(XSD::ValueSpaceError) do
+ @client.echo_version(nil) # nil => "2.0" => out of range
+ end
+ end
+end
+
+
+end