diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-07 07:36:34 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-07-07 07:36:34 +0000 |
commit | 441546edcfbb1b346c87b69c5f578d1a0e522e06 (patch) | |
tree | 04f606a008baebc445f38944ad37e87468da29ea /ruby_1_8_6/test/soap/asp.net/test_aspdotnet.rb | |
parent | fa93611c0f9a6db146341c792bfe3b7322ec00e2 (diff) |
add tag v1_8_6_269
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_6_269@17937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/test/soap/asp.net/test_aspdotnet.rb')
-rw-r--r-- | ruby_1_8_6/test/soap/asp.net/test_aspdotnet.rb | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/ruby_1_8_6/test/soap/asp.net/test_aspdotnet.rb b/ruby_1_8_6/test/soap/asp.net/test_aspdotnet.rb new file mode 100644 index 0000000000..7d5f3fd288 --- /dev/null +++ b/ruby_1_8_6/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 |