summaryrefslogtreecommitdiff
path: root/test/soap
diff options
context:
space:
mode:
Diffstat (limited to 'test/soap')
-rw-r--r--test/soap/calc/test_calc.rb4
-rw-r--r--test/soap/calc/test_calc2.rb5
-rw-r--r--test/soap/calc/test_calc_cgi.rb1
-rw-r--r--test/soap/helloworld/test_helloworld.rb4
-rw-r--r--test/soap/test_basetype.rb40
-rw-r--r--test/soap/test_property.rb70
-rw-r--r--test/soap/test_streamhandler.rb13
7 files changed, 90 insertions, 47 deletions
diff --git a/test/soap/calc/test_calc.rb b/test/soap/calc/test_calc.rb
index c917ddcf9e..4210c65772 100644
--- a/test/soap/calc/test_calc.rb
+++ b/test/soap/calc/test_calc.rb
@@ -1,10 +1,6 @@
require 'test/unit'
require 'soap/rpc/driver'
-
-dir = File.dirname(__FILE__)
-$:.push(dir)
require 'server.rb'
-$:.delete(dir)
module SOAP
diff --git a/test/soap/calc/test_calc2.rb b/test/soap/calc/test_calc2.rb
index b7fee71526..d15cfe9600 100644
--- a/test/soap/calc/test_calc2.rb
+++ b/test/soap/calc/test_calc2.rb
@@ -1,10 +1,6 @@
require 'test/unit'
require 'soap/rpc/driver'
-
-dir = File.dirname(__FILE__)
-$:.push(dir)
require 'server2.rb'
-$:.delete(dir)
module SOAP
@@ -30,6 +26,7 @@ class TestCalc2 < Test::Unit::TestCase
end
@endpoint = "http://localhost:#{Port}/"
@var = SOAP::RPC::Driver.new(@endpoint, 'http://tempuri.org/calcService')
+ @var.wiredump_dev = STDERR if $DEBUG
@var.add_method('set', 'newValue')
@var.add_method('get')
@var.add_method_as('+', 'add', 'rhs')
diff --git a/test/soap/calc/test_calc_cgi.rb b/test/soap/calc/test_calc_cgi.rb
index 523379f302..d1655b0b01 100644
--- a/test/soap/calc/test_calc_cgi.rb
+++ b/test/soap/calc/test_calc_cgi.rb
@@ -44,6 +44,7 @@ class TestCalcCGI < Test::Unit::TestCase
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')
diff --git a/test/soap/helloworld/test_helloworld.rb b/test/soap/helloworld/test_helloworld.rb
index 7261e42f19..cd78d9fa0b 100644
--- a/test/soap/helloworld/test_helloworld.rb
+++ b/test/soap/helloworld/test_helloworld.rb
@@ -1,10 +1,6 @@
require 'test/unit'
require 'soap/rpc/driver'
-
-dir = File.dirname(__FILE__)
-$:.push(dir)
require 'hw_s.rb'
-$:.delete(dir)
module SOAP
diff --git a/test/soap/test_basetype.rb b/test/soap/test_basetype.rb
index 7a77946c2c..afd550f996 100644
--- a/test/soap/test_basetype.rb
+++ b/test/soap/test_basetype.rb
@@ -156,8 +156,8 @@ class TestSOAP < Test::Unit::TestCase
targets = [
3.14159265358979,
12.34e36,
- 1.4e-45,
- -1.4e-45,
+ 1.402e-45,
+ -1.402e-45,
]
targets.each do |f|
assert_equal(f, SOAP::SOAPFloat.new(f).data)
@@ -166,8 +166,8 @@ class TestSOAP < Test::Unit::TestCase
targets = [
"+3.141592654",
"+1.234e+37",
- "+1.4e-45",
- "-1.4e-45",
+ "+1.402e-45",
+ "-1.402e-45",
]
targets.each do |f|
assert_equal(f, SOAP::SOAPFloat.new(f).to_s)
@@ -178,13 +178,13 @@ class TestSOAP < Test::Unit::TestCase
[-2, "-2"], # ditto
[3.14159265358979, "+3.141592654"],
[12.34e36, "+1.234e+37"],
- [1.4e-45, "+1.4e-45"],
- [-1.4e-45, "-1.4e-45"],
- ["1.4e", "+1.4"],
+ [1.402e-45, "+1.402e-45"],
+ [-1.402e-45, "-1.402e-45"],
+ ["1.402e", "+1.402"],
["12.34E36", "+1.234e+37"],
- ["1.4E-45", "+1.4e-45"],
- ["-1.4E-45", "-1.4e-45"],
- ["1.4E", "+1.4"],
+ ["1.402E-45", "+1.402e-45"],
+ ["-1.402E-45", "-1.402e-45"],
+ ["1.402E", "+1.402"],
]
targets.each do |f, str|
assert_equal(str, SOAP::SOAPFloat.new(f).to_s)
@@ -221,8 +221,8 @@ class TestSOAP < Test::Unit::TestCase
targets = [
3.14159265358979,
12.34e36,
- 1.4e-45,
- -1.4e-45,
+ 1.402e-45,
+ -1.402e-45,
]
targets.each do |f|
assert_equal(f, SOAP::SOAPDouble.new(f).data)
@@ -231,8 +231,8 @@ class TestSOAP < Test::Unit::TestCase
targets = [
"+3.14159265358979",
"+1.234e+37",
- "+1.4e-45",
- "-1.4e-45",
+ "+1.402e-45",
+ "-1.402e-45",
]
targets.each do |f|
assert_equal(f, SOAP::SOAPDouble.new(f).to_s)
@@ -243,13 +243,13 @@ class TestSOAP < Test::Unit::TestCase
[-2, "-2"], # ditto.
[3.14159265358979, "+3.14159265358979"],
[12.34e36, "+1.234e+37"],
- [1.4e-45, "+1.4e-45"],
- [-1.4e-45, "-1.4e-45"],
- ["1.4e", "+1.4"],
+ [1.402e-45, "+1.402e-45"],
+ [-1.402e-45, "-1.402e-45"],
+ ["1.402e", "+1.402"],
["12.34E36", "+1.234e+37"],
- ["1.4E-45", "+1.4e-45"],
- ["-1.4E-45", "-1.4e-45"],
- ["1.4E", "+1.4"],
+ ["1.402E-45", "+1.402e-45"],
+ ["-1.402E-45", "-1.402e-45"],
+ ["1.402E", "+1.402"],
]
targets.each do |f, str|
assert_equal(str, SOAP::SOAPDouble.new(f).to_s)
diff --git a/test/soap/test_property.rb b/test/soap/test_property.rb
index 82363a83db..1cc826695f 100644
--- a/test/soap/test_property.rb
+++ b/test/soap/test_property.rb
@@ -59,7 +59,7 @@ __EOP__
prop = Property.new
hooked = false
prop.add_hook("foo.bar.baz") do |name, value|
- assert_equal("foo.bar.baz", name)
+ assert_equal(["foo", "bar", "baz"], name)
assert_equal("123", value)
hooked = true
end
@@ -126,11 +126,24 @@ __EOP__
end
end
+ def test_hook_name
+ tag = Object.new
+ tested = false
+ @prop.add_hook("foo.bar") do |key, value|
+ assert_raise(TypeError) do
+ key << "baz"
+ end
+ tested = true
+ end
+ @prop["foo.bar"] = tag
+ assert(tested)
+ end
+
def test_value_hook
tag = Object.new
tested = false
@prop.add_hook("FOO.BAR.BAZ") do |key, value|
- assert_equal("foo.bar.baz", key)
+ assert_equal(["Foo", "baR", "baZ"], key)
assert_equal(tag, value)
tested = true
end
@@ -141,32 +154,65 @@ __EOP__
assert_equal(1, @prop["foo.bar"])
end
- def test_key_hook
+ def test_key_hook_no_cascade
tag = Object.new
tested = 0
+ @prop.add_hook do |key, value|
+ assert(false)
+ end
+ @prop.add_hook(false) do |key, value|
+ assert(false)
+ end
@prop.add_hook("foo") do |key, value|
- assert_equal("foo.bar.baz.qux", key)
+ assert(false)
+ end
+ @prop.add_hook("foo.bar", false) do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar.baz") do |key, value|
+ assert(false)
+ end
+ @prop.add_hook("foo.bar.baz.qux", false) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
assert_equal(tag, value)
tested += 1
end
- @prop.add_hook("foo.bar") do |key, value|
- assert_equal("foo.bar.baz.qux", key)
+ @prop["foo.bar.baz.qux"] = tag
+ assert_equal(tag, @prop["foo.bar.baz.qux"])
+ assert_equal(1, tested)
+ end
+
+ def test_key_hook_cascade
+ tag = Object.new
+ tested = 0
+ @prop.add_hook(true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
assert_equal(tag, value)
tested += 1
end
- @prop.add_hook("foo.bar.baz") do |key, value|
- assert_equal("foo.bar.baz.qux", key)
+ @prop.add_hook("foo", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
assert_equal(tag, value)
tested += 1
end
- @prop.add_hook("foo.bar.baz.qux") do |key, value|
- assert_equal("foo.bar.baz.qux", key)
+ @prop.add_hook("foo.bar", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar.baz", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
+ assert_equal(tag, value)
+ tested += 1
+ end
+ @prop.add_hook("foo.bar.baz.qux", true) do |key, value|
+ assert_equal(["foo", "bar", "baz", "qux"], key)
assert_equal(tag, value)
tested += 1
end
@prop["foo.bar.baz.qux"] = tag
assert_equal(tag, @prop["foo.bar.baz.qux"])
- assert_equal(4, tested)
+ assert_equal(5, tested)
end
def test_keys
@@ -310,7 +356,7 @@ __EOP__
def test_hook_then_lock
tested = false
@prop.add_hook("a.b.c") do |name, value|
- assert_equal("a.b.c", name)
+ assert_equal(["a", "b", "c"], name)
tested = true
end
@prop["a.b"].lock
diff --git a/test/soap/test_streamhandler.rb b/test/soap/test_streamhandler.rb
index d38b84ed97..e5b578d7a6 100644
--- a/test/soap/test_streamhandler.rb
+++ b/test/soap/test_streamhandler.rb
@@ -142,9 +142,16 @@ __EOX__
end
def test_basic_auth
- # soap4r + basic_auth is not officially supported in ruby/1.8.1 even though
- # soap4r + basic_auth + http-access2 should run fine.
- return
+ unless Object.const_defined?('HTTPAccess2')
+ STDERR.puts("basic_auth is not supported under soap4r + net/http for now.")
+ return
+ end
+ str = ""
+ @client.wiredump_dev = str
+ @client.options["protocol.http.basic_auth"] << [@url, "foo", "bar"]
+ assert_nil(@client.do_server_proc)
+ r, h = parse_req_header(str)
+ assert_equal("Basic Zm9vOmJhcg==", h["authorization"])
end
def test_proxy