mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ff1b89a96d
* lib/soap/{attachment.rb,baseData.rb,encodingstyle/soapHandler.rb}: introduce SOAPExternalReference class as a referenct to SOAPEnvelope external content. * lib/soap/{attachment.rb,mimemessage.rb}: great SwA (SOAP messages with Attachments) support code by Jamie Herre. * lib/soap/{element.rb,marshal.rb,parser.rb,processor.rb, streamHandler.rb,wsdlDriver.rb}: SwA support. * lib/soap/rpc/{cgistub.rb,driver.rb,element.rb,proxy.rb,router.rb, soaplet.rb}: SwA support and refactoring. * lib/soap/generator.rb, lib/soap/mapping/mapping.rb: follow SOAPReference#initialize signature change. * lib/soap/mapping/factory.rb: deleted unused methods. * lib/soap/mapping/rubytypeFactory.rb: do no ignore case while xsi:type string <-> Ruby class name matching. * lib/xsd/datatypes.rb: check the smallest positive non-zero single-precision float exactly instead of packing with "f". [ruby-talk:88822] * test/soap/test_basetype.rb, test/xsd/test_xsd.rb: use 1.402e-45, not 1.4e-45. 1.4e-45 is smaller than 2 ** -149... * test/soap/test_basetype.rb, test/soap/marshal/test_marshal.rb, test/xsd/test_xsd.rb: use "(-1.0 / (1.0 / 0.0))" instead of "-0.0". * test/soap/test_streamhandler.rb: revert to the previous test that warns "basic_auth unsupported under net/http". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
76 lines
1.7 KiB
Ruby
76 lines
1.7 KiB
Ruby
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
|
|
}
|
|
while @server.status != :Running
|
|
sleep 0.1
|
|
unless @t.alive?
|
|
@t.join
|
|
raise
|
|
end
|
|
end
|
|
@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
|