summaryrefslogtreecommitdiff
path: root/ruby/test
diff options
context:
space:
mode:
Diffstat (limited to 'ruby/test')
-rw-r--r--ruby/test/Ice/acm/AllTests.rb4
-rwxr-xr-xruby/test/Ice/acm/Client.rb43
-rw-r--r--ruby/test/Ice/binding/AllTests.rb4
-rwxr-xr-xruby/test/Ice/binding/Client.rb30
-rw-r--r--ruby/test/Ice/checksum/AllTests.rb4
-rwxr-xr-xruby/test/Ice/checksum/Client.rb37
-rwxr-xr-xruby/test/Ice/defaultValue/Client.rb27
-rw-r--r--ruby/test/Ice/enums/AllTests.rb10
-rwxr-xr-xruby/test/Ice/enums/Client.rb29
-rw-r--r--ruby/test/Ice/exceptions/AllTests.rb66
-rwxr-xr-xruby/test/Ice/exceptions/Client.rb40
-rw-r--r--ruby/test/Ice/facets/AllTests.rb4
-rwxr-xr-xruby/test/Ice/facets/Client.rb31
-rw-r--r--ruby/test/Ice/info/AllTests.rb6
-rwxr-xr-xruby/test/Ice/info/Client.rb40
-rw-r--r--ruby/test/Ice/inheritance/AllTests.rb4
-rwxr-xr-xruby/test/Ice/inheritance/Client.rb31
-rw-r--r--ruby/test/Ice/location/AllTests.rb3
-rwxr-xr-xruby/test/Ice/location/Client.rb40
-rw-r--r--ruby/test/Ice/objects/AllTests.rb6
-rwxr-xr-xruby/test/Ice/objects/Client.rb26
-rw-r--r--ruby/test/Ice/operations/AllTests.rb8
-rwxr-xr-xruby/test/Ice/operations/Client.rb80
-rw-r--r--ruby/test/Ice/operations/Twoways.rb4
-rw-r--r--ruby/test/Ice/optional/AllTests.rb10
-rwxr-xr-xruby/test/Ice/optional/Client.rb31
-rw-r--r--ruby/test/Ice/properties/Client.rb102
-rw-r--r--ruby/test/Ice/proxy/AllTests.rb14
-rwxr-xr-xruby/test/Ice/proxy/Client.rb42
-rw-r--r--ruby/test/Ice/scope/AllTests.rb16
-rwxr-xr-xruby/test/Ice/scope/Client.rb25
-rw-r--r--ruby/test/Ice/slicing/exceptions/AllTests.rb4
-rwxr-xr-xruby/test/Ice/slicing/exceptions/Client.rb27
-rw-r--r--ruby/test/Ice/slicing/objects/AllTests.rb10
-rwxr-xr-xruby/test/Ice/slicing/objects/Client.rb27
-rw-r--r--ruby/test/Ice/timeout/AllTests.rb7
-rwxr-xr-xruby/test/Ice/timeout/Client.rb81
-rwxr-xr-xruby/test/Slice/escape/Client.rb97
-rwxr-xr-xruby/test/Slice/macros/Client.rb58
-rwxr-xr-xruby/test/Slice/structure/Client.rb377
-rw-r--r--ruby/test/TestHelper.rb112
41 files changed, 636 insertions, 981 deletions
diff --git a/ruby/test/Ice/acm/AllTests.rb b/ruby/test/Ice/acm/AllTests.rb
index 8b307d528c5..a5cdfa1b173 100644
--- a/ruby/test/Ice/acm/AllTests.rb
+++ b/ruby/test/Ice/acm/AllTests.rb
@@ -84,8 +84,8 @@ def testHeartbeatManual(communicator, com)
puts "ok"
end
-def allTests(communicator)
- ref = "communicator:default -p 12010"
+def allTests(helper, communicator)
+ ref = "communicator:#{helper.getTestEndpoint()}"
com = Test::RemoteCommunicatorPrx::uncheckedCast(communicator.stringToProxy(ref))
testSetACM(communicator, com)
diff --git a/ruby/test/Ice/acm/Client.rb b/ruby/test/Ice/acm/Client.rb
index 408e720921c..c81258c0bff 100755
--- a/ruby/test/Ice/acm/Client.rb
+++ b/ruby/test/Ice/acm/Client.rb
@@ -8,41 +8,16 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-slice_dir = Ice.getSliceDir
-if slice_dir.empty?
- fail "Slice directory not found"
-end
-
-Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+require "Ice"
+Ice::loadSlice("Test.ice")
require './AllTests'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ properties = self.createTestProperties(args:args)
+ properties.setProperty("Ice.Warn.Connections", "0")
+ self.init(properties:properties) do |communicator|
+ allTests(self, communicator)
+ end
end
end
-
-def run(args, communicator)
- allTests(communicator)
- return true
-end
-
-begin
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
- initData.properties.setProperty("Ice.Warn.Connections", "0")
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/binding/AllTests.rb b/ruby/test/Ice/binding/AllTests.rb
index 0ad2500d208..0e1db3aa8fb 100644
--- a/ruby/test/Ice/binding/AllTests.rb
+++ b/ruby/test/Ice/binding/AllTests.rb
@@ -30,8 +30,8 @@ def deactivate(com, adapters)
end
end
-def allTests(communicator)
- ref = "communicator:default -p 12010"
+def allTests(helper, communicator)
+ ref = "communicator:#{helper.getTestEndpoint()}"
com = Test::RemoteCommunicatorPrx::uncheckedCast(communicator.stringToProxy(ref))
print "testing binding with single endpoint... "
diff --git a/ruby/test/Ice/binding/Client.rb b/ruby/test/Ice/binding/Client.rb
index 1f4caf88e15..2c48b93cfbd 100755
--- a/ruby/test/Ice/binding/Client.rb
+++ b/ruby/test/Ice/binding/Client.rb
@@ -8,28 +8,14 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-
-Ice::loadSlice('Test.ice')
+require "Ice"
+Ice::loadSlice("Test.ice")
require './AllTests'
-def run(args, communicator)
- allTests(communicator)
- return true
-end
-
-begin
- communicator = Ice::initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ allTests(self, communicator)
+ end
+ end
end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/checksum/AllTests.rb b/ruby/test/Ice/checksum/AllTests.rb
index 053c598e061..78ab7ac52fa 100644
--- a/ruby/test/Ice/checksum/AllTests.rb
+++ b/ruby/test/Ice/checksum/AllTests.rb
@@ -13,8 +13,8 @@ def test(b)
end
end
-def allTests(communicator)
- ref = "test:default -p 12010"
+def allTests(helper, communicator)
+ ref = "test:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
diff --git a/ruby/test/Ice/checksum/Client.rb b/ruby/test/Ice/checksum/Client.rb
index e528632fc38..33fae6b1ac1 100755
--- a/ruby/test/Ice/checksum/Client.rb
+++ b/ruby/test/Ice/checksum/Client.rb
@@ -8,34 +8,15 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-
-slice_dir = Ice.getSliceDir
-if slice_dir.empty?
- fail "Slice directory not found"
-end
-
-Ice::loadSlice("'-I" + slice_dir + "' --checksum Test.ice CTypes.ice")
+require "Ice"
+Ice::loadSlice("'-I#{Ice.getSliceDir}' --checksum Test.ice CTypes.ice")
require './AllTests'
-def run(args, communicator)
- checksum = allTests(communicator)
- checksum.shutdown()
- return true
-end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ checksum = allTests(self, communicator)
+ checksum.shutdown()
+ end
+ end
end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/defaultValue/Client.rb b/ruby/test/Ice/defaultValue/Client.rb
index b6c2887b165..ab0ee8e757a 100755
--- a/ruby/test/Ice/defaultValue/Client.rb
+++ b/ruby/test/Ice/defaultValue/Client.rb
@@ -8,29 +8,12 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-
-Ice::loadSlice('Test.ice')
+require "Ice"
+Ice::loadSlice("Test.ice")
require './AllTests'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ allTests()
end
end
-
-def run(args)
- allTests()
- return true
-end
-
-begin
- status = run(ARGV)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/enums/AllTests.rb b/ruby/test/Ice/enums/AllTests.rb
index 55e1bf54601..2f6e49b2b79 100644
--- a/ruby/test/Ice/enums/AllTests.rb
+++ b/ruby/test/Ice/enums/AllTests.rb
@@ -7,14 +7,8 @@
#
# **********************************************************************
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
- end
-end
-
-def allTests(communicator)
- ref = "test:default -p 12010"
+def allTests(helper, communicator)
+ ref = "test:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
diff --git a/ruby/test/Ice/enums/Client.rb b/ruby/test/Ice/enums/Client.rb
index 37b48f4e627..d8dbd6f2a85 100755
--- a/ruby/test/Ice/enums/Client.rb
+++ b/ruby/test/Ice/enums/Client.rb
@@ -8,28 +8,15 @@
#
# **********************************************************************
-require 'Ice'
-
+require "Ice"
Ice::loadSlice("Test.ice")
require './AllTests'
-def run(args, communicator)
- proxy = allTests(communicator)
- proxy.shutdown()
- return true
-end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ proxy = allTests(self, communicator)
+ proxy.shutdown()
+ end
+ end
end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/exceptions/AllTests.rb b/ruby/test/Ice/exceptions/AllTests.rb
index b74723e1d6c..edc58748117 100644
--- a/ruby/test/Ice/exceptions/AllTests.rb
+++ b/ruby/test/Ice/exceptions/AllTests.rb
@@ -19,13 +19,7 @@ class ValueFactoryI
end
end
-def allTests(communicator)
- platformInfo = RUBY_PLATFORM.split("-")
- isWin32 = false
- if platformInfo.length >= 2 && platformInfo[1] == "mswin32"
- isWin32 = true
- end
-
+def allTests(helper, communicator)
print "testing value factory registration exception... "
STDOUT.flush
vf = ValueFactoryI.new
@@ -39,7 +33,7 @@ def allTests(communicator)
print "testing stringToProxy... "
STDOUT.flush
- ref = "thrower:default -p 12010"
+ ref = "thrower:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
puts "ok"
@@ -110,22 +104,20 @@ def allTests(communicator)
#
# We cannot invoke throwModA if the server was built with VC6.
#
- if !isWin32
- begin
- thrower.throwModA(1, 2)
- test(false)
- rescue Test::Mod::A => ex
- test(ex.aMem == 1)
- test(ex.a2Mem == 2)
- rescue Ice::OperationNotExistException
- #
- # This operation is not supported in Java.
- #
- rescue
- print $!
- print $!.backtrace.join("\n")
- test(false)
- end
+ begin
+ thrower.throwModA(1, 2)
+ test(false)
+ rescue Test::Mod::A => ex
+ test(ex.aMem == 1)
+ test(ex.a2Mem == 2)
+ rescue Ice::OperationNotExistException
+ #
+ # This operation is not supported in Java.
+ #
+ rescue
+ print $!
+ print $!.backtrace.join("\n")
+ test(false)
end
puts "ok"
@@ -157,20 +149,18 @@ def allTests(communicator)
#
# We cannot invoke throwModA if the server was built with VC6.
#
- if !isWin32
- begin
- thrower.throwModA(1, 2)
- test(false)
- rescue Test::A => ex
- test(ex.aMem == 1)
- rescue Ice::OperationNotExistException
- #
- # This operation is not supported in Java.
- #
- rescue
- print $!.backtrace.join("\n")
- test(false)
- end
+ begin
+ thrower.throwModA(1, 2)
+ test(false)
+ rescue Test::A => ex
+ test(ex.aMem == 1)
+ rescue Ice::OperationNotExistException
+ #
+ # This operation is not supported in Java.
+ #
+ rescue
+ print $!.backtrace.join("\n")
+ test(false)
end
puts "ok"
diff --git a/ruby/test/Ice/exceptions/Client.rb b/ruby/test/Ice/exceptions/Client.rb
index b5d2ca30429..0de13f419a0 100755
--- a/ruby/test/Ice/exceptions/Client.rb
+++ b/ruby/test/Ice/exceptions/Client.rb
@@ -8,34 +8,18 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-
-slice_dir = Ice.getSliceDir
-Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+require "Ice"
+Ice::loadSlice("'-I#{Ice.getSliceDir()}' Test.ice")
require './AllTests'
-def run(args, communicator)
- thrower = allTests(communicator)
- thrower.shutdown()
- return true
-end
-
-begin
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
- initData.properties.setProperty("Ice.MessageSizeMax", "10")
- initData.properties.setProperty("Ice.Warn.Connections", "0")
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
+class Client < ::TestHelper
+ def run(args)
+ properties = self.createTestProperties(args:args)
+ properties.setProperty("Ice.MessageSizeMax", "10")
+ properties.setProperty("Ice.Warn.Connections", "0")
+ self.init(properties:properties) do |communicator|
+ thrower = allTests(self, communicator)
+ thrower.shutdown()
+ end
+ end
end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/facets/AllTests.rb b/ruby/test/Ice/facets/AllTests.rb
index 246fed3b358..0f3f5b2a563 100644
--- a/ruby/test/Ice/facets/AllTests.rb
+++ b/ruby/test/Ice/facets/AllTests.rb
@@ -13,7 +13,7 @@ def test(b)
end
end
-def allTests(communicator)
+def allTests(helper, communicator)
print "testing Ice.Admin.Facets property... "
STDOUT.flush
@@ -38,7 +38,7 @@ def allTests(communicator)
print "testing stringToProxy... "
STDOUT.flush
- ref = "d:default -p 12010"
+ ref = "d:#{helper.getTestEndpoint()}"
db = communicator.stringToProxy(ref)
test(db)
puts "ok"
diff --git a/ruby/test/Ice/facets/Client.rb b/ruby/test/Ice/facets/Client.rb
index b990ba03c40..d8dbd6f2a85 100755
--- a/ruby/test/Ice/facets/Client.rb
+++ b/ruby/test/Ice/facets/Client.rb
@@ -8,28 +8,15 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-Ice::loadSlice('Test.ice')
+require "Ice"
+Ice::loadSlice("Test.ice")
require './AllTests'
-def run(args, communicator)
- g = allTests(communicator)
- g.shutdown()
- return true
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ proxy = allTests(self, communicator)
+ proxy.shutdown()
+ end
+ end
end
-
-begin
- communicator = Ice::initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/info/AllTests.rb b/ruby/test/Ice/info/AllTests.rb
index 7e86bd724cc..de22b967724 100644
--- a/ruby/test/Ice/info/AllTests.rb
+++ b/ruby/test/Ice/info/AllTests.rb
@@ -25,7 +25,7 @@ def getTCPConnectionInfo(info)
end
end
-def allTests(communicator)
+def allTests(helper, communicator)
print "testing proxy endpoint information..."
STDOUT.flush
@@ -72,7 +72,9 @@ def allTests(communicator)
puts "ok"
defaultHost = communicator.getProperties().getProperty("Ice.Default.Host")
- base = communicator.stringToProxy("test:default -p 12010:udp -p 12010")
+ tcpEndpoint = helper.getTestEndpoint()
+ udpEndpoint = helper.getTestEndpoint(protocol:"udp")
+ base = communicator.stringToProxy("test:#{tcpEndpoint}:#{udpEndpoint}")
testIntf = Test::TestIntfPrx::checkedCast(base)
print "test connection endpoint information..."
diff --git a/ruby/test/Ice/info/Client.rb b/ruby/test/Ice/info/Client.rb
index 359ae53e7d5..1925891ad79 100755
--- a/ruby/test/Ice/info/Client.rb
+++ b/ruby/test/Ice/info/Client.rb
@@ -8,40 +8,14 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-slice_dir = Ice.getSliceDir
-if slice_dir.empty?
- fail "Slice directory not found"
-end
-
-Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+require "Ice"
+Ice::loadSlice("'-I#{Ice.getSliceDir()}' Test.ice")
require './AllTests'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ allTests(self, communicator)
+ end
end
end
-
-def run(args, communicator)
- allTests(communicator)
- return true
-end
-
-begin
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/inheritance/AllTests.rb b/ruby/test/Ice/inheritance/AllTests.rb
index fdc3e349af6..865aa794ed0 100644
--- a/ruby/test/Ice/inheritance/AllTests.rb
+++ b/ruby/test/Ice/inheritance/AllTests.rb
@@ -13,10 +13,10 @@ def test(b)
end
end
-def allTests(communicator)
+def allTests(helper, communicator)
print "testing stringToProxy... "
STDOUT.flush
- ref = "initial:default -p 12010"
+ ref = "initial:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
puts "ok"
diff --git a/ruby/test/Ice/inheritance/Client.rb b/ruby/test/Ice/inheritance/Client.rb
index 82714e6af3e..4a9d4574885 100755
--- a/ruby/test/Ice/inheritance/Client.rb
+++ b/ruby/test/Ice/inheritance/Client.rb
@@ -8,28 +8,15 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-Ice::loadSlice('Test.ice')
+require "Ice"
+Ice::loadSlice("Test.ice")
require './AllTests'
-def run(args, communicator)
- initial = allTests(communicator)
- initial.shutdown()
- return true
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ initial = allTests(self, communicator)
+ initial.shutdown()
+ end
+ end
end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/location/AllTests.rb b/ruby/test/Ice/location/AllTests.rb
index 115d666aaa9..0785e2e756a 100644
--- a/ruby/test/Ice/location/AllTests.rb
+++ b/ruby/test/Ice/location/AllTests.rb
@@ -13,7 +13,8 @@ def test(b)
end
end
-def allTests(communicator, ref)
+def allTests(helper, communicator)
+ ref = "ServerManager:#{helper.getTestEndpoint()}"
manager = Test::ServerManagerPrx::checkedCast(communicator.stringToProxy(ref))
locator = communicator.getDefaultLocator()
test(manager)
diff --git a/ruby/test/Ice/location/Client.rb b/ruby/test/Ice/location/Client.rb
index 312c658ceb0..0c81e75c341 100755
--- a/ruby/test/Ice/location/Client.rb
+++ b/ruby/test/Ice/location/Client.rb
@@ -8,36 +8,16 @@
#
# **********************************************************************
-require 'pathname'
-
-require 'Ice'
-slice_dir = Ice.getSliceDir
-if slice_dir.empty?
- fail "Slice directory not found"
-end
-
-Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+require "Ice"
+Ice::loadSlice("'-I#{Ice.getSliceDir()}' Test.ice")
require './AllTests'
-def run(args, communicator)
- allTests(communicator, "ServerManager:default -p 12010")
- return true
-end
-
-begin
- data = Ice::InitializationData.new
- data.properties = Ice::createProperties(ARGV)
- data.properties.setProperty("Ice.Default.Locator", "locator:default -p 12010")
- communicator = Ice::initialize(ARGV, data)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
+class Client < ::TestHelper
+ def run(args)
+ properties = self.createTestProperties(args:args)
+ properties.setProperty("Ice.Default.Locator", "locator:#{self.getTestEndpoint(properties:properties)}")
+ self.init(properties:properties) do |communicator|
+ allTests(self, communicator)
+ end
+ end
end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/objects/AllTests.rb b/ruby/test/Ice/objects/AllTests.rb
index ff07c5106b6..c5c0e7a63bf 100644
--- a/ruby/test/Ice/objects/AllTests.rb
+++ b/ruby/test/Ice/objects/AllTests.rb
@@ -68,7 +68,7 @@ def test(b)
end
end
-def allTests(communicator)
+def allTests(helper, communicator)
factory = MyValueFactory.new
communicator.getValueFactoryManager().add(factory, '::Test::B')
@@ -83,7 +83,7 @@ def allTests(communicator)
print "testing stringToProxy... "
STDOUT.flush
- ref = "initial:default -p 12010"
+ ref = "initial:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
puts "ok"
@@ -309,7 +309,7 @@ def allTests(communicator)
print "testing UnexpectedObjectException... "
STDOUT.flush
- ref = "uoet:default -p 12010"
+ ref = "uoet:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
uoet = Test::UnexpectedObjectExceptionTestPrx::uncheckedCast(base)
diff --git a/ruby/test/Ice/objects/Client.rb b/ruby/test/Ice/objects/Client.rb
index fe4c7b30a7e..6e91e16bce4 100755
--- a/ruby/test/Ice/objects/Client.rb
+++ b/ruby/test/Ice/objects/Client.rb
@@ -8,29 +8,17 @@
#
# **********************************************************************
-require 'pathname'
require 'Ice'
Ice::loadSlice('Test.ice')
Ice::loadSlice('ClientPrivate.ice')
require './AllTests'
-def run(args, communicator)
- initial = allTests(communicator)
- initial.shutdown()
- return true
-end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-if communicator
- communicator.destroy()
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ initial = allTests(self, communicator)
+ initial.shutdown()
+ end
+ end
end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/operations/AllTests.rb b/ruby/test/Ice/operations/AllTests.rb
index 3e0ccb2d22a..db605c422ca 100644
--- a/ruby/test/Ice/operations/AllTests.rb
+++ b/ruby/test/Ice/operations/AllTests.rb
@@ -10,16 +10,16 @@
require './Twoways'
require './BatchOneways'
-def allTests(communicator)
- ref = "test:default -p 12010"
+def allTests(helper, communicator)
+ ref = "test:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
cl = Test::MyClassPrx::checkedCast(base)
derived = Test::MyDerivedClassPrx::checkedCast(cl)
print "testing twoway operations... "
STDOUT.flush
- twoways(communicator, cl)
- twoways(communicator, derived)
+ twoways(helper, communicator, cl)
+ twoways(helper, communicator, derived)
derived.opDerived()
puts "ok"
diff --git a/ruby/test/Ice/operations/Client.rb b/ruby/test/Ice/operations/Client.rb
index 2167caea837..32a460f7688 100755
--- a/ruby/test/Ice/operations/Client.rb
+++ b/ruby/test/Ice/operations/Client.rb
@@ -8,61 +8,33 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-
-slice_dir = Ice.getSliceDir
-Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+require "Ice"
+Ice::loadSlice("'-I#{Ice.getSliceDir()}' Test.ice")
require './AllTests'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
- end
-end
-
-def run(args, communicator)
- myClass = allTests(communicator)
-
- print "testing server shutdown... "
- STDOUT.flush
- myClass.shutdown()
- begin
- myClass.ice_timeout(100).ice_ping(); # Use timeout to speed up testing on Windows
- test(false)
- rescue Ice::LocalException
- puts "ok"
+class Client < ::TestHelper
+ def run(args)
+ properties = self.createTestProperties(args:args)
+ #
+ # This is not necessary since we don't have AMI support (yet).
+ #
+ #properties.setProperty('Ice.ThreadPool.Client.Size', '2')
+ #properties.setProperty('Ice.ThreadPool.Client.SizeWarn', '0')
+ properties.setProperty("Ice.BatchAutoFlushSize", "100")
+ self.init(properties:properties) do |communicator|
+ myClass = allTests(self, communicator)
+ print "testing server shutdown... "
+ STDOUT.flush
+ myClass.shutdown()
+ begin
+ myClass.ice_timeout(100).ice_ping(); # Use timeout to speed up testing on Windows
+ test(false)
+ rescue Ice::LocalException
+ puts "ok"
+ end
+ # Test multiple destroy calls
+ communicator.destroy()
+ communicator.destroy()
+ end
end
-
- return true
end
-
-begin
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
- #
- # This is not necessary since we don't have AMI support (yet).
- #
- #initData.properties.setProperty('Ice.ThreadPool.Client.Size', '2')
- #initData.properties.setProperty('Ice.ThreadPool.Client.SizeWarn', '0')
-
- initData.properties.setProperty("Ice.BatchAutoFlushSize", "100")
-
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-
- # Test multiple destroy calls
- communicator.destroy()
- communicator.destroy()
-
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/operations/Twoways.rb b/ruby/test/Ice/operations/Twoways.rb
index 598353fbe48..1f756b16360 100644
--- a/ruby/test/Ice/operations/Twoways.rb
+++ b/ruby/test/Ice/operations/Twoways.rb
@@ -8,7 +8,7 @@
#
# **********************************************************************
-def twoways(communicator, p)
+def twoways(helper, communicator, p)
literals = p.opStringLiterals();
@@ -1239,7 +1239,7 @@ def twoways(communicator, p)
ctx = {'one'=>'ONE', 'two'=>'TWO', 'three'=>'THREE'}
- p = Test::MyClassPrx::uncheckedCast(ic.stringToProxy('test:default -p 12010'))
+ p = Test::MyClassPrx::uncheckedCast(ic.stringToProxy("test:#{helper.getTestEndpoint()}"))
ic.getImplicitContext().setContext(ctx)
test(ic.getImplicitContext().getContext() == ctx)
diff --git a/ruby/test/Ice/optional/AllTests.rb b/ruby/test/Ice/optional/AllTests.rb
index 91e8d50464d..28f5a9e9af9 100644
--- a/ruby/test/Ice/optional/AllTests.rb
+++ b/ruby/test/Ice/optional/AllTests.rb
@@ -7,16 +7,10 @@
#
# **********************************************************************
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
- end
-end
-
-def allTests(communicator)
+def allTests(helper, communicator)
print "testing stringToProxy... "
STDOUT.flush
- ref = "initial:default -p 12010"
+ ref = "initial:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
puts "ok"
diff --git a/ruby/test/Ice/optional/Client.rb b/ruby/test/Ice/optional/Client.rb
index 35c242f600b..1fa841fc53d 100755
--- a/ruby/test/Ice/optional/Client.rb
+++ b/ruby/test/Ice/optional/Client.rb
@@ -9,33 +9,14 @@
# **********************************************************************
require 'Ice'
-
Ice::loadSlice("--all -I. ClientPrivate.ice")
require './AllTests'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ initial = allTests(self, communicator)
+ initial.shutdown()
+ end
end
end
-
-def run(args, communicator)
- initial = allTests(communicator)
- initial.shutdown()
- return true
-end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/properties/Client.rb b/ruby/test/Ice/properties/Client.rb
index 62c98f9e7ce..cb793b85fe5 100644
--- a/ruby/test/Ice/properties/Client.rb
+++ b/ruby/test/Ice/properties/Client.rb
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-# encoding: UTF-8
+# encoding: utf-8
# **********************************************************************
#
# Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
@@ -11,13 +11,7 @@
require 'Ice'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
- end
-end
-
-class Client < Ice::Application
+class App < Ice::Application
def run(args)
print "testing load properties from UTF-8 path using Ice::Application... "
properties = Ice::Application::communicator().getProperties()
@@ -31,53 +25,57 @@ class Client < Ice::Application
end
end
-print "testing load properties from UTF-8 path... "
-properties = Ice.createProperties(ARGV)
-properties.load("./config/中国_client.config")
-test(properties.getProperty("Ice.Trace.Network") == "1")
-test(properties.getProperty("Ice.Trace.Protocol") == "1")
-test(properties.getProperty("Config.Path").eql? "./config/中国_client.config")
-test(properties.getProperty("Ice.ProgramName") == "PropertiesClient")
-puts "ok"
-app = Client.new()
-app.main(ARGV, "./config/中国_client.config")
+class Client < ::TestHelper
+ def run(args)
-print "testing using Ice.Config with multiple config files... "
-properties = Ice.createProperties(["--Ice.Config=config/config.1, config/config.2, config/config.3"]);
-test(properties.getProperty("Config1") == "Config1");
-test(properties.getProperty("Config2") == "Config2");
-test(properties.getProperty("Config3") == "Config3");
-puts "ok"
+ print "testing load properties from UTF-8 path... "
+ properties = Ice.createProperties(args)
+ properties.load("./config/中国_client.config")
+ test(properties.getProperty("Ice.Trace.Network") == "1")
+ test(properties.getProperty("Ice.Trace.Protocol") == "1")
+ test(properties.getProperty("Config.Path").eql? "./config/中国_client.config")
+ test(properties.getProperty("Ice.ProgramName") == "PropertiesClient")
+ puts "ok"
+
+ app = App.new()
+ app.main(args, "./config/中国_client.config")
-print "testing configuration file escapes... "
-properties = Ice.createProperties(["--Ice.Config=config/escapes.cfg"])
+ print "testing using Ice.Config with multiple config files... "
+ properties = Ice.createProperties(["--Ice.Config=config/config.1, config/config.2, config/config.3"]);
+ test(properties.getProperty("Config1") == "Config1");
+ test(properties.getProperty("Config2") == "Config2");
+ test(properties.getProperty("Config3") == "Config3");
+ puts "ok"
-props = { "Foo\tBar" => "3",
- "Foo\\tBar" => "4",
- "Escape\\ Space" => "2",
- "Prop1" => "1",
- "Prop2" => "2",
- "Prop3" => "3",
- "My Prop1" => "1",
- "My Prop2" => "2",
- "My.Prop1" => "a property",
- "My.Prop2" => "a property",
- "My.Prop3" => " a property ",
- "My.Prop4" => " a property ",
- "My.Prop5" => "a \\ property",
- "foo=bar" => "1",
- "foo#bar" => "2",
- "foo bar" => "3",
- "A" => "1",
- "B" => "2 3 4",
- "C" => "5=#6",
- "AServer" => "\\\\server\\dir",
- "BServer" => "\\server\\dir" }
+ print "testing configuration file escapes... "
+ properties = Ice.createProperties(["--Ice.Config=config/escapes.cfg"])
-props.each do |key, value|
- test(properties.getProperty(key) == value)
-end
-puts "ok"
+ props = { "Foo\tBar" => "3",
+ "Foo\\tBar" => "4",
+ "Escape\\ Space" => "2",
+ "Prop1" => "1",
+ "Prop2" => "2",
+ "Prop3" => "3",
+ "My Prop1" => "1",
+ "My Prop2" => "2",
+ "My.Prop1" => "a property",
+ "My.Prop2" => "a property",
+ "My.Prop3" => " a property ",
+ "My.Prop4" => " a property ",
+ "My.Prop5" => "a \\ property",
+ "foo=bar" => "1",
+ "foo#bar" => "2",
+ "foo bar" => "3",
+ "A" => "1",
+ "B" => "2 3 4",
+ "C" => "5=#6",
+ "AServer" => "\\\\server\\dir",
+ "BServer" => "\\server\\dir" }
-exit(0)
+ props.each do |key, value|
+ test(properties.getProperty(key) == value)
+ end
+ puts "ok"
+ end
+end
diff --git a/ruby/test/Ice/proxy/AllTests.rb b/ruby/test/Ice/proxy/AllTests.rb
index b15f457befa..44fe4bc24f3 100644
--- a/ruby/test/Ice/proxy/AllTests.rb
+++ b/ruby/test/Ice/proxy/AllTests.rb
@@ -7,10 +7,10 @@
#
# **********************************************************************
-def allTests(communicator)
+def allTests(helper, communicator)
print "testing stringToProxy... "
STDOUT.flush
- ref = "test:default -p 12010"
+ ref = "test:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
@@ -192,7 +192,7 @@ def allTests(communicator)
STDOUT.flush
prop = communicator.getProperties()
propertyPrefix = "Foo.Proxy"
- prop.setProperty(propertyPrefix, "test:default -p 12010")
+ prop.setProperty(propertyPrefix, "test:#{helper.getTestEndpoint()}")
b1 = communicator.propertyToProxy(propertyPrefix)
test(b1.ice_getIdentity().name == "test" && b1.ice_getIdentity().category.empty? && \
b1.ice_getAdapterId().empty? && b1.ice_getFacet().empty?)
@@ -234,7 +234,7 @@ def allTests(communicator)
#test(b1.ice_getLocatorCacheTimeout() == 60)
#prop.setProperty("Ice::Default.LocatorCacheTimeout", "")
- prop.setProperty(propertyPrefix, "test:default -p 12010")
+ prop.setProperty(propertyPrefix, "test:#{helper.getTestEndpoint()}")
property = propertyPrefix + ".Router"
test(!b1.ice_getRouter())
@@ -692,7 +692,7 @@ def allTests(communicator)
print "testing encoding versioning... "
STDOUT.flush
- ref20 = "test -e 2.0:default -p 12010";
+ ref20 = "test -e 2.0:#{helper.getTestEndpoint()}";
cl20 = Test::MyClassPrx::uncheckedCast(communicator.stringToProxy(ref20));
begin
cl20.ice_ping();
@@ -701,7 +701,7 @@ def allTests(communicator)
# Server 2.0 endpoint doesn't support 1.1 version.
end
- ref10 = "test -e 1.0:default -p 12010"
+ ref10 = "test -e 1.0:#{helper.getTestEndpoint()}"
cl10 = Test::MyClassPrx::uncheckedCast(communicator.stringToProxy(ref10))
cl10.ice_ping()
cl10.ice_encodingVersion(Ice::Encoding_1_0).ice_ping()
@@ -709,7 +709,7 @@ def allTests(communicator)
# 1.3 isn't supported but since a 1.3 proxy supports 1.1, the
# call will use the 1.1 encoding
- ref13 = "test -e 1.3:default -p 12010"
+ ref13 = "test -e 1.3:#{helper.getTestEndpoint()}"
cl13 = Test::MyClassPrx::uncheckedCast(communicator.stringToProxy(ref13))
cl13.ice_ping()
diff --git a/ruby/test/Ice/proxy/Client.rb b/ruby/test/Ice/proxy/Client.rb
index ded1d8e04d1..a83d2fe832a 100755
--- a/ruby/test/Ice/proxy/Client.rb
+++ b/ruby/test/Ice/proxy/Client.rb
@@ -8,42 +8,16 @@
#
# **********************************************************************
-require 'pathname'
-require 'Ice'
-slice_dir = Ice.getSliceDir
-if slice_dir.empty?
- fail "Slice directory not found"
-end
-Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+require 'Ice'
+Ice::loadSlice("'-I#{Ice.getSliceDir()}' Test.ice")
require './AllTests'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ initial = allTests(self, communicator)
+ initial.shutdown()
+ end
end
end
-
-def run(args, communicator)
- myClass = allTests(communicator)
-
- myClass.shutdown()
- return true
-end
-
-begin
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/scope/AllTests.rb b/ruby/test/Ice/scope/AllTests.rb
index da2a89e4600..8083b0481fc 100644
--- a/ruby/test/Ice/scope/AllTests.rb
+++ b/ruby/test/Ice/scope/AllTests.rb
@@ -7,18 +7,12 @@
#
# **********************************************************************
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
- end
-end
-
-def allTests(communicator)
+def allTests(helper, communicator)
print "test same Slice type name in different scopes... "
STDOUT.flush
- i1 = Test::IPrx::checkedCast(communicator.stringToProxy("i1:default -p 12010"))
+ i1 = Test::IPrx::checkedCast(communicator.stringToProxy("i1:#{helper.getTestEndpoint()}"))
s1 = Test::S.new(0)
s2, s3 = i1.opS(s1)
@@ -52,7 +46,7 @@ def allTests(communicator)
test(cmap2["a"].s == s1)
test(cmap3["a"].s == s1)
- i2 = Test::Inner::Inner2::IPrx::checkedCast(communicator.stringToProxy("i2:default -p 12010"))
+ i2 = Test::Inner::Inner2::IPrx::checkedCast(communicator.stringToProxy("i2:#{helper.getTestEndpoint()}"))
s1 = Test::Inner::Inner2::S.new(0)
s2, s3 = i2.opS(s1)
@@ -86,7 +80,7 @@ def allTests(communicator)
test(cmap2["a"].s == s1)
test(cmap3["a"].s == s1)
- i3 = Test::Inner::IPrx::checkedCast(communicator.stringToProxy("i3:default -p 12010"))
+ i3 = Test::Inner::IPrx::checkedCast(communicator.stringToProxy("i3:#{helper.getTestEndpoint()}"))
s1 = Test::Inner::Inner2::S.new(0)
s2, s3 = i3.opS(s1)
@@ -120,7 +114,7 @@ def allTests(communicator)
test(cmap2["a"].s == s1)
test(cmap3["a"].s == s1)
- i4 = Inner::Test::Inner2::IPrx::checkedCast(communicator.stringToProxy("i4:default -p 12010"))
+ i4 = Inner::Test::Inner2::IPrx::checkedCast(communicator.stringToProxy("i4:#{helper.getTestEndpoint()}"))
s1 = Test::S.new(0)
s2, s3 = i4.opS(s1)
diff --git a/ruby/test/Ice/scope/Client.rb b/ruby/test/Ice/scope/Client.rb
index 1de102800a6..9e5e8c476d7 100755
--- a/ruby/test/Ice/scope/Client.rb
+++ b/ruby/test/Ice/scope/Client.rb
@@ -9,26 +9,13 @@
# **********************************************************************
require 'Ice'
-
Ice::loadSlice("Test.ice")
require './AllTests'
-def run(args, communicator)
- allTests(communicator)
- return true
-end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ allTests(self, communicator)
+ end
+ end
end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/slicing/exceptions/AllTests.rb b/ruby/test/Ice/slicing/exceptions/AllTests.rb
index 869906e678e..4044fb41bfb 100644
--- a/ruby/test/Ice/slicing/exceptions/AllTests.rb
+++ b/ruby/test/Ice/slicing/exceptions/AllTests.rb
@@ -13,8 +13,8 @@ def test(b)
end
end
-def allTests(communicator)
- obj = communicator.stringToProxy("Test:default -p 12010")
+def allTests(helper, communicator)
+ obj = communicator.stringToProxy("Test:#{helper.getTestEndpoint()}")
t = Test::TestIntfPrx::checkedCast(obj)
print "base... "
diff --git a/ruby/test/Ice/slicing/exceptions/Client.rb b/ruby/test/Ice/slicing/exceptions/Client.rb
index 7d1b4fdd6dc..0d410457c81 100755
--- a/ruby/test/Ice/slicing/exceptions/Client.rb
+++ b/ruby/test/Ice/slicing/exceptions/Client.rb
@@ -8,28 +8,15 @@
#
# **********************************************************************
-require 'pathname'
require 'Ice'
Ice::loadSlice('Test.ice')
require './AllTests'
-def run(args, communicator)
- t = allTests(communicator)
- t.shutdown()
- return true
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do | communicator|
+ t = allTests(self, communicator)
+ t.shutdown()
+ end
+ end
end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/slicing/objects/AllTests.rb b/ruby/test/Ice/slicing/objects/AllTests.rb
index 190a37e33d8..66e4e81b4fc 100644
--- a/ruby/test/Ice/slicing/objects/AllTests.rb
+++ b/ruby/test/Ice/slicing/objects/AllTests.rb
@@ -10,14 +10,8 @@
require 'Ice'
Ice::loadSlice('-I. --all ClientPrivate.ice')
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
- end
-end
-
-def allTests(communicator)
- obj = communicator.stringToProxy("Test:default -p 12010")
+def allTests(helper, communicator)
+ obj = communicator.stringToProxy("Test:#{helper.getTestEndpoint()}")
t = Test::TestIntfPrx::checkedCast(obj)
print "base as Object... "
diff --git a/ruby/test/Ice/slicing/objects/Client.rb b/ruby/test/Ice/slicing/objects/Client.rb
index 9b039b2633e..44619569d7c 100755
--- a/ruby/test/Ice/slicing/objects/Client.rb
+++ b/ruby/test/Ice/slicing/objects/Client.rb
@@ -8,26 +8,13 @@
#
# **********************************************************************
-require 'pathname'
require './AllTests'
-def run(args, communicator)
- t = allTests(communicator)
- t.shutdown()
- return true
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ t = allTests(self, communicator)
+ t.shutdown()
+ end
+ end
end
-
-begin
- communicator = Ice.initialize(ARGV)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Ice/timeout/AllTests.rb b/ruby/test/Ice/timeout/AllTests.rb
index 0d2cdd9a99d..cba928f117e 100644
--- a/ruby/test/Ice/timeout/AllTests.rb
+++ b/ruby/test/Ice/timeout/AllTests.rb
@@ -21,15 +21,16 @@ def connect(prx)
return prx.ice_getConnection()
end
-def allTests(communicator)
- sref = "timeout:default -p 12010"
+def allTests(helper, communicator)
+ sref = "timeout:#{helper.getTestEndpoint()}"
obj = communicator.stringToProxy(sref)
test(obj)
timeout = Test::TimeoutPrx::checkedCast(obj)
test(timeout)
- controller = Test::ControllerPrx::checkedCast(communicator.stringToProxy("controller:default -p 12011"))
+ controller = Test::ControllerPrx::checkedCast(
+ communicator.stringToProxy("controller:#{helper.getTestEndpoint(num:1)}"))
test(controller)
print "testing connect timeout... "
diff --git a/ruby/test/Ice/timeout/Client.rb b/ruby/test/Ice/timeout/Client.rb
index 49138a2d850..cdff6a10ca3 100755
--- a/ruby/test/Ice/timeout/Client.rb
+++ b/ruby/test/Ice/timeout/Client.rb
@@ -8,61 +8,36 @@
#
# **********************************************************************
-require 'pathname'
require 'Ice'
-slice_dir = Ice.getSliceDir
-if slice_dir.empty?
- fail "Slice directory not found"
-end
-
-Ice::loadSlice("'-I" + slice_dir + "' Test.ice")
+Ice::loadSlice("'-I#{Ice.getSliceDir()}' Test.ice")
require './AllTests'
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ #
+ # In this test, we need at least two threads in the
+ # client side thread pool for nested AMI.
+ #
+ properties = self.createTestProperties(args:args)
+
+ #
+ # For this test, we want to disable retries.
+ #
+ properties.setProperty('Ice.RetryIntervals', '-1')
+
+ #
+ # This test kills connections, so we don't want warnings.
+ #
+ properties.setProperty('Ice.Warn.Connections', '0')
+
+ #
+ # Limit the send buffer size, this test relies on the socket
+ # send() blocking after sending a given amount of data.
+ #
+ properties.setProperty("Ice.TCP.SndSize", "50000");
+
+ self.init(properties:properties) do |communicator|
+ allTests(self, communicator)
+ end
end
end
-
-def run(args, communicator)
- allTests(communicator)
- return true
-end
-
-begin
- #
- # In this test, we need at least two threads in the
- # client side thread pool for nested AMI.
- #
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
-
- #
- # For this test, we want to disable retries.
- #
- initData.properties.setProperty('Ice.RetryIntervals', '-1')
-
- #
- # This test kills connections, so we don't want warnings.
- #
- initData.properties.setProperty('Ice.Warn.Connections', '0')
-
- #
- # Limit the send buffer size, this test relies on the socket
- # send() blocking after sending a given amount of data.
- #
- initData.properties.setProperty("Ice.TCP.SndSize", "50000");
-
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Slice/escape/Client.rb b/ruby/test/Slice/escape/Client.rb
index 84a31048a45..eb418cb005c 100755
--- a/ruby/test/Slice/escape/Client.rb
+++ b/ruby/test/Slice/escape/Client.rb
@@ -8,75 +8,40 @@
#
# **********************************************************************
-require 'pathname'
-
-rubyDir = nil
-for toplevel in [".", "..", "../..", "../../..", "../../../.."]
- path = Pathname.new(toplevel).join("ruby", "Ice.rb")
- if path.file?
- rubyDir = Pathname.new(toplevel).join("ruby")
- break
- end
-end
-if not rubyDir
- fail "can't find toplevel directory!"
-end
-
require 'Ice'
Ice::loadSlice('Key.ice')
Ice::loadSlice('Clash.ice')
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ print "testing type names... "
+ STDOUT.flush
+ a = BEGIN_::END_::Alias
+ b = BEGIN_::And.new
+ b._begin = 0;
+ c = BEGIN_::BreakPrx::uncheckedCast(communicator.stringToProxy("test:tcp"))
+ test(c.method(:_case))
+ test(c.method(:_to_a))
+ test(c.method(:_instance_variable_set))
+ test(c.method(:_instance_variables))
+ d1 = BEGIN_::Display.new
+ d1._when = 0
+ d1._do = 0
+ d1._dup = communicator.stringToProxy("test:tcp")
+ d1._else = 0
+ e = BEGIN_::ElsifPrx::uncheckedCast(communicator.stringToProxy("test:tcp"))
+ test(e.method(:_case))
+ f = BEGIN_::Next.new
+ f._new = 0
+ g = BEGIN_::Nil.new
+ g._new = 0
+ g._not = 0
+ g._or = 0
+ # TODO: Test local interface
+ #h = BEGIN_::ExtendPrx::uncheckedCast(communicator.stringToProxy("test:tcp"))
+ i = BEGIN_::Redo
+ puts "ok"
+ end
end
end
-
-def run(args, communicator)
- print "testing type names... "
- STDOUT.flush
- a = BEGIN_::END_::Alias
- b = BEGIN_::And.new
- b._begin = 0;
- c = BEGIN_::BreakPrx::uncheckedCast(communicator.stringToProxy("test:tcp"))
- test(c.method(:_case))
- test(c.method(:_to_a))
- test(c.method(:_instance_variable_set))
- test(c.method(:_instance_variables))
- d1 = BEGIN_::Display.new
- d1._when = 0
- d1._do = 0
- d1._dup = communicator.stringToProxy("test:tcp")
- d1._else = 0
- e = BEGIN_::ElsifPrx::uncheckedCast(communicator.stringToProxy("test:tcp"))
- test(e.method(:_case))
- f = BEGIN_::Next.new
- f._new = 0
- g = BEGIN_::Nil.new
- g._new = 0
- g._not = 0
- g._or = 0
- # TODO: Test local interface
- #h = BEGIN_::ExtendPrx::uncheckedCast(communicator.stringToProxy("test:tcp"))
- i = BEGIN_::Redo
- puts "ok"
-
- return true
-end
-
-begin
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Slice/macros/Client.rb b/ruby/test/Slice/macros/Client.rb
index 3ca2264c996..2c1ac2ae2ce 100755
--- a/ruby/test/Slice/macros/Client.rb
+++ b/ruby/test/Slice/macros/Client.rb
@@ -8,50 +8,24 @@
#
# **********************************************************************
-require 'pathname'
-
-rubyDir = nil
-for toplevel in [".", "..", "../..", "../../..", "../../../.."]
- path = Pathname.new(toplevel).join("ruby", "Ice.rb")
- if path.file?
- rubyDir = Pathname.new(toplevel).join("ruby")
- break
- end
-end
-if not rubyDir
- fail "can't find toplevel directory!"
-end
-
require 'Ice'
Ice::loadSlice('Test.ice')
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ print "testing Slice predefined macros... "
+ STDOUT.flush
+ d = Test::Default.new
+ test(d.x == 10)
+ test(d.y == 10)
+
+ nd = Test::NoDefault.new
+ test(nd.x != 10)
+ test(nd.y != 10)
+
+ c = Test::RubyOnly.new
+ test(c.lang.eql? "ruby")
+ test(c.version == Ice::intVersion())
+ puts "ok"
end
end
-
-status = true
-
-begin
- print "testing Slice predefined macros... "
- STDOUT.flush
- d = Test::Default.new
- test(d.x == 10)
- test(d.y == 10)
-
- nd = Test::NoDefault.new
- test(nd.x != 10)
- test(nd.y != 10)
-
- c = Test::RubyOnly.new
- test(c.lang.eql? "ruby")
- test(c.version == Ice::intVersion())
- puts "ok"
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/Slice/structure/Client.rb b/ruby/test/Slice/structure/Client.rb
index a7d04de2fc1..8a35213e82a 100755
--- a/ruby/test/Slice/structure/Client.rb
+++ b/ruby/test/Slice/structure/Client.rb
@@ -8,216 +8,177 @@
#
# **********************************************************************
-require 'pathname'
-
-rubyDir = nil
-for toplevel in [".", "..", "../..", "../../..", "../../../.."]
- path = Pathname.new(toplevel).join("ruby", "Ice.rb")
- if path.file?
- rubyDir = Pathname.new(toplevel).join("ruby")
- break
- end
-end
-if not rubyDir
- fail "can't find toplevel directory!"
-end
-
require 'Ice'
Ice::loadSlice('Test.ice')
-def test(b)
- if !b
- raise RuntimeError, 'test assertion failed'
+class Client < ::TestHelper
+ def run(args)
+ self.init(args:args) do |communicator|
+ print "testing equals() for Slice structures... "
+ STDOUT.flush
+
+ #
+ # Define some default values.
+ #
+ def_s2 = Test::S2.new(true, 98, 99, 100, 101, 1.0, 2.0, "string", ["one", "two", "three"], {"abc"=>"def"}, \
+ Test::S1.new("name"), Test::C.new(5), communicator.stringToProxy("test"))
+
+ #
+ # Compare default-constructed structures.
+ #
+ test(Test::S2.new.eql?(Test::S2.new))
+
+ #
+ # Change one primitive member at a time.
+ #
+ v = def_s2.clone
+ test(v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.bo = false
+ test(!v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.by = v.by - 1
+ test(!v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.sh = v.sh - 1
+ test(!v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.i = v.i - 1
+ test(!v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.l = v.l - 1
+ test(!v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.f = v.f - 1
+ test(!v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.d = v.d - 1
+ test(!v.eql?(def_s2))
+
+ v = def_s2.clone
+ v.str = ""
+ test(!v.eql?(def_s2))
+
+ #
+ # String member
+ #
+ v1 = def_s2.clone
+ v1.str = "string"
+ test(v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v1.str = nil
+ test(!v1.eql?(v2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v2.str = nil
+ test(!v1.eql?(v2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v1.str = nil
+ v2.str = nil
+ test(v1.eql?(v2))
+
+ #
+ # Sequence member
+ #
+ v1 = def_s2.clone
+ v1.ss = def_s2.ss.clone
+ test(v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v1.ss = []
+ test(!v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v1.ss = ["one", "two", "three"]
+ test(v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v1.ss = nil
+ test(!v1.eql?(v2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v2.ss = nil
+ test(!v1.eql?(v2))
+
+ #
+ # Dictionary member
+ #
+ v1 = def_s2.clone
+ v1.sd = {"abc"=>"def"}
+ test(v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v1.sd = {}
+ test(!v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v1.sd = nil
+ test(!v1.eql?(v2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v2.sd = nil
+ test(!v1.eql?(v2))
+
+ #
+ # Struct member
+ #
+ v1 = def_s2.clone
+ v1.s = def_s2.s.clone
+ test(v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v1.s = Test::S1.new("name")
+ test(v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v1.s = Test::S1.new("noname")
+ test(!v1.eql?(def_s2))
+
+ #
+ # Class member
+ #
+ v1 = def_s2.clone
+ v1.cls = def_s2.cls.clone
+ test(!v1.eql?(def_s2))
+
+ #
+ # Proxy member
+ #
+ v1 = def_s2.clone
+ v1.prx = communicator.stringToProxy("test")
+ test(v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v1.prx = communicator.stringToProxy("test2")
+ test(!v1.eql?(def_s2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v1.prx = nil
+ test(!v1.eql?(v2))
+
+ v1 = def_s2.clone
+ v2 = def_s2.clone
+ v2.prx = nil
+ test(!v1.eql?(v2))
+
+ puts "ok"
+ end
end
end
-
-def allTests(communicator)
- print "testing equals() for Slice structures... "
- STDOUT.flush
-
- #
- # Define some default values.
- #
- def_s2 = Test::S2.new(true, 98, 99, 100, 101, 1.0, 2.0, "string", ["one", "two", "three"], {"abc"=>"def"}, \
- Test::S1.new("name"), Test::C.new(5), communicator.stringToProxy("test"))
-
- #
- # Compare default-constructed structures.
- #
- test(Test::S2.new.eql?(Test::S2.new))
-
- #
- # Change one primitive member at a time.
- #
- v = def_s2.clone
- test(v.eql?(def_s2))
-
- v = def_s2.clone
- v.bo = false
- test(!v.eql?(def_s2))
-
- v = def_s2.clone
- v.by = v.by - 1
- test(!v.eql?(def_s2))
-
- v = def_s2.clone
- v.sh = v.sh - 1
- test(!v.eql?(def_s2))
-
- v = def_s2.clone
- v.i = v.i - 1
- test(!v.eql?(def_s2))
-
- v = def_s2.clone
- v.l = v.l - 1
- test(!v.eql?(def_s2))
-
- v = def_s2.clone
- v.f = v.f - 1
- test(!v.eql?(def_s2))
-
- v = def_s2.clone
- v.d = v.d - 1
- test(!v.eql?(def_s2))
-
- v = def_s2.clone
- v.str = ""
- test(!v.eql?(def_s2))
-
- #
- # String member
- #
- v1 = def_s2.clone
- v1.str = "string"
- test(v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v1.str = nil
- test(!v1.eql?(v2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v2.str = nil
- test(!v1.eql?(v2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v1.str = nil
- v2.str = nil
- test(v1.eql?(v2))
-
- #
- # Sequence member
- #
- v1 = def_s2.clone
- v1.ss = def_s2.ss.clone
- test(v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v1.ss = []
- test(!v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v1.ss = ["one", "two", "three"]
- test(v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v1.ss = nil
- test(!v1.eql?(v2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v2.ss = nil
- test(!v1.eql?(v2))
-
- #
- # Dictionary member
- #
- v1 = def_s2.clone
- v1.sd = {"abc"=>"def"}
- test(v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v1.sd = {}
- test(!v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v1.sd = nil
- test(!v1.eql?(v2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v2.sd = nil
- test(!v1.eql?(v2))
-
- #
- # Struct member
- #
- v1 = def_s2.clone
- v1.s = def_s2.s.clone
- test(v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v1.s = Test::S1.new("name")
- test(v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v1.s = Test::S1.new("noname")
- test(!v1.eql?(def_s2))
-
- #
- # Class member
- #
- v1 = def_s2.clone
- v1.cls = def_s2.cls.clone
- test(!v1.eql?(def_s2))
-
- #
- # Proxy member
- #
- v1 = def_s2.clone
- v1.prx = communicator.stringToProxy("test")
- test(v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v1.prx = communicator.stringToProxy("test2")
- test(!v1.eql?(def_s2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v1.prx = nil
- test(!v1.eql?(v2))
-
- v1 = def_s2.clone
- v2 = def_s2.clone
- v2.prx = nil
- test(!v1.eql?(v2))
-
- puts "ok"
-end
-
-def run(args, communicator)
- allTests(communicator)
-
- return true
-end
-
-begin
- initData = Ice::InitializationData.new
- initData.properties = Ice.createProperties(ARGV)
- communicator = Ice.initialize(ARGV, initData)
- status = run(ARGV, communicator)
-rescue => ex
- puts $!
- print ex.backtrace.join("\n")
- status = false
-end
-
-if communicator
- communicator.destroy()
-end
-
-exit(status ? 0 : 1)
diff --git a/ruby/test/TestHelper.rb b/ruby/test/TestHelper.rb
new file mode 100644
index 00000000000..5ac1e09147b
--- /dev/null
+++ b/ruby/test/TestHelper.rb
@@ -0,0 +1,112 @@
+#!/usr/bin/env ruby
+# **********************************************************************
+#
+# Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+require "Ice"
+
+class TestHelper
+ def initialize
+ @communicator = nil
+ end
+
+ def getTestEndpoint(properties:nil, num:0, protocol:"")
+ if properties.nil?
+ properties = @communicator.getProperties()
+ end
+
+ if protocol.empty?
+ protocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "default")
+ end
+
+ port = properties.getPropertyAsIntWithDefault("Test.BasePort", 12010) + num
+
+ return "#{protocol} -p #{port}"
+ end
+
+ def getTestHost(properties:nil)
+ if properties.nil?
+ properties = @communicator.getProperties()
+ end
+ return properties.getPropertyWithDefault("Ice.Default.Host", "127.0.0.1")
+ end
+
+ def getTestProtocol(properties:nil)
+ if properties.nil?
+ properties = @communicator.getProperties()
+ end
+ return properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp")
+ end
+
+ def getTestPort(properties:nil, num:0)
+ if properties.nil?
+ properties = @communicator.getProperties()
+ end
+ return properties.getPropertyAsIntWithDefault("Test.BasePort", 12010) + num
+ end
+
+ def createTestProperties(args:[])
+ properties = Ice::createProperties(args)
+ properties.parseCommandLineOptions("Test", args)
+ return properties
+ end
+
+ def init(initData:nil, properties:nil, args:[])
+ if initData.nil?
+ initData = Ice::InitializationData.new
+ unless properties.nil?
+ initData.properties = properties
+ else
+ initData.properties = self.createTestProperties(args:args)
+ end
+ end
+
+ communicator = Ice.initialize(initData)
+ if @communicator.nil?
+ @communicator = communicator
+ end
+ begin
+ yield communicator
+ ensure
+ communicator.destroy()
+ end
+ end
+
+ def communicator
+ return @communicator
+ end
+
+ def shutdown
+ unless @communicator.nil?
+ @communicator.shutdown()
+ end
+ end
+
+ def self.run
+ begin
+ moduleName = File.basename(ARGV[0], ".rb")
+ require moduleName
+ cls = Object.const_get moduleName
+ helper = cls.new
+ helper.run(ARGV.drop(1))
+ exit(0)
+ rescue => ex
+ puts $!
+ print ex.backtrace.join("\n")
+ exit(1)
+ end
+ end
+end
+
+def test(b)
+ if !b
+ raise RuntimeError, 'test assertion failed'
+ end
+end
+
+TestHelper.run()