diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-22 01:53:51 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-22 01:53:51 +0000 |
commit | 1e760c0be3ed35874204114e7454509f740c0fe2 (patch) | |
tree | a75eb2b1eea073830902d1fa49c568c4525c8b57 /ruby_1_8_6/test/soap/calc | |
parent | a2055d63b41a6678dc7aeb17d0bece314e700c5a (diff) |
add tag v1_8_6_71v1_8_5_71
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_71@13189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_8_6/test/soap/calc')
-rw-r--r-- | ruby_1_8_6/test/soap/calc/calc.rb | 17 | ||||
-rw-r--r-- | ruby_1_8_6/test/soap/calc/calc2.rb | 29 | ||||
-rw-r--r-- | ruby_1_8_6/test/soap/calc/server.cgi | 13 | ||||
-rw-r--r-- | ruby_1_8_6/test/soap/calc/server.rb | 17 | ||||
-rw-r--r-- | ruby_1_8_6/test/soap/calc/server2.rb | 20 | ||||
-rw-r--r-- | ruby_1_8_6/test/soap/calc/test_calc.rb | 49 | ||||
-rw-r--r-- | ruby_1_8_6/test/soap/calc/test_calc2.rb | 53 | ||||
-rw-r--r-- | ruby_1_8_6/test/soap/calc/test_calc_cgi.rb | 69 |
8 files changed, 267 insertions, 0 deletions
diff --git a/ruby_1_8_6/test/soap/calc/calc.rb b/ruby_1_8_6/test/soap/calc/calc.rb new file mode 100644 index 0000000000..6bc78803b3 --- /dev/null +++ b/ruby_1_8_6/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_6/test/soap/calc/calc2.rb b/ruby_1_8_6/test/soap/calc/calc2.rb new file mode 100644 index 0000000000..69495730e7 --- /dev/null +++ b/ruby_1_8_6/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_6/test/soap/calc/server.cgi b/ruby_1_8_6/test/soap/calc/server.cgi new file mode 100644 index 0000000000..1eb0d1d864 --- /dev/null +++ b/ruby_1_8_6/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_6/test/soap/calc/server.rb b/ruby_1_8_6/test/soap/calc/server.rb new file mode 100644 index 0000000000..a93774d909 --- /dev/null +++ b/ruby_1_8_6/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_6/test/soap/calc/server2.rb b/ruby_1_8_6/test/soap/calc/server2.rb new file mode 100644 index 0000000000..01c6d75289 --- /dev/null +++ b/ruby_1_8_6/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_6/test/soap/calc/test_calc.rb b/ruby_1_8_6/test/soap/calc/test_calc.rb new file mode 100644 index 0000000000..88738716a6 --- /dev/null +++ b/ruby_1_8_6/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_6/test/soap/calc/test_calc2.rb b/ruby_1_8_6/test/soap/calc/test_calc2.rb new file mode 100644 index 0000000000..f334b29bdb --- /dev/null +++ b/ruby_1_8_6/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_6/test/soap/calc/test_calc_cgi.rb b/ruby_1_8_6/test/soap/calc/test_calc_cgi.rb new file mode 100644 index 0000000000..d28830629f --- /dev/null +++ b/ruby_1_8_6/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 |