Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Jul 22, 2024
1 parent 7610856 commit e701e97
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 74 deletions.
4 changes: 0 additions & 4 deletions ruby/ruby/Ice/Proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ module Ice
# Provide some common functionality for proxy classes
module Proxy_mixin
module ClassMethods
def inspect
::Ice::__stringify(self, self.class::ICE_TYPE)
end

def ice_staticId()
self::ICE_ID
end
Expand Down
2 changes: 1 addition & 1 deletion ruby/test/Ice/exceptions/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def allTests(helper, communicator)

print "testing checked cast... "
STDOUT.flush
thrower = Test::ThrowerPrx::checkedCast(base)
thrower = Test::ThrowerPrx.checkedCast(base)
test(thrower)
test(thrower == base)
puts "ok"
Expand Down
24 changes: 12 additions & 12 deletions ruby/test/Ice/facets/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ def allTests(helper, communicator)

print "testing checked cast... "
STDOUT.flush
obj = Ice::ObjectPrx::checkedCast(db)
obj = Ice::ObjectPrx.checkedCast(db)
test(obj.ice_getFacet() == "")
obj = Ice::ObjectPrx::checkedCast(db, "facetABCD")
obj = Ice::ObjectPrx.checkedCast(db, "facetABCD")
test(obj.ice_getFacet() == "facetABCD")
obj2 = Ice::ObjectPrx::checkedCast(obj)
obj2 = Ice::ObjectPrx.checkedCast(obj)
test(obj2.ice_getFacet() == "facetABCD")
obj3 = Ice::ObjectPrx::checkedCast(obj, "")
obj3 = Ice::ObjectPrx.checkedCast(obj, "")
test(obj3.ice_getFacet() == "")
d = Test::DPrx::checkedCast(db)
d = Test::DPrx.checkedCast(db)
test(d.ice_getFacet() == "")
df = Test::DPrx::checkedCast(db, "facetABCD")
df = Test::DPrx.checkedCast(db, "facetABCD")
test(df.ice_getFacet() == "facetABCD")
df2 = Test::DPrx::checkedCast(df)
df2 = Test::DPrx.checkedCast(df)
test(df2.ice_getFacet() == "facetABCD")
df3 = Test::DPrx::checkedCast(df, "")
df3 = Test::DPrx.checkedCast(df, "")
test(df3.ice_getFacet() == "")
puts "ok"

Expand All @@ -88,7 +88,7 @@ def allTests(helper, communicator)

print "testing facets A, B, C, and D... "
STDOUT.flush
df = Test::DPrx::checkedCast(d, "facetABCD")
df = Test::DPrx.checkedCast(d, "facetABCD")
test(df)
test(df.callA() == "A")
test(df.callB() == "B")
Expand All @@ -98,22 +98,22 @@ def allTests(helper, communicator)

print "testing facets E and F... "
STDOUT.flush
ff = Test::FPrx::checkedCast(d, "facetEF")
ff = Test::FPrx.checkedCast(d, "facetEF")
test(ff)
test(ff.callE() == "E")
test(ff.callF() == "F")
puts "ok"

print "testing facet G... "
STDOUT.flush
gf = Test::GPrx::checkedCast(ff, "facetGH")
gf = Test::GPrx.checkedCast(ff, "facetGH")
test(gf)
test(gf.callG() == "G")
puts "ok"

print "testing whether casting preserves the facet... "
STDOUT.flush
hf = Test::HPrx::checkedCast(gf)
hf = Test::HPrx.checkedCast(gf)
test(hf)
test(hf.callG() == "G")
test(hf.callH() == "H")
Expand Down
11 changes: 5 additions & 6 deletions ruby/test/Ice/info/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ def allTests(helper, communicator)
defaultHost = communicator.getProperties().getProperty("Ice.Default.Host")
tcpEndpoint = helper.getTestEndpoint()
udpEndpoint = helper.getTestEndpoint(protocol:"udp")
base = communicator.stringToProxy("test:#{tcpEndpoint}:#{udpEndpoint}")
testIntf = Test::TestIntfPrx::checkedCast(base)
testIntf = Test::TestIntfPrx.new(communicator, "test:#{tcpEndpoint}:#{udpEndpoint}")

print "test connection endpoint information..."
STDOUT.flush
port = helper.getTestPort()
tcpinfo = getTCPEndpointInfo(base.ice_getConnection().getEndpoint().getInfo())
tcpinfo = getTCPEndpointInfo(testIntf.ice_getConnection().getEndpoint().getInfo())
test(tcpinfo.port == port)
test(!tcpinfo.compress)
test(tcpinfo.host == defaultHost)
Expand All @@ -86,7 +85,7 @@ def allTests(helper, communicator)
port = Integer(ctx["port"])
test(port > 0)

udp = base.ice_datagram().ice_getConnection().getEndpoint().getInfo()
udp = testIntf.ice_datagram().ice_getConnection().getEndpoint().getInfo()
test(udp.port == port)
test(udp.host == defaultHost)

Expand All @@ -95,7 +94,7 @@ def allTests(helper, communicator)
print "testing connection information..."
STDOUT.flush

connection = base.ice_getConnection()
connection = testIntf.ice_getConnection()
connection.setBufferSize(1024, 2048)

info = connection.getInfo()
Expand All @@ -119,7 +118,7 @@ def allTests(helper, communicator)
test(ctx["remotePort"] == tcpinfo.localPort.to_s())
test(ctx["localPort"] == tcpinfo.remotePort.to_s())

if base.ice_getConnection().type() == "ws" || base.ice_getConnection().type() == "wss"
if testIntf.ice_getConnection().type() == "ws" || testIntf.ice_getConnection().type() == "wss"
test(info.is_a?(Ice::WSConnectionInfo))

test(info.headers["Upgrade"] == "websocket")
Expand Down
39 changes: 19 additions & 20 deletions ruby/test/Ice/location/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ def test(b)

def allTests(helper, communicator)
ref = "ServerManager:#{helper.getTestEndpoint()}"
manager = Test::ServerManagerPrx::checkedCast(communicator.stringToProxy(ref))
manager = Test::ServerManagerPrx.new(communicator, ref)
locator = communicator.getDefaultLocator()
test(manager)

print "testing stringToProxy... "
STDOUT.flush
Expand Down Expand Up @@ -62,18 +61,18 @@ def allTests(helper, communicator)

print "testing checked cast... "
STDOUT.flush
obj = Test::TestIntfPrx::checkedCast(base)
obj = Test::TestIntfPrx::checkedCast(communicator.stringToProxy("test@TestAdapter"))
obj = Test::TestIntfPrx::checkedCast(communicator.stringToProxy("test @TestAdapter"))
obj = Test::TestIntfPrx::checkedCast(communicator.stringToProxy("test@ TestAdapter"))
obj = Test::TestIntfPrx.checkedCast(base)
obj = Test::TestIntfPrx.checkedCast(communicator.stringToProxy("test@TestAdapter"))
obj = Test::TestIntfPrx.checkedCast(communicator.stringToProxy("test @TestAdapter"))
obj = Test::TestIntfPrx.checkedCast(communicator.stringToProxy("test@ TestAdapter"))
test(obj)
obj2 = Test::TestIntfPrx::checkedCast(base2)
obj2 = Test::TestIntfPrx.checkedCast(base2)
test(obj2)
obj3 = Test::TestIntfPrx::checkedCast(base3)
obj3 = Test::TestIntfPrx.checkedCast(base3)
test(obj3)
obj4 = Test::ServerManagerPrx::checkedCast(base4)
obj4 = Test::ServerManagerPrx.checkedCast(base4)
test(obj4)
obj5 = Test::TestIntfPrx::checkedCast(base5)
obj5 = Test::TestIntfPrx.checkedCast(base5)
test(obj5)
puts "ok"

Expand All @@ -82,7 +81,7 @@ def allTests(helper, communicator)
obj.shutdown()
manager.startServer()
begin
obj2 = Test::TestIntfPrx::checkedCast(base2)
obj2 = Test::TestIntfPrx.checkedCast(base2)
obj2.ice_ping()
rescue Ice::LocalException
test(false)
Expand All @@ -94,27 +93,27 @@ def allTests(helper, communicator)
obj.shutdown()
manager.startServer()
begin
obj3 = Test::TestIntfPrx::checkedCast(base3)
obj3 = Test::TestIntfPrx.checkedCast(base3)
obj3.ice_ping()
rescue Ice::LocalException
test(false)
end
begin
obj2 = Test::TestIntfPrx::checkedCast(base2)
obj2 = Test::TestIntfPrx.checkedCast(base2)
obj2.ice_ping()
rescue Ice::LocalException
test(false)
end
obj.shutdown()
manager.startServer()
begin
obj2 = Test::TestIntfPrx::checkedCast(base2)
obj2 = Test::TestIntfPrx.checkedCast(base2)
obj2.ice_ping()
rescue Ice::LocalException
test(false)
end
begin
obj3 = Test::TestIntfPrx::checkedCast(base3)
obj3 = Test::TestIntfPrx.checkedCast(base3)
obj3.ice_ping()
rescue Ice::LocalException
test(false)
Expand All @@ -123,23 +122,23 @@ def allTests(helper, communicator)
manager.startServer()

begin
obj2 = Test::TestIntfPrx::checkedCast(base2)
obj2 = Test::TestIntfPrx.checkedCast(base2)
obj2.ice_ping()
rescue Ice::LocalException
test(false)
end
obj.shutdown()
manager.startServer()
begin
obj3 = Test::TestIntfPrx::checkedCast(base3)
obj3 = Test::TestIntfPrx.checkedCast(base3)
obj3.ice_ping()
rescue Ice::LocalException
test(false)
end
obj.shutdown()
manager.startServer()
begin
obj2 = Test::TestIntfPrx::checkedCast(base2)
obj2 = Test::TestIntfPrx.checkedCast(base2)
obj2.ice_ping()
rescue Ice::LocalException
test(false)
Expand All @@ -148,7 +147,7 @@ def allTests(helper, communicator)
manager.startServer()

begin
obj5 = Test::TestIntfPrx::checkedCast(base5)
obj5 = Test::TestIntfPrx.checkedCast(base5)
obj5.ice_ping()
rescue Ice::LocalException
test(false)
Expand Down Expand Up @@ -194,7 +193,7 @@ def allTests(helper, communicator)

print "testing object migration... "
STDOUT.flush
hello = Test::HelloPrx::checkedCast(communicator.stringToProxy("hello"))
hello = Test::HelloPrx.checkedCast(communicator.stringToProxy("hello"))
obj.migrateHello()
hello.sayHello()
obj.migrateHello()
Expand Down
14 changes: 1 addition & 13 deletions ruby/test/Ice/objects/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,7 @@ def allTests(helper, communicator)
valueFactoryManager.add(factory, '::Test::I')
valueFactoryManager.add(factory, '::Test::J')

print "testing stringToProxy... "
STDOUT.flush
ref = "initial:#{helper.getTestEndpoint()}"
base = communicator.stringToProxy(ref)
test(base)
puts "ok"

print "testing checked cast... "
STDOUT.flush
initial = Test::InitialPrx::checkedCast(base)
test(initial)
test(initial == base)
puts "ok"
initial = Test::InitialPrx.new(communicator, "initial:#{helper.getTestEndpoint()}")

print "getting B1... "
STDOUT.flush
Expand Down
2 changes: 1 addition & 1 deletion ruby/test/Ice/operations/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def allTests(helper, communicator)
ref = "test:#{helper.getTestEndpoint()}"
cl = Test::MyClassPrx.new(communicator, ref)
derived = Test::MyDerivedClassPrx::checkedCast(cl)
derived = Test::MyDerivedClassPrx.checkedCast(cl)

print "testing twoway operations... "
STDOUT.flush
Expand Down
6 changes: 4 additions & 2 deletions ruby/test/Ice/operations/Twoways.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ def twoways(helper, communicator, p)
test(p.ice_getContext().length == 0)
test(r == ctx)

p2 = Test::MyClassPrx::checkedCast(p.ice_context(ctx))
p2 = p.ice_context(ctx)
test(p2.ice_getContext() == ctx)
r = p2.opContext()
test(r == ctx)
Expand All @@ -1183,7 +1183,9 @@ def twoways(helper, communicator, p)
test(p.opStringS2(nil).length == 0)
test(p.opByteBoolD2(nil).length == 0)

d = Test::MyDerivedClassPrx::uncheckedCast(p)
d = Test::MyDerivedClassPrx.uncheckedCast(p)
test(d.class == Test::MyDerivedClassPrx)

s = Test::MyStruct1.new
s.tesT = "Test.MyStruct1.s"
s.myClass = nil
Expand Down
16 changes: 8 additions & 8 deletions ruby/test/Ice/proxy/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -586,28 +586,28 @@ def allTests(helper, communicator)

print "testing checked cast... "
STDOUT.flush
cl = Test::MyClassPrx::checkedCast(base)
cl = Test::MyClassPrx.checkedCast(base)
test(cl)

derived = Test::MyDerivedClassPrx::checkedCast(cl)
derived = Test::MyDerivedClassPrx.checkedCast(cl)
test(derived)
test(cl == base)
test(derived == base)
test(cl == derived)
begin
Test::MyDerivedClassPrx::checkedCast(cl, "facet")
Test::MyDerivedClassPrx.checkedCast(cl, "facet")
test(false)
rescue Ice::FacetNotExistException
end

loc = Ice::LocatorPrx::checkedCast(base)
loc = Ice::LocatorPrx.checkedCast(base)
test(loc == nil)

#
# Upcasting
#
cl2 = Test::MyClassPrx::checkedCast(derived)
obj = Ice::ObjectPrx::checkedCast(derived)
cl2 = Test::MyClassPrx.checkedCast(derived)
obj = Ice::ObjectPrx.checkedCast(derived)
test(cl2)
test(obj)
test(cl2 == obj)
Expand All @@ -617,14 +617,14 @@ def allTests(helper, communicator)

print "testing checked cast with context... "
STDOUT.flush
tccp = Test::MyClassPrx::checkedCast(base)
tccp = Test::MyClassPrx.checkedCast(base)
c = tccp.getContext()
test(c == nil || c.length == 0)

c = { }
c["one"] = "hello"
c["two"] = "world"
tccp = Test::MyClassPrx::checkedCast(base, c)
tccp = Test::MyClassPrx.checkedCast(base, c)
c2 = tccp.getContext()
test(c == c2)
puts "ok"
Expand Down
8 changes: 4 additions & 4 deletions ruby/test/Ice/scope/AllTests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def allTests(helper, communicator)
print "test using same type name in different Slice modules... "
STDOUT.flush

i1 = Test::IPrx::checkedCast(communicator.stringToProxy("i1:#{helper.getTestEndpoint()}"))
i1 = Test::IPrx.new(communicator, "i1:#{helper.getTestEndpoint()}")

s1 = Test::S.new(0)
s2, s3 = i1.opS(s1)
Expand Down Expand Up @@ -50,7 +50,7 @@ def allTests(helper, communicator)
c = i1.opC1(Test::C1.new("C1"))
test(c.s == "C1")

i2 = Test::Inner::Inner2::IPrx::checkedCast(Ice::ObjectPrx.new(communicator, "i2:#{helper.getTestEndpoint()}"))
i2 = Test::Inner::Inner2::IPrx.new(communicator, "i2:#{helper.getTestEndpoint()}")

s1 = Test::Inner::Inner2::S.new(0)
s2, s3 = i2.opS(s1)
Expand Down Expand Up @@ -84,7 +84,7 @@ def allTests(helper, communicator)
test(cmap2["a"].s == s1)
test(cmap3["a"].s == s1)

i3 = Test::Inner::IPrx::checkedCast(communicator.stringToProxy("i3:#{helper.getTestEndpoint()}"))
i3 = Test::Inner::IPrx.new(communicator, "i3:#{helper.getTestEndpoint()}")

s1 = Test::Inner::Inner2::S.new(0)
s2, s3 = i3.opS(s1)
Expand Down Expand Up @@ -118,7 +118,7 @@ def allTests(helper, communicator)
test(cmap2["a"].s == s1)
test(cmap3["a"].s == s1)

i4 = Inner::Test::Inner2::IPrx::checkedCast(communicator.stringToProxy("i4:#{helper.getTestEndpoint()}"))
i4 = Inner::Test::Inner2::IPrx.new(communicator, "i4:#{helper.getTestEndpoint()}")

s1 = Test::S.new(0)
s2, s3 = i4.opS(s1)
Expand Down
Loading

0 comments on commit e701e97

Please sign in to comment.