summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2015-12-18 14:05:33 +0100
committerJose <jose@zeroc.com>2015-12-18 14:05:33 +0100
commit9ae75237e0784fd302d94b5dd2ec34e42d2c3681 (patch)
tree7e0a96821ce32d734ce3cf39e1d9f8ab5435bbd1 /cpp
parentDisable running C++11 travis tests (diff)
downloadice-9ae75237e0784fd302d94b5dd2ec34e42d2c3681.tar.bz2
ice-9ae75237e0784fd302d94b5dd2ec34e42d2c3681.tar.xz
ice-9ae75237e0784fd302d94b5dd2ec34e42d2c3681.zip
C++11 background & metrics test fixes
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp4
-rw-r--r--cpp/test/Ice/Makefile1
-rw-r--r--cpp/test/Ice/background/AllTests.cpp554
-rw-r--r--cpp/test/Ice/background/Client.cpp4
-rw-r--r--cpp/test/Ice/background/EndpointFactory.cpp4
-rw-r--r--cpp/test/Ice/background/EndpointI.cpp40
-rw-r--r--cpp/test/Ice/background/EndpointI.h10
-rw-r--r--cpp/test/Ice/background/Server.cpp75
-rw-r--r--cpp/test/Ice/background/TestI.cpp6
-rw-r--r--cpp/test/Ice/background/TestI.h9
-rw-r--r--cpp/test/Ice/metrics/Client.cpp29
-rw-r--r--cpp/test/Ice/metrics/Collocated.cpp34
-rw-r--r--cpp/test/Ice/metrics/Server.cpp30
-rw-r--r--cpp/test/Ice/metrics/ServerAMD.cpp27
-rw-r--r--cpp/test/Ice/metrics/TestI.cpp4
-rw-r--r--cpp/test/Ice/metrics/TestI.h5
-rw-r--r--cpp/test/Ice/stringConverter/Server.cpp4
17 files changed, 640 insertions, 200 deletions
diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp
index 68db941c94b..9516548a5be 100644
--- a/cpp/src/Ice/LocatorInfo.cpp
+++ b/cpp/src/Ice/LocatorInfo.cpp
@@ -59,7 +59,7 @@ public:
{
rethrow_exception(e);
}
- catch(const UserException& ex)
+ catch(const Exception& ex)
{
request->exception(ex);
}
@@ -105,7 +105,7 @@ public:
{
rethrow_exception(e);
}
- catch(const UserException& ex)
+ catch(const Exception& ex)
{
request->exception(ex);
}
diff --git a/cpp/test/Ice/Makefile b/cpp/test/Ice/Makefile
index 5085b670842..d54b1130182 100644
--- a/cpp/test/Ice/Makefile
+++ b/cpp/test/Ice/Makefile
@@ -34,6 +34,7 @@ SUBDIRS = proxy \
acm \
servantLocator \
interceptor \
+ stringConverter \
udp \
defaultServant \
defaultValue \
diff --git a/cpp/test/Ice/background/AllTests.cpp b/cpp/test/Ice/background/AllTests.cpp
index 900a611bfa7..27d99e14f19 100644
--- a/cpp/test/Ice/background/AllTests.cpp
+++ b/cpp/test/Ice/background/AllTests.cpp
@@ -143,9 +143,9 @@ class OpThread : public IceUtil::Thread, public IceUtil::Mutex
{
public:
- OpThread(const BackgroundPrx& background) :
+ OpThread(const BackgroundPrxPtr& background) :
_destroyed(false),
- _background(BackgroundPrx::uncheckedCast(background->ice_oneway()))
+ _background(ICE_UNCHECKED_CAST(BackgroundPrx, background->ice_oneway()))
{
start();
}
@@ -171,7 +171,11 @@ public:
count = 0;
_background->ice_twoway()->ice_ping();
}
+#ifdef ICE_CPP11_MAPPING
+ _background->op_async();
+#else
_background->begin_op();
+#endif
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1));
}
catch(const Ice::LocalException&)
@@ -190,32 +194,36 @@ public:
private:
bool _destroyed;
- BackgroundPrx _background;
+ BackgroundPrxPtr _background;
};
typedef IceUtil::Handle<OpThread> OpThreadPtr;
-void connectTests(const ConfigurationPtr&, const Test::BackgroundPrx&);
-void initializeTests(const ConfigurationPtr&, const Test::BackgroundPrx&, const Test::BackgroundControllerPrx&);
-void validationTests(const ConfigurationPtr&, const Test::BackgroundPrx&, const Test::BackgroundControllerPrx&);
-void readWriteTests(const ConfigurationPtr&, const Test::BackgroundPrx&, const Test::BackgroundControllerPrx&);
+void connectTests(const ConfigurationPtr&, const Test::BackgroundPrxPtr&);
+void initializeTests(const ConfigurationPtr&, const Test::BackgroundPrxPtr&, const Test::BackgroundControllerPrxPtr&);
+void validationTests(const ConfigurationPtr&, const Test::BackgroundPrxPtr&, const Test::BackgroundControllerPrxPtr&);
+void readWriteTests(const ConfigurationPtr&, const Test::BackgroundPrxPtr&, const Test::BackgroundControllerPrxPtr&);
-BackgroundPrx
+BackgroundPrxPtr
allTests(const Ice::CommunicatorPtr& communicator)
{
const string endp = getTestEndpoint(communicator, 0);
string sref = "background:" + endp;
- Ice::ObjectPrx obj = communicator->stringToProxy(sref);
+ Ice::ObjectPrxPtr obj = communicator->stringToProxy(sref);
test(obj);
- BackgroundPrx background = BackgroundPrx::uncheckedCast(obj);
+ BackgroundPrxPtr background = ICE_UNCHECKED_CAST(BackgroundPrx, obj);
sref = "backgroundController:" + getTestEndpoint(communicator, 1, "tcp");
obj = communicator->stringToProxy(sref);
test(obj);
- BackgroundControllerPrx backgroundController = BackgroundControllerPrx::uncheckedCast(obj);
+ BackgroundControllerPrxPtr backgroundController = ICE_UNCHECKED_CAST(BackgroundControllerPrx, obj);
+#ifdef ICE_CPP11_MAPPING
+ auto plugin = dynamic_pointer_cast<PluginI>(communicator->getPluginManager()->getPlugin("Test"));
+#else
PluginI* plugin = dynamic_cast<PluginI*>(communicator->getPluginManager()->getPlugin("Test").get());
+#endif
assert(plugin);
ConfigurationPtr configuration = plugin->getConfiguration();
@@ -245,9 +253,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing locator... " << flush;
{
- Ice::LocatorPrx locator;
+ Ice::LocatorPrxPtr locator;
obj = communicator->stringToProxy("locator:" + endp)->ice_invocationTimeout(250);
- locator = Ice::LocatorPrx::uncheckedCast(obj);
+ locator = ICE_UNCHECKED_CAST(Ice::LocatorPrx, obj);
obj = communicator->stringToProxy("background@Test")->ice_locator(locator)->ice_oneway();
backgroundController->pauseCall("findAdapterById");
@@ -262,13 +270,32 @@ allTests(const Ice::CommunicatorPtr& communicator)
backgroundController->resumeCall("findAdapterById");
obj = communicator->stringToProxy("locator:" + endp);
- locator = Ice::LocatorPrx::uncheckedCast(obj);
+ locator = ICE_UNCHECKED_CAST(Ice::LocatorPrx, obj);
obj = obj->ice_locator(locator);
obj->ice_ping();
-
obj = communicator->stringToProxy("background@Test")->ice_locator(locator);
- BackgroundPrx bg = BackgroundPrx::uncheckedCast(obj);
+ BackgroundPrxPtr bg = ICE_UNCHECKED_CAST(BackgroundPrx, obj);
+#ifdef ICE_CPP11_MAPPING
+ backgroundController->pauseCall("findAdapterById");
+
+ promise<void> p1;
+ promise<void> p2;
+
+ bg->op_async([&p1](){ p1.set_value(); }, [&p1](exception_ptr e){ p1.set_exception(e); });
+ bg->op_async([&p2](){ p2.set_value(); }, [&p2](exception_ptr e){ p2.set_exception(e); });
+
+ auto f1 = p1.get_future();
+ auto f2 = p2.get_future();
+
+ test(f1.wait_for(chrono::milliseconds(1)) != future_status::ready);
+ test(f2.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ backgroundController->resumeCall("findAdapterById");
+
+ f1.get();
+ f2.get();
+#else
backgroundController->pauseCall("findAdapterById");
Ice::AsyncResultPtr r1 = bg->begin_op();
Ice::AsyncResultPtr r2 = bg->begin_op();
@@ -279,15 +306,15 @@ allTests(const Ice::CommunicatorPtr& communicator)
bg->end_op(r2);
test(r1->isCompleted());
test(r2->isCompleted());
+#endif
}
cout << "ok" << endl;
cout << "testing router... " << flush;
{
- Ice::RouterPrx router;
-
+ Ice::RouterPrxPtr router;
obj = communicator->stringToProxy("router:" + endp)->ice_invocationTimeout(250);
- router = Ice::RouterPrx::uncheckedCast(obj);
+ router = ICE_UNCHECKED_CAST(Ice::RouterPrx, obj);
obj = communicator->stringToProxy("background@Test")->ice_router(router)->ice_oneway();
backgroundController->pauseCall("getClientProxy");
@@ -302,11 +329,31 @@ allTests(const Ice::CommunicatorPtr& communicator)
backgroundController->resumeCall("getClientProxy");
obj = communicator->stringToProxy("router:" + endp);
- router = Ice::RouterPrx::uncheckedCast(obj);
+ router = ICE_UNCHECKED_CAST(Ice::RouterPrx, obj);
obj = communicator->stringToProxy("background@Test")->ice_router(router);
- BackgroundPrx bg = BackgroundPrx::uncheckedCast(obj);
+ BackgroundPrxPtr bg = ICE_UNCHECKED_CAST(BackgroundPrx, obj);
test(bg->ice_getRouter());
+#ifdef ICE_CPP11_MAPPING
+ backgroundController->pauseCall("getClientProxy");
+
+ promise<void> p1;
+ promise<void> p2;
+
+ bg->op_async([&p1](){ p1.set_value(); }, [&p1](exception_ptr e){ p1.set_exception(e); });
+ bg->op_async([&p2](){ p2.set_value(); }, [&p2](exception_ptr e){ p2.set_exception(e); });
+
+ auto f1 = p1.get_future();
+ auto f2 = p2.get_future();
+
+ test(f1.wait_for(chrono::milliseconds(1)) != future_status::ready);
+ test(f2.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ backgroundController->resumeCall("getClientProxy");
+
+ f1.get();
+ f2.get();
+#else
backgroundController->pauseCall("getClientProxy");
Ice::AsyncResultPtr r1 = bg->begin_op();
Ice::AsyncResultPtr r2 = bg->begin_op();
@@ -317,6 +364,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
bg->end_op(r2);
test(r1->isCompleted());
test(r2->isCompleted());
+#endif
}
cout << "ok" << endl;
@@ -328,6 +376,36 @@ allTests(const Ice::CommunicatorPtr& communicator)
configuration->buffered(true);
backgroundController->buffered(true);
+
+#ifdef ICE_CPP11_MAPPING
+ background->op_async();
+ background->ice_getCachedConnection()->close(true);
+ background->op_async();
+
+ vector<future<void>> results;
+ for(int i = 0; i < 10000; ++i)
+ {
+ auto f = background->op_async();
+ if(i % 50 == 0)
+ {
+ backgroundController->holdAdapter();
+ backgroundController->resumeAdapter();
+ }
+ if(i % 100 == 0)
+ {
+ f.get();
+ }
+ else
+ {
+ results.push_back(move(f));
+ }
+ }
+
+ for(auto& f : results)
+ {
+ f.get(); // Ensure all the calls are completed before destroying the communicator
+ }
+#else
background->begin_op();
background->ice_getCachedConnection()->close(true);
background->begin_op();
@@ -356,7 +434,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
(*p)->waitForCompleted(); // Ensure all the calls are completed before destroying the communicator
}
-
+#endif
cout << "ok" << endl;
}
@@ -364,7 +442,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
}
void
-connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrx& background)
+connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrxPtr& background)
{
try
{
@@ -387,7 +465,7 @@ connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrx& b
{
configuration->connectException(new Ice::SocketException(__FILE__, __LINE__));
}
- BackgroundPrx prx = (i == 1 || i == 3) ? background : background->ice_oneway();
+ BackgroundPrxPtr prx = (i == 1 || i == 3) ? background : background->ice_oneway();
try
{
@@ -397,7 +475,48 @@ connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrx& b
catch(const Ice::Exception&)
{
}
+#ifdef ICE_CPP11_MAPPING
+ {
+ promise<void> completed;
+ promise<bool> sent;
+ prx->op_async(
+ [&completed]()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr)
+ {
+ completed.set_value();
+ },
+ [&sent](bool value)
+ {
+ sent.set_value(value);
+ });
+ test(sent.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+ completed.get_future().get();
+ }
+ {
+ promise<void> completed;
+ promise<bool> sent;
+
+ prx->op_async(
+ [&completed]()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr)
+ {
+ completed.set_value();
+ },
+ [&sent](bool value)
+ {
+ sent.set_value(value);
+ });
+ test(sent.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+ completed.get_future().get();
+ }
+#else
Ice::AsyncResultPtr r = prx->begin_op();
test(!r->sentSynchronously());
try
@@ -409,13 +528,13 @@ connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrx& b
{
}
test(r->isCompleted());
-
+
OpAMICallbackPtr cbEx = new OpAMICallback();
r = prx->begin_op(Test::newCallback_Background_op(cbEx, &OpAMICallback::exception));
test(!r->sentSynchronously());
cbEx->checkException();
test(r->isCompleted());
-
+#endif
if(i == 0 || i == 2)
{
configuration->connectorsException(0);
@@ -462,8 +581,8 @@ connectTests(const ConfigurationPtr& configuration, const Test::BackgroundPrx& b
void
initializeTests(const ConfigurationPtr& configuration,
- const Test::BackgroundPrx& background,
- const Test::BackgroundControllerPrx& ctl)
+ const Test::BackgroundPrxPtr& background,
+ const Test::BackgroundControllerPrxPtr& ctl)
{
try
{
@@ -491,7 +610,7 @@ initializeTests(const ConfigurationPtr& configuration,
configuration->initializeException(new Ice::SocketException(__FILE__, __LINE__));
#endif
}
- BackgroundPrx prx = (i == 1 || i == 3) ? background : background->ice_oneway();
+ BackgroundPrxPtr prx = (i == 1 || i == 3) ? background : background->ice_oneway();
try
{
@@ -502,6 +621,26 @@ initializeTests(const ConfigurationPtr& configuration,
{
}
+#ifdef ICE_CPP11_MAPPING
+ promise<bool> sent;
+ promise<void> completed;
+
+ prx->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr)
+ {
+ completed.set_value();
+ },
+ [&sent](bool value)
+ {
+ sent.set_value(value);
+ });
+ test(sent.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+ completed.get_future().get();
+#else
Ice::AsyncResultPtr r = prx->begin_op();
test(!r->sentSynchronously());
try
@@ -519,7 +658,7 @@ initializeTests(const ConfigurationPtr& configuration,
test(!r->sentSynchronously());
cbEx->checkException();
test(r->isCompleted());
-
+#endif
if(i == 0 || i == 2)
{
configuration->initializeException(0);
@@ -697,8 +836,8 @@ initializeTests(const ConfigurationPtr& configuration,
void
validationTests(const ConfigurationPtr& configuration,
- const Test::BackgroundPrx& background,
- const Test::BackgroundControllerPrx& ctl)
+ const Test::BackgroundPrxPtr& background,
+ const Test::BackgroundControllerPrxPtr& ctl)
{
try
{
@@ -731,7 +870,27 @@ validationTests(const ConfigurationPtr& configuration,
for(i = 0; i < 2; i++)
{
configuration->readException(new Ice::SocketException(__FILE__, __LINE__));
- BackgroundPrx prx = i == 0 ? background : background->ice_oneway();
+ BackgroundPrxPtr prx = i == 0 ? background : background->ice_oneway();
+#ifdef ICE_CPP11_MAPPING
+ promise<bool> sent;
+ promise<void> completed;
+
+ prx->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr)
+ {
+ completed.set_value();
+ },
+ [&sent](bool value)
+ {
+ sent.set_value(value);
+ });
+ test(sent.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+ completed.get_future().get();
+#else
Ice::AsyncResultPtr r = prx->begin_op();
test(!r->sentSynchronously());
try
@@ -743,6 +902,7 @@ validationTests(const ConfigurationPtr& configuration,
{
}
test(r->isCompleted());
+#endif
configuration->readException(0);
}
@@ -786,6 +946,30 @@ validationTests(const ConfigurationPtr& configuration,
{
configuration->readReady(false);
configuration->readException(new Ice::SocketException(__FILE__, __LINE__));
+#ifdef ICE_CPP11_MAPPING
+ promise<void> completed;
+ background->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr err)
+ {
+ try
+ {
+ rethrow_exception(err);
+ }
+ catch(const Ice::SocketException&)
+ {
+ completed.set_value();
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ });
+ completed.get_future().get();
+#else
Ice::AsyncResultPtr r = background->begin_op();
test(!r->sentSynchronously());
try
@@ -797,12 +981,62 @@ validationTests(const ConfigurationPtr& configuration,
{
}
test(r->isCompleted());
+#endif
configuration->readException(0);
configuration->readReady(true);
}
}
ctl->holdAdapter(); // Hold to block in connection validation
+#ifdef ICE_CPP11_MAPPING
+ promise<void> p1;
+ promise<void> p2;
+
+ promise<bool> s1;
+ promise<bool> s2;
+
+ background->op_async(
+ [&p1]()
+ {
+ p1.set_value();
+ },
+ [&p1](exception_ptr e)
+ {
+ p1.set_exception(e);
+ },
+ [&s1](bool value)
+ {
+ s1.set_value(value);
+ });
+
+ background->op_async(
+ [&p2]()
+ {
+ p2.set_value();
+ },
+ [&p2](exception_ptr e)
+ {
+ p2.set_exception(e);
+ },
+ [&s2](bool value)
+ {
+ s2.set_value(value);
+ });
+
+ test(s1.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+ test(s2.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ auto f1 = p1.get_future();
+ auto f2 = p2.get_future();
+
+ test(f1.wait_for(chrono::milliseconds(1)) != future_status::ready);
+ test(f2.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ ctl->resumeAdapter();
+
+ f1.get();
+ f2.get();
+#else
Ice::AsyncResultPtr r = background->begin_op();
Ice::AsyncResultPtr r2 = background->begin_op();
test(!r->sentSynchronously() && !r2->sentSynchronously());
@@ -811,6 +1045,7 @@ validationTests(const ConfigurationPtr& configuration,
background->end_op(r);
background->end_op(r2);
test(r->isCompleted() && r2->isCompleted());
+#endif
#if defined(ICE_USE_IOCP) || defined(ICE_USE_CFSTREAM)
if(background->ice_getCommunicator()->getProperties()->getProperty("Ice.Default.Protocol") != "test-ssl" &&
@@ -873,7 +1108,7 @@ validationTests(const ConfigurationPtr& configuration,
Ice::ByteSeq seq;
seq.resize(512 * 1024);
- BackgroundPrx backgroundBatchOneway = BackgroundPrx::uncheckedCast(background->ice_batchOneway());
+ BackgroundPrxPtr backgroundBatchOneway = ICE_UNCHECKED_CAST(BackgroundPrx, background->ice_batchOneway());
//
// First send small requests to test without auto-flushing.
@@ -923,7 +1158,11 @@ validationTests(const ConfigurationPtr& configuration,
backgroundBatchOneway->op();
backgroundBatchOneway->op();
ctl->resumeAdapter();
+#ifdef ICE_CPP11_MAPPING
+ backgroundBatchOneway->ice_flushBatchRequests_async();
+#else
backgroundBatchOneway->begin_ice_flushBatchRequests();
+#endif
backgroundBatchOneway->ice_getConnection()->close(false);
ctl->holdAdapter();
@@ -932,6 +1171,9 @@ validationTests(const ConfigurationPtr& configuration,
backgroundBatchOneway->opWithPayload(seq);
backgroundBatchOneway->opWithPayload(seq);
ctl->resumeAdapter();
+#ifdef ICE_CPP11_MAPPING
+ backgroundBatchOneway->ice_flushBatchRequests_async().get();
+#else
r = backgroundBatchOneway->begin_ice_flushBatchRequests();
//
// We can't close the connection before ensuring all the batches
@@ -943,13 +1185,14 @@ validationTests(const ConfigurationPtr& configuration,
//
//backgroundBatchOneway->ice_getConnection()->close(false);
backgroundBatchOneway->end_ice_flushBatchRequests(r);
+#endif
backgroundBatchOneway->ice_getConnection()->close(false);
}
void
readWriteTests(const ConfigurationPtr& configuration,
- const Test::BackgroundPrx& background,
- const Test::BackgroundControllerPrx& ctl)
+ const Test::BackgroundPrxPtr& background,
+ const Test::BackgroundControllerPrxPtr& ctl)
{
try
{
@@ -964,7 +1207,7 @@ readWriteTests(const ConfigurationPtr& configuration,
int i;
for(i = 0; i < 2; i++)
{
- BackgroundPrx prx = i == 0 ? background : background->ice_oneway();
+ BackgroundPrxPtr prx = i == 0 ? background : background->ice_oneway();
try
{
@@ -980,6 +1223,36 @@ readWriteTests(const ConfigurationPtr& configuration,
background->ice_ping();
configuration->writeException(new Ice::SocketException(__FILE__, __LINE__));
+#ifdef ICE_CPP11_MAPPING
+ promise<bool> sent;
+ promise<void> completed;
+ prx->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr e)
+ {
+ try
+ {
+ rethrow_exception(e);
+ }
+ catch(const Ice::SocketException&)
+ {
+ completed.set_value();
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ },
+ [&sent](bool value)
+ {
+ sent.set_value(value);
+ });
+ test(sent.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+ completed.get_future().get();
+#else
Ice::AsyncResultPtr r = prx->begin_op();
test(!r->sentSynchronously());
try
@@ -991,6 +1264,7 @@ readWriteTests(const ConfigurationPtr& configuration,
{
}
test(r->isCompleted());
+#endif
configuration->writeException(0);
}
@@ -1009,6 +1283,30 @@ readWriteTests(const ConfigurationPtr& configuration,
background->ice_ping();
configuration->readReady(false); // Required in C# to make sure beginRead() doesn't throw too soon.
configuration->readException(new Ice::SocketException(__FILE__, __LINE__));
+#ifdef ICE_CPP11_MAPPING
+ promise<void> completed;
+ background->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr e)
+ {
+ try
+ {
+ rethrow_exception(e);
+ }
+ catch(const Ice::SocketException&)
+ {
+ completed.set_value();
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ });
+ completed.get_future().get();
+#else
Ice::AsyncResultPtr r = background->begin_op();
try
{
@@ -1019,6 +1317,7 @@ readWriteTests(const ConfigurationPtr& configuration,
{
}
test(r->isCompleted());
+#endif
configuration->readException(0);
configuration->readReady(true);
@@ -1068,11 +1367,37 @@ readWriteTests(const ConfigurationPtr& configuration,
for(i = 0; i < 2; ++i)
{
- BackgroundPrx prx = i == 0 ? background : background->ice_oneway();
+ BackgroundPrxPtr prx = i == 0 ? background : background->ice_oneway();
background->ice_ping();
configuration->writeReady(false);
configuration->writeException(new Ice::SocketException(__FILE__, __LINE__));
+#ifdef ICE_CPP11_MAPPING
+ promise<void> completed;
+ promise<bool> sent;
+ prx->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr e)
+ {
+ try
+ {
+ rethrow_exception(e);
+ }
+ catch(const Ice::SocketException&)
+ {
+ completed.set_value();
+ }
+ },
+ [&sent](bool value)
+ {
+ sent.set_value(value);
+ });
+ test(sent.get_future().wait_for(chrono::milliseconds(1)) != future_status::ready);
+ completed.get_future().get();
+#else
Ice::AsyncResultPtr r = prx->begin_op();
test(!r->sentSynchronously());
try
@@ -1084,6 +1409,7 @@ readWriteTests(const ConfigurationPtr& configuration,
{
}
test(r->isCompleted());
+#endif
configuration->writeReady(true);
configuration->writeException(0);
}
@@ -1106,6 +1432,31 @@ readWriteTests(const ConfigurationPtr& configuration,
background->ice_ping();
configuration->readReady(false);
configuration->readException(new Ice::SocketException(__FILE__, __LINE__));
+#ifdef ICE_CPP11_MAPPING
+ promise<void> completed;
+ background->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr e)
+ {
+ try
+ {
+ rethrow_exception(e);
+ }
+ catch(const Ice::SocketException&)
+ {
+ completed.set_value();
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ });
+ completed.get_future().get();
+
+#else
Ice::AsyncResultPtr r = background->begin_op();
try
{
@@ -1116,6 +1467,7 @@ readWriteTests(const ConfigurationPtr& configuration,
{
}
test(r->isCompleted());
+#endif
configuration->readReady(true);
configuration->readException(0);
}
@@ -1125,11 +1477,40 @@ readWriteTests(const ConfigurationPtr& configuration,
configuration->readReady(false);
configuration->writeReady(false);
configuration->readException(new Ice::SocketException(__FILE__, __LINE__));
- Ice::AsyncResultPtr r = background->begin_op();
+#ifdef ICE_CPP11_MAPPING
+ promise<void> completed;
+ promise<bool> sent;
+ background->op_async(
+ []()
+ {
+ test(false);
+ },
+ [&completed](exception_ptr e)
+ {
+ try
+ {
+ rethrow_exception(e);
+ }
+ catch(const Ice::SocketException&)
+ {
+ completed.set_value();
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ },
+ [&sent](bool value)
+ {
+ sent.set_value(value);
+ });
+ sent.get_future().get();
+ completed.get_future().get();
+#else
// The read exception might propagate before the message send is seen as completed on IOCP.
-#ifndef ICE_USE_IOCP
+# ifndef ICE_USE_IOCP
r->waitForSent();
-#endif
+# endif
try
{
background->end_op(r);
@@ -1139,6 +1520,7 @@ readWriteTests(const ConfigurationPtr& configuration,
{
}
test(r->isCompleted());
+#endif
configuration->writeReady(true);
configuration->readReady(true);
configuration->readException(0);
@@ -1149,7 +1531,7 @@ readWriteTests(const ConfigurationPtr& configuration,
background->ice_ping(); // Establish the connection
- BackgroundPrx backgroundOneway = BackgroundPrx::uncheckedCast(background->ice_oneway());
+ BackgroundPrxPtr backgroundOneway = ICE_UNCHECKED_CAST(BackgroundPrx, background->ice_oneway());
test(backgroundOneway->ice_getConnection() == background->ice_getConnection());
ctl->holdAdapter(); // Hold to block in request send.
@@ -1160,6 +1542,93 @@ readWriteTests(const ConfigurationPtr& configuration,
{
*p = static_cast<Ice::Byte>(IceUtilInternal::random(255));
}
+
+#ifdef ICE_CPP11_MAPPING
+ // Fill up the receive and send buffers
+ for(int i = 0; i < 200; ++i) // 2MB
+ {
+ backgroundOneway->opWithPayload_async(
+ seq,
+ []()
+ {
+ test(false);
+ },
+ [](exception_ptr)
+ {
+ test(false);
+ });
+ }
+
+ promise<void> c1;
+ promise<bool> s1;
+
+ background->op_async(
+ [&c1]()
+ {
+ c1.set_value();
+ },
+ [](exception_ptr err)
+ {
+ test(false);
+ },
+ [&s1](bool value)
+ {
+ s1.set_value(value);
+ });
+
+ auto fs1 = s1.get_future();
+ test(fs1.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ promise<void> c2;
+ promise<bool> s2;
+
+ background->op_async(
+ [&c2]()
+ {
+ c2.set_value();
+ },
+ [](exception_ptr err)
+ {
+ test(false);
+ },
+ [&s2](bool value)
+ {
+ s2.set_value(value);
+ });
+
+ auto fs2 = s2.get_future();
+ test(fs2.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ promise<bool> s3;
+ backgroundOneway->opWithPayload_async(seq,
+ [](){ test(false); },
+ [](exception_ptr){ test(false); },
+ [&s3](bool value){ s3.set_value(value); });
+ auto fs3 = s3.get_future();
+ test(fs3.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ promise<bool> s4;
+ backgroundOneway->opWithPayload_async(seq,
+ [](){ test(false); },
+ [](exception_ptr){ test(false); },
+ [&s4](bool value){ s4.set_value(value); });
+ auto fs4 = s4.get_future();
+ test(fs4.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ auto fc1 = c1.get_future();
+ test(fc1.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ auto fc2 = c2.get_future();
+ test(fc2.wait_for(chrono::milliseconds(1)) != future_status::ready);
+
+ ctl->resumeAdapter();
+
+ fs1.get();
+ fs2.get();
+
+ fc1.get();
+ fc2.get();
+#else
OpAMICallbackPtr cb = new OpAMICallback();
Callback_Background_opWithPayloadPtr callbackWP = newCallback_Background_opWithPayload(cb,
&OpAMICallback::noResponse,
@@ -1196,6 +1665,7 @@ readWriteTests(const ConfigurationPtr& configuration,
cb2->checkResponseAndSent();
test(r1->isSent() && r1->isCompleted());
test(r2->isSent() && r2->isCompleted());
+#endif
try
{
diff --git a/cpp/test/Ice/background/Client.cpp b/cpp/test/Ice/background/Client.cpp
index 699605bd494..12dc63fb095 100644
--- a/cpp/test/Ice/background/Client.cpp
+++ b/cpp/test/Ice/background/Client.cpp
@@ -18,8 +18,8 @@ using namespace Test;
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
- BackgroundPrx allTests(const Ice::CommunicatorPtr&);
- BackgroundPrx background = allTests(communicator);
+ BackgroundPrxPtr allTests(const Ice::CommunicatorPtr&);
+ BackgroundPrxPtr background = allTests(communicator);
background->shutdown();
return EXIT_SUCCESS;
}
diff --git a/cpp/test/Ice/background/EndpointFactory.cpp b/cpp/test/Ice/background/EndpointFactory.cpp
index 306101b810a..1fbe25930de 100644
--- a/cpp/test/Ice/background/EndpointFactory.cpp
+++ b/cpp/test/Ice/background/EndpointFactory.cpp
@@ -34,7 +34,7 @@ EndpointFactory::protocol() const
IceInternal::EndpointIPtr
EndpointFactory::create(vector<string>& args, bool oaEndpoint) const
{
- return new EndpointI(_factory->create(args, oaEndpoint));
+ return ICE_MAKE_SHARED(EndpointI, _factory->create(args, oaEndpoint));
}
IceInternal::EndpointIPtr
@@ -45,7 +45,7 @@ EndpointFactory::read(IceInternal::BasicStream* s) const
assert(type == _factory->type());
s->startReadEncaps();
- IceInternal::EndpointIPtr endpoint = new EndpointI(_factory->read(s));
+ IceInternal::EndpointIPtr endpoint = ICE_MAKE_SHARED(EndpointI, _factory->read(s));
s->endReadEncaps();
return endpoint;
}
diff --git a/cpp/test/Ice/background/EndpointI.cpp b/cpp/test/Ice/background/EndpointI.cpp
index 16aa72c32e9..afab5ac8919 100644
--- a/cpp/test/Ice/background/EndpointI.cpp
+++ b/cpp/test/Ice/background/EndpointI.cpp
@@ -71,11 +71,15 @@ EndpointI::timeout(int timeout) const
IceInternal::EndpointIPtr endpoint = _endpoint->timeout(timeout);
if(endpoint == _endpoint)
{
+#ifdef ICE_CPP11_MAPPING
+ return const_pointer_cast<IceInternal::EndpointI>(shared_from_this());
+#else
return const_cast<EndpointI*>(this);
+#endif
}
else
{
- return new EndpointI(endpoint);
+ return ICE_MAKE_SHARED(EndpointI, endpoint);
}
}
@@ -85,11 +89,15 @@ EndpointI::connectionId(const string& connectionId) const
IceInternal::EndpointIPtr endpoint = _endpoint->connectionId(connectionId);
if(endpoint == _endpoint)
{
+#ifdef ICE_CPP11_MAPPING
+ return const_pointer_cast<IceInternal::EndpointI>(shared_from_this());
+#else
return const_cast<EndpointI*>(this);
+#endif
}
else
{
- return new EndpointI(endpoint);
+ return ICE_MAKE_SHARED(EndpointI, endpoint);
}
}
@@ -105,11 +113,15 @@ EndpointI::compress(bool compress) const
IceInternal::EndpointIPtr endpoint = _endpoint->compress(compress);
if(endpoint == _endpoint)
{
+#ifdef ICE_CPP11_MAPPING
+ return const_pointer_cast<IceInternal::EndpointI>(shared_from_this());
+#else
return const_cast<EndpointI*>(this);
+#endif
}
else
{
- return new EndpointI(endpoint);
+ return ICE_MAKE_SHARED(EndpointI, endpoint);
}
}
@@ -175,7 +187,7 @@ EndpointI::connectors_async(Ice::EndpointSelectionType selType, const IceInterna
try
{
_configuration->checkConnectorsException();
- _endpoint->connectors_async(selType, new Callback(cb));
+ _endpoint->connectors_async(selType, ICE_MAKE_SHARED(Callback, cb));
}
catch(const Ice::LocalException& ex)
{
@@ -186,7 +198,13 @@ EndpointI::connectors_async(Ice::EndpointSelectionType selType, const IceInterna
IceInternal::AcceptorPtr
EndpointI::acceptor(const string& adapterName) const
{
+#ifdef ICE_CPP11_MAPPING
+ return new Acceptor(dynamic_pointer_cast<EndpointI>(
+ const_pointer_cast<IceInternal::EndpointI>(shared_from_this())),
+ _endpoint->acceptor(adapterName));
+#else
return new Acceptor(const_cast<EndpointI*>(this), _endpoint->acceptor(adapterName));
+#endif
}
/*IceInternal::EndpointIPtr
@@ -207,7 +225,7 @@ EndpointI::endpoint(const IceInternal::TransceiverPtr& transceiver) const
EndpointIPtr
EndpointI::endpoint(const IceInternal::EndpointIPtr& delEndp) const
{
- return new EndpointI(delEndp);
+ return ICE_MAKE_SHARED(EndpointI, delEndp);
}
vector<IceInternal::EndpointIPtr>
@@ -216,7 +234,11 @@ EndpointI::expand() const
vector<IceInternal::EndpointIPtr> e = _endpoint->expand();
for(vector<IceInternal::EndpointIPtr>::iterator p = e.begin(); p != e.end(); ++p)
{
+#ifdef ICE_CPP11_MAPPING
+ *p = (*p == _endpoint) ? const_pointer_cast<IceInternal::EndpointI>(shared_from_this()) : make_shared<EndpointI>(*p);
+#else
*p = (*p == _endpoint) ? const_cast<EndpointI*>(this) : new EndpointI(*p);
+#endif
}
return e;
}
@@ -245,7 +267,11 @@ EndpointI::getInfo() const
}
bool
+#ifdef ICE_CPP11_MAPPING
+EndpointI::operator==(const IceInternal::EndpointI& r) const
+#else
EndpointI::operator==(const Ice::LocalObject& r) const
+#endif
{
const EndpointI* p = dynamic_cast<const EndpointI*>(&r);
if(!p)
@@ -263,7 +289,11 @@ EndpointI::operator==(const Ice::LocalObject& r) const
}
bool
+#ifdef ICE_CPP11_MAPPING
+EndpointI::operator<(const IceInternal::EndpointI& r) const
+#else
EndpointI::operator<(const Ice::LocalObject& r) const
+#endif
{
const EndpointI* p = dynamic_cast<const EndpointI*>(&r);
if(!p)
diff --git a/cpp/test/Ice/background/EndpointI.h b/cpp/test/Ice/background/EndpointI.h
index 63b3425da14..7cb75068e2a 100644
--- a/cpp/test/Ice/background/EndpointI.h
+++ b/cpp/test/Ice/background/EndpointI.h
@@ -16,13 +16,15 @@
class EndpointI;
-typedef IceUtil::Handle<EndpointI> EndpointIPtr;
+ICE_DEFINE_PTR(EndpointIPtr, EndpointI);
class EndpointI : public IceInternal::EndpointI
{
public:
static Ice::Short TYPE_BASE;
+
+ EndpointI(const IceInternal::EndpointIPtr&);
// From EndpointI
virtual void streamWrite(IceInternal::BasicStream*) const;
@@ -47,8 +49,13 @@ public:
virtual bool datagram() const;
virtual bool secure() const;
+#ifdef ICE_CPP11_MAPPING
+ virtual bool operator==(const IceInternal::EndpointI&) const;
+ virtual bool operator<(const IceInternal::EndpointI&) const;
+#else
virtual bool operator==(const Ice::LocalObject&) const;
virtual bool operator<(const Ice::LocalObject&) const;
+#endif
virtual int hash() const;
virtual std::string options() const;
@@ -60,7 +67,6 @@ public:
private:
- EndpointI(const IceInternal::EndpointIPtr&);
friend class EndpointFactory;
const IceInternal::EndpointIPtr _endpoint;
diff --git a/cpp/test/Ice/background/Server.cpp b/cpp/test/Ice/background/Server.cpp
index cc0a4265bd2..06aa9ac9c54 100644
--- a/cpp/test/Ice/background/Server.cpp
+++ b/cpp/test/Ice/background/Server.cpp
@@ -22,6 +22,29 @@ class LocatorI : public Ice::Locator
{
public:
+#ifdef ICE_CPP11_MAPPING
+ virtual void
+ findAdapterById_async(string,
+ function<void (const shared_ptr<Ice::ObjectPrx>&)> response,
+ function<void (exception_ptr)>,
+ const Ice::Current& current) const
+ {
+ _controller->checkCallPause(current);
+ Ice::CommunicatorPtr communicator = current.adapter->getCommunicator();
+ response(current.adapter->createDirectProxy(communicator->stringToIdentity("dummy")));
+ }
+
+ virtual void
+ findObjectById_async(Ice::Identity id,
+ function<void (const shared_ptr<Ice::ObjectPrx>&)> response,
+ function<void (exception_ptr)>,
+ const Ice::Current& current) const
+ {
+ _controller->checkCallPause(current);
+ Ice::CommunicatorPtr communicator = current.adapter->getCommunicator();
+ response(current.adapter->createDirectProxy(id));
+ }
+#else
virtual void
findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& response, const string&,
const Ice::Current& current) const
@@ -39,11 +62,11 @@ public:
Ice::CommunicatorPtr communicator = current.adapter->getCommunicator();
response->ice_response(current.adapter->createDirectProxy(id));
}
-
- virtual Ice::LocatorRegistryPrx
+#endif
+ virtual Ice::LocatorRegistryPrxPtr
getRegistry(const Ice::Current&) const
{
- return 0;
+ return ICE_NULLPTR;
}
LocatorI(const BackgroundControllerIPtr& controller) : _controller(controller)
@@ -59,22 +82,22 @@ class RouterI : public Ice::Router
{
public:
- virtual Ice::ObjectPrx
+ virtual Ice::ObjectPrxPtr
getClientProxy(const Ice::Current& current) const
{
_controller->checkCallPause(current);
- return 0;
+ return ICE_NULLPTR;
}
- virtual Ice::ObjectPrx
+ virtual Ice::ObjectPrxPtr
getServerProxy(const Ice::Current& current) const
{
_controller->checkCallPause(current);
- return 0;
+ return ICE_NULLPTR;
}
virtual Ice::ObjectProxySeq
- addProxies(const Ice::ObjectProxySeq&, const Ice::Current&)
+ addProxies(ICE_IN(Ice::ObjectProxySeq), const Ice::Current&)
{
return Ice::ObjectProxySeq();
}
@@ -100,14 +123,18 @@ run(int, char**, const Ice::CommunicatorPtr& communicator)
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::ObjectAdapterPtr adapter2 = communicator->createObjectAdapter("ControllerAdapter");
+#ifdef ICE_CPP11_MAPPING
+ shared_ptr<PluginI> plugin = dynamic_pointer_cast<PluginI>(communicator->getPluginManager()->getPlugin("Test"));
+#else
PluginI* plugin = dynamic_cast<PluginI*>(communicator->getPluginManager()->getPlugin("Test").get());
+#endif
assert(plugin);
ConfigurationPtr configuration = plugin->getConfiguration();
- BackgroundControllerIPtr backgroundController = new BackgroundControllerI(adapter, configuration);
+ BackgroundControllerIPtr backgroundController = ICE_MAKE_SHARED(BackgroundControllerI, adapter, configuration);
- adapter->add(new BackgroundI(backgroundController), communicator->stringToIdentity("background"));
- adapter->add(new LocatorI(backgroundController), communicator->stringToIdentity("locator"));
- adapter->add(new RouterI(backgroundController), communicator->stringToIdentity("router"));
+ adapter->add(ICE_MAKE_SHARED(BackgroundI, backgroundController), communicator->stringToIdentity("background"));
+ adapter->add(ICE_MAKE_SHARED(LocatorI, backgroundController), communicator->stringToIdentity("locator"));
+ adapter->add(ICE_MAKE_SHARED(RouterI, backgroundController), communicator->stringToIdentity("router"));
adapter->activate();
adapter2->add(backgroundController, communicator->stringToIdentity("backgroundController"));
@@ -120,9 +147,6 @@ run(int, char**, const Ice::CommunicatorPtr& communicator)
int
main(int argc, char* argv[])
{
- int status;
- Ice::CommunicatorPtr communicator;
-
try
{
Ice::InitializationData initData;
@@ -146,27 +170,12 @@ main(int argc, char* argv[])
string defaultProtocol = initData.properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
initData.properties->setProperty("Ice.Default.Protocol", "test-" + defaultProtocol);
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
+ return run(argc, argv, ich.communicator());
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
- status = EXIT_FAILURE;
+ return EXIT_FAILURE;
}
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
- }
-
- return status;
}
diff --git a/cpp/test/Ice/background/TestI.cpp b/cpp/test/Ice/background/TestI.cpp
index c9f61ecbe92..053b6138e3b 100644
--- a/cpp/test/Ice/background/TestI.cpp
+++ b/cpp/test/Ice/background/TestI.cpp
@@ -20,7 +20,7 @@ BackgroundI::op(const Ice::Current& current)
}
void
-BackgroundI::opWithPayload(const Ice::ByteSeq&, const Ice::Current& current)
+BackgroundI::opWithPayload(ICE_IN(Ice::ByteSeq), const Ice::Current& current)
{
_controller->checkCallPause(current);
}
@@ -37,14 +37,14 @@ BackgroundI::BackgroundI(const BackgroundControllerIPtr& controller) :
}
void
-BackgroundControllerI::pauseCall(const string& opName, const Ice::Current&)
+BackgroundControllerI::pauseCall(ICE_IN(string) opName, const Ice::Current&)
{
Lock sync(*this);
_pausedCalls.insert(opName);
}
void
-BackgroundControllerI::resumeCall(const string& opName, const Ice::Current&)
+BackgroundControllerI::resumeCall(ICE_IN(string) opName, const Ice::Current&)
{
Lock sync(*this);
_pausedCalls.erase(opName);
diff --git a/cpp/test/Ice/background/TestI.h b/cpp/test/Ice/background/TestI.h
index 20907f44742..fdef89a8791 100644
--- a/cpp/test/Ice/background/TestI.h
+++ b/cpp/test/Ice/background/TestI.h
@@ -11,19 +11,20 @@
#define TEST_I_H
#include <Test.h>
+#include <TestCommon.h>
#include <Configuration.h>
#include <set>
class BackgroundControllerI;
-typedef IceUtil::Handle<BackgroundControllerI> BackgroundControllerIPtr;
+ICE_DEFINE_PTR(BackgroundControllerIPtr, BackgroundControllerI);
class BackgroundI : virtual public Test::Background
{
public:
virtual void op(const Ice::Current&);
- virtual void opWithPayload(const Ice::ByteSeq&, const Ice::Current&);
+ virtual void opWithPayload(ICE_IN(Ice::ByteSeq), const Ice::Current&);
virtual void shutdown(const Ice::Current&);
BackgroundI(const BackgroundControllerIPtr&);
@@ -38,8 +39,8 @@ class BackgroundControllerI : public Test::BackgroundController, IceUtil::Monito
public:
- virtual void pauseCall(const std::string&, const Ice::Current&);
- virtual void resumeCall(const std::string&, const Ice::Current&);
+ virtual void pauseCall(ICE_IN(std::string), const Ice::Current&);
+ virtual void resumeCall(ICE_IN(std::string), const Ice::Current&);
virtual void checkCallPause(const Ice::Current&);
virtual void holdAdapter(const Ice::Current&);
diff --git a/cpp/test/Ice/metrics/Client.cpp b/cpp/test/Ice/metrics/Client.cpp
index b895749d011..7111c15597e 100644
--- a/cpp/test/Ice/metrics/Client.cpp
+++ b/cpp/test/Ice/metrics/Client.cpp
@@ -20,8 +20,8 @@ using namespace Test;
int
run(int, char**, const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPtr& observer)
{
- MetricsPrx allTests(const Ice::CommunicatorPtr&, const CommunicatorObserverIPtr&);
- MetricsPrx metrics = allTests(communicator, observer);
+ MetricsPrxPtr allTests(const Ice::CommunicatorPtr&, const CommunicatorObserverIPtr&);
+ MetricsPrxPtr metrics = allTests(communicator, observer);
metrics->shutdown();
return EXIT_SUCCESS;
}
@@ -32,10 +32,6 @@ main(int argc, char* argv[])
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
#endif
-
- int status;
- Ice::CommunicatorPtr communicator;
-
try
{
Ice::InitializationData initData;
@@ -48,27 +44,12 @@ main(int argc, char* argv[])
initData.properties->setProperty("Ice.Default.Host", "127.0.0.1");
CommunicatorObserverIPtr observer = new CommunicatorObserverI();
initData.observer = observer;
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator, observer);
+ Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
+ return run(argc, argv, ich.communicator(), observer);
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
+ return EXIT_FAILURE;
}
-
- return status;
}
diff --git a/cpp/test/Ice/metrics/Collocated.cpp b/cpp/test/Ice/metrics/Collocated.cpp
index 5eb75ea0c15..ce55f344282 100644
--- a/cpp/test/Ice/metrics/Collocated.cpp
+++ b/cpp/test/Ice/metrics/Collocated.cpp
@@ -22,17 +22,16 @@ run(int, char**, const Ice::CommunicatorPtr& communicator, const CommunicatorObs
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
- Ice::ObjectPtr object = new MetricsI;
- adapter->add(object, communicator->stringToIdentity("metrics"));
+ adapter->add(ICE_MAKE_SHARED(MetricsI), communicator->stringToIdentity("metrics"));
//adapter->activate(); // Don't activate OA to ensure collocation is used.
communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", "default -p 12011");
Ice::ObjectAdapterPtr controllerAdapter = communicator->createObjectAdapter("ControllerAdapter");
- controllerAdapter->add(new ControllerI(adapter), communicator->stringToIdentity("controller"));
+ controllerAdapter->add(ICE_MAKE_SHARED(ControllerI, adapter), communicator->stringToIdentity("controller"));
//controllerAdapter->activate(); // Don't activate OA to ensure collocation is used.
- MetricsPrx allTests(const Ice::CommunicatorPtr&, const CommunicatorObserverIPtr&);
- MetricsPrx metrics = allTests(communicator, observer);
+ MetricsPrxPtr allTests(const Ice::CommunicatorPtr&, const CommunicatorObserverIPtr&);
+ MetricsPrxPtr metrics = allTests(communicator, observer);
metrics->shutdown();
return EXIT_SUCCESS;
}
@@ -43,10 +42,6 @@ main(int argc, char* argv[])
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
#endif
-
- int status;
- Ice::CommunicatorPtr communicator;
-
try
{
Ice::InitializationData initData;
@@ -60,27 +55,12 @@ main(int argc, char* argv[])
initData.properties->setProperty("Ice.Default.Host", "127.0.0.1");
CommunicatorObserverIPtr observer = new CommunicatorObserverI();
initData.observer = observer;
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator, observer);
+ Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
+ return run(argc, argv, ich.communicator(), observer);
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
+ return EXIT_FAILURE;
}
-
- return status;
}
diff --git a/cpp/test/Ice/metrics/Server.cpp b/cpp/test/Ice/metrics/Server.cpp
index 54928e88007..098837164e8 100644
--- a/cpp/test/Ice/metrics/Server.cpp
+++ b/cpp/test/Ice/metrics/Server.cpp
@@ -20,13 +20,12 @@ run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
- Ice::ObjectPtr object = new MetricsI;
- adapter->add(object, communicator->stringToIdentity("metrics"));
+ adapter->add(ICE_MAKE_SHARED(MetricsI), communicator->stringToIdentity("metrics"));
adapter->activate();
communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", "default -p 12011");
Ice::ObjectAdapterPtr controllerAdapter = communicator->createObjectAdapter("ControllerAdapter");
- controllerAdapter->add(new ControllerI(adapter), communicator->stringToIdentity("controller"));
+ controllerAdapter->add(ICE_MAKE_SHARED(ControllerI, adapter), communicator->stringToIdentity("controller"));
controllerAdapter->activate();
TEST_READY
@@ -41,10 +40,6 @@ main(int argc, char* argv[])
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
#endif
-
- int status;
- Ice::CommunicatorPtr communicator;
-
try
{
Ice::InitializationData initData;
@@ -57,27 +52,12 @@ main(int argc, char* argv[])
initData.properties->setProperty("Ice.Warn.Dispatch", "0");
initData.properties->setProperty("Ice.MessageSizeMax", "50000");
initData.properties->setProperty("Ice.Default.Host", "127.0.0.1");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
+ return run(argc, argv, ich.communicator());
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
+ return EXIT_FAILURE;
}
-
- return status;
}
diff --git a/cpp/test/Ice/metrics/ServerAMD.cpp b/cpp/test/Ice/metrics/ServerAMD.cpp
index 4b9ff8b4702..efdaabad296 100644
--- a/cpp/test/Ice/metrics/ServerAMD.cpp
+++ b/cpp/test/Ice/metrics/ServerAMD.cpp
@@ -20,13 +20,12 @@ run(int, char**, const Ice::CommunicatorPtr& communicator)
{
communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010");
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
- Ice::ObjectPtr object = new MetricsI;
- adapter->add(object, communicator->stringToIdentity("metrics"));
+ adapter->add(ICE_MAKE_SHARED(MetricsI), communicator->stringToIdentity("metrics"));
adapter->activate();
communicator->getProperties()->setProperty("ControllerAdapter.Endpoints", "default -p 12011");
Ice::ObjectAdapterPtr controllerAdapter = communicator->createObjectAdapter("ControllerAdapter");
- controllerAdapter->add(new ControllerI(adapter), communicator->stringToIdentity("controller"));
+ controllerAdapter->add(ICE_MAKE_SHARED(ControllerI, adapter), communicator->stringToIdentity("controller"));
controllerAdapter->activate();
TEST_READY
@@ -41,10 +40,7 @@ main(int argc, char* argv[])
#ifdef ICE_STATIC_LIBS
Ice::registerIceSSL();
#endif
-
- int status;
Ice::CommunicatorPtr communicator;
-
try
{
Ice::InitializationData initData;
@@ -58,26 +54,11 @@ main(int argc, char* argv[])
initData.properties->setProperty("Ice.MessageSizeMax", "50000");
initData.properties->setProperty("Ice.Default.Host", "127.0.0.1");
communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ return run(argc, argv, communicator);
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
- status = EXIT_FAILURE;
- }
-
- if(communicator)
- {
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
+ return EXIT_FAILURE;
}
-
- return status;
}
diff --git a/cpp/test/Ice/metrics/TestI.cpp b/cpp/test/Ice/metrics/TestI.cpp
index 5ccc6b8ab23..9025f4187bf 100644
--- a/cpp/test/Ice/metrics/TestI.cpp
+++ b/cpp/test/Ice/metrics/TestI.cpp
@@ -46,11 +46,11 @@ MetricsI::opWithUnknownException(const Ice::Current&)
}
void
-MetricsI::opByteS(const Test::ByteSeq&, const Ice::Current&)
+MetricsI::opByteS(ICE_IN(Test::ByteSeq), const Ice::Current&)
{
}
-Ice::ObjectPrx
+Ice::ObjectPrxPtr
MetricsI::getAdmin(const Ice::Current& current)
{
return current.adapter->getCommunicator()->getAdmin();
diff --git a/cpp/test/Ice/metrics/TestI.h b/cpp/test/Ice/metrics/TestI.h
index e5f094ac088..d108789d898 100644
--- a/cpp/test/Ice/metrics/TestI.h
+++ b/cpp/test/Ice/metrics/TestI.h
@@ -11,6 +11,7 @@
#define TEST_I_H
#include <Test.h>
+#include <TestCommon.h>
class MetricsI : public Test::Metrics
{
@@ -26,9 +27,9 @@ class MetricsI : public Test::Metrics
virtual void opWithUnknownException(const Ice::Current&);
- virtual void opByteS(const Test::ByteSeq&, const Ice::Current&);
+ virtual void opByteS(ICE_IN(Test::ByteSeq), const Ice::Current&);
- virtual Ice::ObjectPrx getAdmin(const Ice::Current&);
+ virtual Ice::ObjectPrxPtr getAdmin(const Ice::Current&);
virtual void shutdown(const Ice::Current&);
};
diff --git a/cpp/test/Ice/stringConverter/Server.cpp b/cpp/test/Ice/stringConverter/Server.cpp
index 0607a4f2d17..3c5ff9f007b 100644
--- a/cpp/test/Ice/stringConverter/Server.cpp
+++ b/cpp/test/Ice/stringConverter/Server.cpp
@@ -22,7 +22,7 @@ class MyObjectI : public Test::MyObject
{
public:
- virtual wstring widen(const string& msg, const Ice::Current&)
+ virtual wstring widen(ICE_IN(string) msg, const Ice::Current&)
{
const Ice::Byte* cmsg = reinterpret_cast<const Ice::Byte*>(msg.c_str());
@@ -35,7 +35,7 @@ public:
IceUtil::getProcessWstringConverter());
}
- virtual string narrow(const wstring& wmsg, const Ice::Current&)
+ virtual string narrow(ICE_IN(wstring) wmsg, const Ice::Current&)
{
return IceUtil::wstringToString(wmsg, IceUtil::getProcessStringConverter(),
IceUtil::getProcessWstringConverter());