summaryrefslogtreecommitdiff
path: root/cpp/test/Ice
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-03-23 15:29:25 +0100
committerBenoit Foucher <benoit@zeroc.com>2017-03-23 15:29:25 +0100
commit1597a75419cd8049252cfbca6fce6ae95ef8b2c7 (patch)
tree2b2c858df1dbe68c1d576cae06c4713fd2ad5c40 /cpp/test/Ice
parentUse Ice\None with PHP namespace mapping (diff)
downloadice-1597a75419cd8049252cfbca6fce6ae95ef8b2c7.tar.bz2
ice-1597a75419cd8049252cfbca6fce6ae95ef8b2c7.tar.xz
ice-1597a75419cd8049252cfbca6fce6ae95ef8b2c7.zip
Fix for ICE-7125 - Added support for Ice.ClassGraphDepthMax
Diffstat (limited to 'cpp/test/Ice')
-rw-r--r--cpp/test/Ice/echo/BlobjectI.cpp41
-rw-r--r--cpp/test/Ice/echo/BlobjectI.h6
-rw-r--r--cpp/test/Ice/echo/Server.cpp5
-rw-r--r--cpp/test/Ice/echo/Test.ice1
-rw-r--r--cpp/test/Ice/echo/test.py5
-rw-r--r--cpp/test/Ice/exceptions/AllTests.cpp40
-rw-r--r--cpp/test/Ice/objects/AllTests.cpp32
-rw-r--r--cpp/test/Ice/objects/Collocated.cpp1
-rw-r--r--cpp/test/Ice/objects/Server.cpp1
-rw-r--r--cpp/test/Ice/objects/Test.ice8
-rw-r--r--cpp/test/Ice/objects/TestI.cpp11
-rw-r--r--cpp/test/Ice/objects/TestI.h3
12 files changed, 135 insertions, 19 deletions
diff --git a/cpp/test/Ice/echo/BlobjectI.cpp b/cpp/test/Ice/echo/BlobjectI.cpp
index 024b239ac4f..894e217569c 100644
--- a/cpp/test/Ice/echo/BlobjectI.cpp
+++ b/cpp/test/Ice/echo/BlobjectI.cpp
@@ -54,6 +54,14 @@ BlobjectI::BlobjectI() :
}
void
+BlobjectI::setConnection(const Ice::ConnectionPtr& connection)
+{
+ Lock sync(*this);
+ _connection = connection;
+ notifyAll();
+}
+
+void
BlobjectI::startBatch()
{
assert(!_batchProxy);
@@ -75,8 +83,9 @@ BlobjectI::ice_invokeAsync(std::vector<Ice::Byte> inEncaps,
std::function<void(std::exception_ptr)> ex,
const Ice::Current& current)
{
+ auto connection = getConnection(current);
const bool twoway = current.requestId > 0;
- auto obj = current.con->createProxy(current.id);
+ auto obj = connection->createProxy(current.id);
if(!twoway)
{
if(_startBatch)
@@ -124,8 +133,9 @@ void
BlobjectI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCb, const vector<Ice::Byte>& inEncaps,
const Ice::Current& current)
{
+ Ice::ConnectionPtr connection = getConnection(current);
const bool twoway = current.requestId > 0;
- Ice::ObjectPrx obj = current.con->createProxy(current.id);
+ Ice::ObjectPrx obj = connection->createProxy(current.id);
if(!twoway)
{
if(_startBatch)
@@ -171,3 +181,30 @@ BlobjectI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& amdCb, const ve
}
}
#endif
+
+Ice::ConnectionPtr
+BlobjectI::getConnection(const Ice::Current& current)
+{
+ Lock sync(*this);
+ if(!_connection)
+ {
+ return current.con;
+ }
+
+ try
+ {
+ _connection->throwException();
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ // If we lost the connection, wait 5 seconds for the server to re-establish it. Some tests,
+ // involve connection closure (e.g.: exceptions MemoryLimitException test) and the server
+ // automatically re-establishes the connection with the echo server.
+ timedWait(IceUtil::Time::seconds(5));
+ if(!_connection)
+ {
+ throw;
+ }
+ }
+ return _connection;
+}
diff --git a/cpp/test/Ice/echo/BlobjectI.h b/cpp/test/Ice/echo/BlobjectI.h
index fe8091c8f88..16db90e0b5c 100644
--- a/cpp/test/Ice/echo/BlobjectI.h
+++ b/cpp/test/Ice/echo/BlobjectI.h
@@ -12,7 +12,7 @@
#include <Ice/Object.h>
-class BlobjectI : public Ice::BlobjectAsync
+class BlobjectI : public Ice::BlobjectAsync, private IceUtil::Monitor<IceUtil::Mutex>
{
public:
@@ -20,6 +20,7 @@ public:
void startBatch();
void flushBatch();
+ void setConnection(const Ice::ConnectionPtr&);
#ifdef ICE_CPP11_MAPPING
@@ -35,8 +36,11 @@ public:
private:
+ Ice::ConnectionPtr getConnection(const Ice::Current&);
+
bool _startBatch;
Ice::ObjectPrxPtr _batchProxy;
+ Ice::ConnectionPtr _connection;
};
ICE_DEFINE_PTR(BlobjectIPtr, BlobjectI);
diff --git a/cpp/test/Ice/echo/Server.cpp b/cpp/test/Ice/echo/Server.cpp
index 56cd9f534bf..b0576241b02 100644
--- a/cpp/test/Ice/echo/Server.cpp
+++ b/cpp/test/Ice/echo/Server.cpp
@@ -25,6 +25,11 @@ public:
{
}
+ virtual void setConnection(const Ice::Current& current)
+ {
+ _blob->setConnection(current.con);
+ }
+
virtual void startBatch(const Ice::Current&)
{
_blob->startBatch();
diff --git a/cpp/test/Ice/echo/Test.ice b/cpp/test/Ice/echo/Test.ice
index 57f7e92da21..7cf7ec721bd 100644
--- a/cpp/test/Ice/echo/Test.ice
+++ b/cpp/test/Ice/echo/Test.ice
@@ -17,6 +17,7 @@ module Test
//
interface Echo
{
+ void setConnection();
void startBatch();
void flushBatch();
void shutdown();
diff --git a/cpp/test/Ice/echo/test.py b/cpp/test/Ice/echo/test.py
index 3f25f4bfa15..717826f73a2 100644
--- a/cpp/test/Ice/echo/test.py
+++ b/cpp/test/Ice/echo/test.py
@@ -9,7 +9,10 @@
class EchoServerTestCase(ClientServerTestCase):
+ def __init__(self):
+ ClientServerTestCase.__init__(self, "server", server=Server(quiet=True, waitForShutdown=False))
+
def runClientSide(self, current):
pass
-TestSuite(__name__, [EchoServerTestCase(name="server", server=Server(quiet=True, waitForShutdown=False))])
+TestSuite(__name__, [EchoServerTestCase()])
diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp
index 7fb9c1a930a..32302c5c6d8 100644
--- a/cpp/test/Ice/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/exceptions/AllTests.cpp
@@ -988,32 +988,42 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::ConnectionLostException&)
{
}
+ catch(const Ice::UnknownLocalException&)
+ {
+ // Expected with JS bidir server
+ }
catch(const Ice::LocalException& ex)
{
cerr << ex << endl;
test(false);
}
- ThrowerPrxPtr thrower2 =
- ICE_UNCHECKED_CAST(ThrowerPrx, communicator->stringToProxy("thrower:" + getTestEndpoint(communicator, 1)));
- try
- {
- thrower2->throwMemoryLimitException(Ice::ByteSeq(2 * 1024 * 1024)); // 2MB (no limits)
- }
- catch(const Ice::MemoryLimitException&)
- {
- }
- ThrowerPrxPtr thrower3 =
- ICE_UNCHECKED_CAST(ThrowerPrx, communicator->stringToProxy("thrower:" + getTestEndpoint(communicator, 2)));
try
{
- thrower3->throwMemoryLimitException(Ice::ByteSeq(1024)); // 1KB limit
- test(false);
+ ThrowerPrxPtr thrower2 =
+ ICE_UNCHECKED_CAST(ThrowerPrx, communicator->stringToProxy("thrower:" + getTestEndpoint(communicator, 1)));
+ try
+ {
+ thrower2->throwMemoryLimitException(Ice::ByteSeq(2 * 1024 * 1024)); // 2MB (no limits)
+ }
+ catch(const Ice::MemoryLimitException&)
+ {
+ }
+ ThrowerPrxPtr thrower3 =
+ ICE_UNCHECKED_CAST(ThrowerPrx, communicator->stringToProxy("thrower:" + getTestEndpoint(communicator, 2)));
+ try
+ {
+ thrower3->throwMemoryLimitException(Ice::ByteSeq(1024)); // 1KB limit
+ test(false);
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ }
}
- catch(const Ice::ConnectionLostException&)
+ catch(const Ice::ConnectionRefusedException&)
{
+ // Expected with JS bidir server
}
-
cout << "ok" << endl;
}
diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp
index 5e6ba0460b8..95d44d6b962 100644
--- a/cpp/test/Ice/objects/AllTests.cpp
+++ b/cpp/test/Ice/objects/AllTests.cpp
@@ -323,6 +323,38 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(retS.size() == 1 && outS.size() == 1);
cout << "ok" << endl;
+ cout << "testing recursive type... " << flush;
+ RecursivePtr top = ICE_MAKE_SHARED(Recursive);
+ RecursivePtr p = top;
+ int depth = 0;
+ try
+ {
+ for(; depth <= 2000; ++depth)
+ {
+ p->v = ICE_MAKE_SHARED(Recursive);
+ p = p->v;
+ if((depth < 10 && (depth % 10) == 0) ||
+ (depth < 1000 && (depth % 100) == 0) ||
+ (depth < 10000 && (depth % 1000) == 0) ||
+ (depth % 10000) == 0)
+ {
+ initial->setRecursive(top);
+ }
+ }
+ test(!initial->supportsClassGraphDepthMax());
+ }
+ catch(const Ice::UnknownLocalException&)
+ {
+ // Expected marshal exception from the server (max class graph depth reached)
+ test(depth == 100); // The default is 100.
+ }
+ catch(const Ice::UnknownException&)
+ {
+ // Expected stack overflow from the server (Java only)
+ }
+ initial->setRecursive(ICE_MAKE_SHARED(Recursive));
+ cout << "ok" << endl;
+
cout << "testing compact ID..." << flush;
try
{
diff --git a/cpp/test/Ice/objects/Collocated.cpp b/cpp/test/Ice/objects/Collocated.cpp
index 60330b7061b..8c2d71b399b 100644
--- a/cpp/test/Ice/objects/Collocated.cpp
+++ b/cpp/test/Ice/objects/Collocated.cpp
@@ -154,6 +154,7 @@ main(int argc, char* argv[])
try
{
Ice::InitializationData initData = getTestInitData(argc, argv);
+ initData.properties->setProperty("Ice.Warn.Dispatch", "0");
Ice::CommunicatorHolder ich(argc, argv, initData);
return run(argc, argv, ich.communicator());
}
diff --git a/cpp/test/Ice/objects/Server.cpp b/cpp/test/Ice/objects/Server.cpp
index 991233bfa0a..a501281b29b 100644
--- a/cpp/test/Ice/objects/Server.cpp
+++ b/cpp/test/Ice/objects/Server.cpp
@@ -88,6 +88,7 @@ main(int argc, char* argv[])
try
{
Ice::InitializationData initData = getTestInitData(argc, argv);
+ initData.properties->setProperty("Ice.Warn.Dispatch", "0");
Ice::CommunicatorHolder ich(argc, argv, initData);
return run(argc, argv, ich.communicator());
}
diff --git a/cpp/test/Ice/objects/Test.ice b/cpp/test/Ice/objects/Test.ice
index 134a1aa2ea5..7d64f20614e 100644
--- a/cpp/test/Ice/objects/Test.ice
+++ b/cpp/test/Ice/objects/Test.ice
@@ -167,6 +167,11 @@ exception EDerived extends EBase
A1 a4;
};
+class Recursive
+{
+ Recursive v;
+};
+
interface Initial
{
void shutdown();
@@ -177,6 +182,9 @@ interface Initial
E getE();
F getF();
+ void setRecursive(Recursive p);
+ bool supportsClassGraphDepthMax();
+
["marshaled-result"] B getMB();
["amd", "marshaled-result"] B getAMDMB();
diff --git a/cpp/test/Ice/objects/TestI.cpp b/cpp/test/Ice/objects/TestI.cpp
index f17e1a7960d..803a278fba7 100644
--- a/cpp/test/Ice/objects/TestI.cpp
+++ b/cpp/test/Ice/objects/TestI.cpp
@@ -161,6 +161,17 @@ InitialI::getF(const Ice::Current&)
return _f;
}
+void
+InitialI::setRecursive(ICE_IN(RecursivePtr), const Ice::Current&)
+{
+}
+
+bool
+InitialI::supportsClassGraphDepthMax(const Ice::Current&)
+{
+ return true;
+}
+
#ifdef ICE_CPP11_MAPPING
InitialI::GetMBMarshaledResult
InitialI::getMB(const Ice::Current& current)
diff --git a/cpp/test/Ice/objects/TestI.h b/cpp/test/Ice/objects/TestI.h
index a7243ed95f6..1a467fc0f33 100644
--- a/cpp/test/Ice/objects/TestI.h
+++ b/cpp/test/Ice/objects/TestI.h
@@ -94,6 +94,9 @@ public:
virtual Test::EPtr getE(const Ice::Current&);
virtual Test::FPtr getF(const Ice::Current&);
+ virtual void setRecursive(ICE_IN(Test::RecursivePtr), const Ice::Current&);
+ virtual bool supportsClassGraphDepthMax(const Ice::Current&);
+
#ifdef ICE_CPP11_MAPPING
virtual GetMBMarshaledResult getMB(const Ice::Current&);
virtual void getAMDMBAsync(std::function<void(const GetAMDMBMarshaledResult&)>,