summaryrefslogtreecommitdiff
path: root/test/soap/wsdlDriver/test_calc.rb
diff options
context:
space:
mode:
author(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-22 13:20:28 +0000
committer(no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-05-22 13:20:28 +0000
commit15b7d439885f4aa97e0f508ef485cadab4b23577 (patch)
tree82c8688f0c59072692095d904460e9d33d42c747 /test/soap/wsdlDriver/test_calc.rb
parent7c95e34533ddc68692e2f811de159a81b94af3d4 (diff)
This commit was manufactured by cvs2svn to create branch 'ruby_1_8'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/soap/wsdlDriver/test_calc.rb')
-rw-r--r--test/soap/wsdlDriver/test_calc.rb88
1 files changed, 88 insertions, 0 deletions
diff --git a/test/soap/wsdlDriver/test_calc.rb b/test/soap/wsdlDriver/test_calc.rb
new file mode 100644
index 0000000000..f1cc116a59
--- /dev/null
+++ b/test/soap/wsdlDriver/test_calc.rb
@@ -0,0 +1,88 @@
+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
+ @client = ::SOAP::WSDLDriverFactory.new(@wsdl).create_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
+end
+
+
+end