2003-09-24 11:18:44 -04:00
|
|
|
require 'test/unit'
|
|
|
|
require 'soap/rpc/driver'
|
2003-09-27 03:03:29 -04:00
|
|
|
require 'logger'
|
2003-09-24 11:18:44 -04:00
|
|
|
require 'webrick'
|
2004-07-03 09:33:20 -04:00
|
|
|
require 'rbconfig'
|
2003-09-24 11:18:44 -04:00
|
|
|
|
2003-09-26 14:34:41 -04:00
|
|
|
|
|
|
|
module SOAP
|
|
|
|
module Calc
|
|
|
|
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
class TestCalcCGI < Test::Unit::TestCase
|
2004-07-03 09:33:20 -04:00
|
|
|
# This test shuld be run after installing ruby.
|
|
|
|
RUBYBIN = File.join(
|
* mkconfig.rb: generate RbConfig instead of Config.
* instruby.rb, rubytest.rb, runruby.rb, bcc32/Makefile.sub,
ext/extmk.rb, ext/dl/extconf.rb, ext/iconv/charset_alias.rb,
lib/mkmf.rb, lib/rdoc/ri/ri_paths.rb,
lib/webrick/httpservlet/cgihandler.rb,
test/dbm/test_dbm.rb, test/gdbm/test_gdbm.rb,
test/ruby/envutil.rb, test/soap/calc/test_calc_cgi.rb,
test/soap/header/test_authheader_cgi.rb, test/soap/ssl/test_ssl.rb,
win32/mkexports.rb, win32/resource.rb: Use RbConfig instead of
Config.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-02-20 03:34:53 -05:00
|
|
|
RbConfig::CONFIG["bindir"],
|
|
|
|
RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]
|
2004-07-03 09:33:20 -04:00
|
|
|
)
|
2003-10-30 09:25:21 -05:00
|
|
|
RUBYBIN << " -d" if $DEBUG
|
2003-10-05 01:42:04 -04:00
|
|
|
|
2003-10-18 11:21:18 -04:00
|
|
|
Port = 17171
|
|
|
|
|
2003-09-24 11:18:44 -04:00
|
|
|
def setup
|
2003-09-27 03:03:29 -04:00
|
|
|
logger = Logger.new(STDERR)
|
2003-10-22 11:43:10 -04:00
|
|
|
logger.level = Logger::Severity::ERROR
|
2003-09-24 11:18:44 -04:00
|
|
|
@server = WEBrick::HTTPServer.new(
|
|
|
|
:BindAddress => "0.0.0.0",
|
2003-09-27 03:03:29 -04:00
|
|
|
:Logger => logger,
|
2003-10-18 11:21:18 -04:00
|
|
|
:Port => Port,
|
2003-09-27 03:03:29 -04:00
|
|
|
:AccessLog => [],
|
2003-09-24 11:18:44 -04:00
|
|
|
:DocumentRoot => File.dirname(File.expand_path(__FILE__)),
|
2003-10-01 11:29:43 -04:00
|
|
|
:CGIPathEnv => ENV['PATH'],
|
|
|
|
:CGIInterpreter => RUBYBIN
|
2003-09-24 11:18:44 -04:00
|
|
|
)
|
|
|
|
@t = Thread.new {
|
2003-10-20 11:37:11 -04:00
|
|
|
Thread.current.abort_on_exception = true
|
2003-09-24 11:18:44 -04:00
|
|
|
@server.start
|
|
|
|
}
|
2003-10-22 11:43:10 -04:00
|
|
|
@endpoint = "http://localhost:#{Port}/server.cgi"
|
|
|
|
@calc = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
|
* import soap4r/1.5.2;
* 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
2004-01-05 21:20:51 -05:00
|
|
|
@calc.wiredump_dev = STDERR if $DEBUG
|
2003-09-24 11:18:44 -04:00
|
|
|
@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
|
2003-10-20 11:37:11 -04:00
|
|
|
@t.join
|
2003-10-22 11:43:10 -04:00
|
|
|
@calc.reset_stream
|
2003-09-24 11:18:44 -04:00
|
|
|
end
|
|
|
|
|
2003-10-31 11:50:27 -05:00
|
|
|
def test_calc_cgi
|
2003-09-24 11:18:44 -04:00
|
|
|
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
|
2003-09-26 14:34:41 -04:00
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|