summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/exceptions/AllTests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/exceptions/AllTests.cpp')
-rw-r--r--cpp/test/Ice/exceptions/AllTests.cpp701
1 files changed, 571 insertions, 130 deletions
diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp
index 434aabb040b..7fb9c1a930a 100644
--- a/cpp/test/Ice/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/exceptions/AllTests.cpp
@@ -7,6 +7,7 @@
//
// **********************************************************************
+#include <IceUtil/IceUtil.h>
#include <Ice/Ice.h>
#include <TestCommon.h>
#include <Test.h>
@@ -14,31 +15,38 @@
using namespace std;
using namespace Test;
-namespace
+namespace
{
const bool printException = false;
}
-class EmptyI : virtual public Empty
+class EmptyI : public virtual Empty
{
};
-class ServantLocatorI : virtual public Ice::ServantLocator
+class ServantLocatorI : public virtual Ice::ServantLocator
{
public:
+#ifdef ICE_CPP11_MAPPING
+ virtual shared_ptr<Ice::Object> locate(const Ice::Current&, shared_ptr<void>&) { return nullptr; }
+ virtual void finished(const Ice::Current&, const shared_ptr<Ice::Object>&, const shared_ptr<void>&) {}
+ virtual void deactivate(const string&) {}
+#else
virtual Ice::ObjectPtr locate(const Ice::Current&, Ice::LocalObjectPtr&) { return 0; }
virtual void finished(const Ice::Current&, const Ice::ObjectPtr&, const Ice::LocalObjectPtr&) {}
virtual void deactivate(const string&) {}
+#endif
};
-class ObjectFactoryI : virtual public Ice::ObjectFactory
+#ifndef ICE_CPP11_MAPPING // C++98
+class ValueFactoryI : public virtual Ice::ValueFactory
{
public:
virtual Ice::ObjectPtr create(const string&) { return 0; }
- virtual void destroy() {}
};
+#endif
class CallbackBase : public IceUtil::Monitor<IceUtil::Mutex>
{
@@ -298,7 +306,7 @@ public:
}
catch(const Ice::ObjectNotExistException& ex)
{
- Ice::Identity id = _communicator->stringToIdentity("does not exist");
+ Ice::Identity id = Ice::stringToIdentity("does not exist");
test(ex.id == id);
}
catch(...)
@@ -394,21 +402,16 @@ endsWith(const string& s, const string& findme)
return false;
}
-ThrowerPrx
+ThrowerPrxPtr
allTests(const Ice::CommunicatorPtr& communicator)
{
-#ifdef ICE_OS_WINRT
- bool winrt = true;
-#else
- bool winrt = false;
-#endif
cout << "testing ice_print()/what()... " << flush;
{
A a;
- string aMsg = "Test::A";
+ string aMsg = "::Test::A";
Ice::UnknownLocalException ule("thisFile", 99);
- string uleMsg = "thisFile:99: Ice::UnknownLocalException:\nunknown local exception";
+ string uleMsg = "thisFile:99: ::Ice::UnknownLocalException:\nunknown local exception";
//
// Test ice_print().
@@ -451,7 +454,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
E ex("E");
ostringstream os;
ex.ice_print(os);
- test(os.str() == "Test::E");
+ test(os.str() == "::Test::E");
test(ex.data == "E");
}
@@ -462,7 +465,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
F ex("F");
ostringstream os;
ex.ice_print(os);
- test(os.str() == "Test::F data:'F'");
+ test(os.str() == "::Test::F data:'F'");
test(ex.data == "F");
}
@@ -485,90 +488,93 @@ allTests(const Ice::CommunicatorPtr& communicator)
}
cout << "ok" << endl;
- cout << "testing object adapter registration exceptions... " << flush;
+ string localOAEndpoint;
{
- Ice::ObjectAdapterPtr first;
- try
+ ostringstream ostr;
+ if(communicator->getProperties()->getProperty("Ice.Default.Protocol") == "bt")
{
- first = communicator->createObjectAdapter("TestAdapter0");
- test(false);
+ ostr << "default -a *";
}
- catch(const Ice::InitializationException& ex)
+ else
{
- if(printException)
- {
- Ice::Print printer(communicator->getLogger());
- printer << ex;
- }
- // Expected
+ ostr << "default -h *";
}
+ localOAEndpoint = ostr.str();
+ }
+#ifdef ICE_OS_UWP
+ bool uwp = true;
+#else
+ bool uwp = false;
+#endif
- string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ?
- "127.0.0.1" : "\"0:0:0:0:0:0:0:1\"";
- communicator->getProperties()->setProperty("TestAdapter0.Endpoints", "default -h " + host);
- try
+ if(!uwp || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" &&
+ communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss"))
+ {
+ cout << "testing object adapter registration exceptions... " << flush;
{
+ Ice::ObjectAdapterPtr first;
+ try
+ {
+ first = communicator->createObjectAdapter("TestAdapter0");
+ test(false);
+ }
+ catch(const Ice::InitializationException& ex)
+ {
+ if(printException)
+ {
+ Ice::Print printer(communicator->getLogger());
+ printer << ex;
+ }
+ // Expected
+ }
+
+ communicator->getProperties()->setProperty("TestAdapter0.Endpoints", localOAEndpoint);
first = communicator->createObjectAdapter("TestAdapter0");
- Ice::ObjectAdapterPtr second = communicator->createObjectAdapter("TestAdapter0");
- test(false);
- }
- catch(const Ice::AlreadyRegisteredException& ex)
- {
- if(printException)
+ try
{
- Ice::Print printer(communicator->getLogger());
- printer << ex;
+ Ice::ObjectAdapterPtr second = communicator->createObjectAdapter("TestAdapter0");
+ test(false);
}
+ catch(const Ice::AlreadyRegisteredException& ex)
+ {
+ if(printException)
+ {
+ Ice::Print printer(communicator->getLogger());
+ printer << ex;
+ }
- // Expected
- }
-#ifdef ICE_OS_WINRT
- catch(const Ice::FeatureNotSupportedException&)
- {
- // WinRT doesn't support SSL server side endponints.
- }
-#endif
+ // Expected
+ }
- try
- {
- Ice::ObjectAdapterPtr second =
- communicator->createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011");
- test(false);
- }
- catch(const Ice::AlreadyRegisteredException& ex)
- {
- if(printException)
+ try
{
- Ice::Print printer(communicator->getLogger());
- printer << ex;
+ Ice::ObjectAdapterPtr second =
+ communicator->createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011");
+ test(false);
}
+ catch(const Ice::AlreadyRegisteredException& ex)
+ {
+ if(printException)
+ {
+ Ice::Print printer(communicator->getLogger());
+ printer << ex;
+ }
- // Expected.
- }
-#ifdef ICE_OS_WINRT
- catch(const Ice::FeatureNotSupportedException&)
- {
- // WinRT doesn't support SSL server side endponints.
+ // Expected.
+ }
+ first->deactivate();
}
-#else
- first->deactivate();
-#endif
- }
+ cout << "ok" << endl;
- if(!winrt || (communicator->getProperties()->getProperty("Ice.Default.Protocol") != "ssl" &&
- communicator->getProperties()->getProperty("Ice.Default.Protocol") != "wss"))
- {
cout << "testing servant registration exceptions... " << flush;
{
- string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ?
- "127.0.0.1" : "\"0:0:0:0:0:0:0:1\"";
- communicator->getProperties()->setProperty("TestAdapter1.Endpoints", "default -h " + host);
+ communicator->getProperties()->setProperty("TestAdapter1.Endpoints", localOAEndpoint);
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter1");
- Ice::ObjectPtr obj = new EmptyI;
- adapter->add(obj, communicator->stringToIdentity("x"));
+ Ice::ObjectPtr obj = ICE_MAKE_SHARED(EmptyI);
+ adapter->add(obj, Ice::stringToIdentity("x"));
try
{
- adapter->add(obj, communicator->stringToIdentity("x"));
+ adapter->add(obj, Ice::stringToIdentity("x"));
test(false);
}
catch(const Ice::AlreadyRegisteredException& ex)
@@ -582,7 +588,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
try
{
- adapter->add(obj, communicator->stringToIdentity(""));
+ adapter->add(obj, Ice::stringToIdentity(""));
}
catch(const Ice::IllegalIdentityException& ex)
{
@@ -596,7 +602,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
try
{
- adapter->add(0, communicator->stringToIdentity("x"));
+ adapter->add(0, Ice::stringToIdentity("x"));
}
catch(const Ice::IllegalServantException& ex)
{
@@ -607,11 +613,10 @@ allTests(const Ice::CommunicatorPtr& communicator)
}
}
-
- adapter->remove(communicator->stringToIdentity("x"));
+ adapter->remove(Ice::stringToIdentity("x"));
try
{
- adapter->remove(communicator->stringToIdentity("x"));
+ adapter->remove(Ice::stringToIdentity("x"));
test(false);
}
catch(const Ice::NotRegisteredException& ex)
@@ -629,11 +634,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing servant locator registrations exceptions... " << flush;
{
- string host = communicator->getProperties()->getPropertyAsIntWithDefault("Ice.IPv6", 0) == 0 ?
- "127.0.0.1" : "\"0:0:0:0:0:0:0:1\"";
- communicator->getProperties()->setProperty("TestAdapter2.Endpoints", "default -h " + host);
+ communicator->getProperties()->setProperty("TestAdapter2.Endpoints", localOAEndpoint);
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter2");
- Ice::ServantLocatorPtr loc = new ServantLocatorI;
+ Ice::ServantLocatorPtr loc = ICE_MAKE_SHARED(ServantLocatorI);
adapter->addServantLocator(loc, "x");
try
{
@@ -649,31 +652,57 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "ok" << endl;
}
- cout << "testing object factory registration exception... " << flush;
+ cout << "testing value factory registration exception... " << flush;
{
- Ice::ObjectFactoryPtr of = new ObjectFactoryI;
- communicator->addObjectFactory(of, "x");
+#ifdef ICE_CPP11_MAPPING
+ communicator->getValueFactoryManager()->add(
+ [](const std::string&)
+ {
+ return nullptr;
+ },
+ "x");
+ try
+ {
+ communicator->getValueFactoryManager()->add(
+ [](const std::string&)
+ {
+ return nullptr;
+ },
+ "x");
+ test(false);
+ }
+ catch(const Ice::AlreadyRegisteredException&)
+ {
+ }
+#else
+ Ice::ValueFactoryPtr vf = new ValueFactoryI;
+ communicator->getValueFactoryManager()->add(vf, "x");
try
{
- communicator->addObjectFactory(of, "x");
+ communicator->getValueFactoryManager()->add(vf, "x");
test(false);
}
catch(const Ice::AlreadyRegisteredException&)
{
}
+#endif
}
cout << "ok" << endl;
cout << "testing stringToProxy... " << flush;
- string ref = "thrower:default -p 12010";
- Ice::ObjectPrx base = communicator->stringToProxy(ref);
+ string ref = "thrower:" + getTestEndpoint(communicator, 0);
+ Ice::ObjectPrxPtr base = communicator->stringToProxy(ref);
test(base);
cout << "ok" << endl;
cout << "testing checked cast... " << flush;
- ThrowerPrx thrower = ThrowerPrx::checkedCast(base);
+ ThrowerPrxPtr thrower = ICE_CHECKED_CAST(ThrowerPrx, base);
test(thrower);
+#ifdef ICE_CPP11_MAPPING
+ test(Ice::targetEqualTo(thrower, base));
+#else
test(thrower == base);
+#endif
cout << "ok" << endl;
cout << "catching exact types... " << flush;
@@ -964,8 +993,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
cerr << ex << endl;
test(false);
}
-
- ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(communicator->stringToProxy("thrower:default -p 12011"));
+
+ ThrowerPrxPtr thrower2 =
+ ICE_UNCHECKED_CAST(ThrowerPrx, communicator->stringToProxy("thrower:" + getTestEndpoint(communicator, 1)));
try
{
thrower2->throwMemoryLimitException(Ice::ByteSeq(2 * 1024 * 1024)); // 2MB (no limits)
@@ -973,7 +1003,8 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::MemoryLimitException&)
{
}
- ThrowerPrx thrower3 = ThrowerPrx::uncheckedCast(communicator->stringToProxy("thrower:default -p 12012"));
+ ThrowerPrxPtr thrower3 =
+ ICE_UNCHECKED_CAST(ThrowerPrx, communicator->stringToProxy("thrower:" + getTestEndpoint(communicator, 2)));
try
{
thrower3->throwMemoryLimitException(Ice::ByteSeq(1024)); // 1KB limit
@@ -988,10 +1019,10 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "catching object not exist exception... " << flush;
- Ice::Identity id = communicator->stringToIdentity("does not exist");
+ Ice::Identity id = Ice::stringToIdentity("does not exist");
try
{
- ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower->ice_identity(id));
+ ThrowerPrxPtr thrower2 = ICE_UNCHECKED_CAST(ThrowerPrx, thrower->ice_identity(id));
thrower2->throwAasA(1);
// thrower2->ice_ping();
test(false);
@@ -1011,7 +1042,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
try
{
- ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower, "no such facet");
+#ifdef ICE_CPP11_MAPPING
+ ThrowerPrxPtr thrower2 = Ice::uncheckedCast<ThrowerPrx>(thrower, "no such facet");
+#else
+ ThrowerPrxPtr thrower2 = ThrowerPrx::uncheckedCast(thrower, "no such facet");
+#endif
try
{
thrower2->ice_ping();
@@ -1033,7 +1068,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
try
{
- WrongOperationPrx thrower2 = WrongOperationPrx::uncheckedCast(thrower);
+ WrongOperationPrxPtr thrower2 = ICE_UNCHECKED_CAST(WrongOperationPrx, thrower);
thrower2->noSuchOperation();
test(false);
}
@@ -1111,6 +1146,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
try
{
thrower->throwAfterException();
+ test(false);
}
catch(const A&)
{
@@ -1123,62 +1159,314 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "ok" << endl;
cout << "catching exact types with new AMI mapping... " << flush;
+#ifdef ICE_CPP11_MAPPING
+ {
+ auto f = thrower->throwAasAAsync(1);
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const A& ex)
+ {
+ test(ex.aMem == 1);
+ }
+ catch(const Ice::Exception&)
+ {
+ test(false);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
{
+ auto f = thrower->throwAorDasAorDAsync(1);
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const A& ex)
+ {
+ test(ex.aMem == 1);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+
+ {
+ auto f = thrower->throwAorDasAorDAsync(-1);
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const D& ex)
+ {
+ test(ex.dMem == -1);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ {
+ auto f = thrower->throwBasBAsync(1, 2);
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const B& ex)
+ {
+ test(ex.aMem == 1);
+ test(ex.bMem == 2);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ {
+ auto f = thrower->throwCasCAsync(1, 2, 3);
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const C& ex)
+ {
+ test(ex.aMem == 1);
+ test(ex.bMem == 2);
+ test(ex.cMem == 3);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+ {
+ auto f = thrower->throwModAAsync(1, 2);
+ try
+ {
+ f.get();
+ }
+ catch(const A& ex)
+ {
+ test(ex.aMem == 1);
+ }
+ catch(const Ice::OperationNotExistException&)
+ {
+ //
+ // This operation is not supported in Java.
+ //
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+
+ //
+ // repeat with callback API and no exception callback
+ //
+ {
+ promise<bool> sent;
+ thrower->throwAasAAsync(1,
+ []()
+ {
+ test(false);
+ },
+ nullptr,
+ [&](bool value)
+ {
+ sent.set_value(value);
+ });
+ sent.get_future().get(); // Wait for sent
+ }
+
+ {
+ promise<bool> sent;
+ thrower->throwAorDasAorDAsync(1,
+ []()
+ {
+ test(false);
+ },
+ nullptr,
+ [&](bool value)
+ {
+ sent.set_value(value);
+ });
+ sent.get_future().get(); // Wait for sent
+ }
+
+ {
+ promise<bool> sent;
+ thrower->throwAorDasAorDAsync(-1,
+ []()
+ {
+ test(false);
+ },
+ nullptr,
+ [&](bool value)
+ {
+ sent.set_value(value);
+ });
+ sent.get_future().get(); // Wait for sent
+ }
+
+ {
+ promise<bool> sent;
+ thrower->throwBasBAsync(1, 2,
+ []()
+ {
+ test(false);
+ },
+ nullptr,
+ [&](bool value)
+ {
+ sent.set_value(value);
+ });
+ sent.get_future().get(); // Wait for sent
+ }
+
+ {
+ promise<bool> sent;
+ thrower->throwCasCAsync(1, 2, 3,
+ []()
+ {
+ test(false);
+ },
+ nullptr,
+ [&](bool value)
+ {
+ sent.set_value(value);
+ });
+ sent.get_future().get(); // Wait for sent
+ }
+
+ {
+ promise<bool> sent;
+ thrower->throwModAAsync(1, 2,
+ []()
+ {
+ test(false);
+ },
+ nullptr,
+ [&](bool value)
+ {
+ sent.set_value(value);
+ });
+ sent.get_future().get(); // Wait for sent
+ }
+#else
+ {
CallbackPtr cb = new Callback;
- Callback_Thrower_throwAasAPtr callback =
+ Callback_Thrower_throwAasAPtr callback =
newCallback_Thrower_throwAasA(cb, &Callback::response, &Callback::exception_AasA);
thrower->begin_throwAasA(1, callback);
cb->check();
}
-
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwAorDasAorDPtr callback =
+ Callback_Thrower_throwAorDasAorDPtr callback =
newCallback_Thrower_throwAorDasAorD(cb, &Callback::response, &Callback::exception_AorDasAorD);
thrower->begin_throwAorDasAorD(1, callback);
cb->check();
}
-
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwAorDasAorDPtr callback =
+ Callback_Thrower_throwAorDasAorDPtr callback =
newCallback_Thrower_throwAorDasAorD(cb, &Callback::response, &Callback::exception_AorDasAorD);
thrower->begin_throwAorDasAorD(-1, callback);
cb->check();
}
-
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwBasBPtr callback =
+ Callback_Thrower_throwBasBPtr callback =
newCallback_Thrower_throwBasB(cb, &Callback::response, &Callback::exception_BasB);
thrower->begin_throwBasB(1, 2, callback);
cb->check();
}
-
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwCasCPtr callback =
+ Callback_Thrower_throwCasCPtr callback =
newCallback_Thrower_throwCasC(cb, &Callback::response, &Callback::exception_CasC);
thrower->begin_throwCasC(1, 2, 3, callback);
cb->check();
}
-
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwModAPtr callback =
+ Callback_Thrower_throwModAPtr callback =
newCallback_Thrower_throwModA(cb, &Callback::response, &Callback::exception_ModA);
thrower->begin_throwModA(1, 2, callback);
cb->check();
}
-
+#endif
cout << "ok" << endl;
cout << "catching derived types with new AMI mapping... " << flush;
+#ifdef ICE_CPP11_MAPPING
+ {
+ auto f = thrower->throwBasAAsync(1, 2);
+ try
+ {
+ f.get();
+ }
+ catch(const B& ex)
+ {
+ test(ex.aMem == 1);
+ test(ex.bMem == 2);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
{
+ auto f = thrower->throwCasAAsync(1, 2, 3);
+ try
+ {
+ f.get();
+ }
+ catch(const C& ex)
+ {
+ test(ex.aMem == 1);
+ test(ex.bMem == 2);
+ test(ex.cMem == 3);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+
+ {
+ auto f = thrower->throwCasBAsync(1, 2, 3);
+ try
+ {
+ f.get();
+ }
+ catch(const C& ex)
+ {
+ test(ex.aMem == 1);
+ test(ex.bMem == 2);
+ test(ex.cMem == 3);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+#else
+ {
CallbackPtr cb = new Callback;
- Callback_Thrower_throwBasAPtr callback =
+ Callback_Thrower_throwBasAPtr callback =
newCallback_Thrower_throwBasA(cb, &Callback::response, &Callback::exception_BasA);
thrower->begin_throwBasA(1, 2, callback);
cb->check();
@@ -1186,7 +1474,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwCasAPtr callback =
+ Callback_Thrower_throwCasAPtr callback =
newCallback_Thrower_throwCasA(cb, &Callback::response, &Callback::exception_CasA);
thrower->begin_throwCasA(1, 2, 3, callback);
cb->check();
@@ -1194,21 +1482,74 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwCasBPtr callback =
+ Callback_Thrower_throwCasBPtr callback =
newCallback_Thrower_throwCasB(cb, &Callback::response, &Callback::exception_CasB);
thrower->begin_throwCasB(1, 2, 3, callback);
cb->check();
}
-
+#endif
cout << "ok" << endl;
if(thrower->supportsUndeclaredExceptions())
{
cout << "catching unknown user exception with new AMI mapping... " << flush;
+#ifdef ICE_CPP11_MAPPING
+ {
+ auto f = thrower->throwUndeclaredAAsync(1);
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const Ice::UnknownUserException&)
+ {
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cout << ex << endl;
+ cout << ex.ice_stackTrace() << endl;
+ test(false);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+
+ {
+ auto f = thrower->throwUndeclaredBAsync(1, 2);
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const Ice::UnknownUserException&)
+ {
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
{
+ auto f = thrower->throwUndeclaredCAsync(1, 2, 3);
+ try
+ {
+ f.get();
+ }
+ catch(const Ice::UnknownUserException&)
+ {
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+#else
+ {
CallbackPtr cb = new Callback;
- Callback_Thrower_throwUndeclaredAPtr callback =
+ Callback_Thrower_throwUndeclaredAPtr callback =
newCallback_Thrower_throwUndeclaredA(cb, &Callback::response, &Callback::exception_UndeclaredA);
thrower->begin_throwUndeclaredA(1, callback);
cb->check();
@@ -1224,25 +1565,43 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwUndeclaredCPtr callback =
+ Callback_Thrower_throwUndeclaredCPtr callback =
newCallback_Thrower_throwUndeclaredC(cb, &Callback::response, &Callback::exception_UndeclaredC);
thrower->begin_throwUndeclaredC(1, 2, 3, callback);
cb->check();
}
-
+#endif
cout << "ok" << endl;
}
cout << "catching object not exist exception with new AMI mapping... " << flush;
{
- id = communicator->stringToIdentity("does not exist");
+#ifdef ICE_CPP11_MAPPING
+ id = Ice::stringToIdentity("does not exist");
+ shared_ptr<ThrowerPrx> thrower2 = Ice::uncheckedCast<ThrowerPrx>(thrower->ice_identity(id));
+ auto f = thrower2->throwAasAAsync(1);
+ try
+ {
+ f.get();
+ }
+ catch(const Ice::ObjectNotExistException& ex)
+ {
+ test(ex.id == id);
+ }
+ catch(...)
+ {
+ test(false);
+ }
+#else
+ id = Ice::stringToIdentity("does not exist");
ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower->ice_identity(id));
CallbackPtr cb = new Callback(communicator);
- Callback_Thrower_throwAasAPtr callback =
+ Callback_Thrower_throwAasAPtr callback =
newCallback_Thrower_throwAasA(cb, &Callback::response, &Callback::exception_AasAObjectNotExist);
thrower2->begin_throwAasA(1, callback);
cb->check();
+#endif
}
cout << "ok" << endl;
@@ -1250,12 +1609,25 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "catching facet not exist exception with new AMI mapping... " << flush;
{
+#ifdef ICE_CPP11_MAPPING
+ shared_ptr<ThrowerPrx> thrower2 = Ice::uncheckedCast<ThrowerPrx>(thrower, "no such facet");
+ auto f = thrower2->throwAasAAsync(1);
+ try
+ {
+ f.get();
+ }
+ catch(const Ice::FacetNotExistException& ex)
+ {
+ test(ex.facet == "no such facet");
+ }
+#else
ThrowerPrx thrower2 = ThrowerPrx::uncheckedCast(thrower, "no such facet");
CallbackPtr cb = new Callback;
- Callback_Thrower_throwAasAPtr callback =
+ Callback_Thrower_throwAasAPtr callback =
newCallback_Thrower_throwAasA(cb, &Callback::response, &Callback::exception_AasAFacetNotExist);
thrower2->begin_throwAasA(1, callback);
cb->check();
+#endif
}
cout << "ok" << endl;
@@ -1263,22 +1635,74 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "catching operation not exist exception with new AMI mapping... " << flush;
{
+#ifdef ICE_CPP11_MAPPING
+ shared_ptr<WrongOperationPrx> thrower4 = Ice::uncheckedCast<WrongOperationPrx>(thrower);
+ auto f = thrower4->noSuchOperationAsync();
+ try
+ {
+ f.get();
+ }
+ catch(const Ice::OperationNotExistException& ex)
+ {
+ test(ex.operation == "noSuchOperation");
+ }
+ catch(...)
+ {
+ test(false);
+ }
+#else
CallbackPtr cb = new Callback;
- Callback_WrongOperation_noSuchOperationPtr callback =
- newCallback_WrongOperation_noSuchOperation(cb, &Callback::response,
+ Callback_WrongOperation_noSuchOperationPtr callback =
+ newCallback_WrongOperation_noSuchOperation(cb, &Callback::response,
&Callback::exception_noSuchOperation);
WrongOperationPrx thrower4 = WrongOperationPrx::uncheckedCast(thrower);
thrower4->begin_noSuchOperation(callback);
cb->check();
+#endif
}
cout << "ok" << endl;
cout << "catching unknown local exception with new AMI mapping... " << flush;
+#ifdef ICE_CPP11_MAPPING
+ {
+ auto f = thrower->throwLocalExceptionAsync();
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const Ice::UnknownLocalException&)
+ {
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
{
+ auto f = thrower->throwLocalExceptionIdempotentAsync();
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const Ice::UnknownLocalException&)
+ {
+ }
+ catch(const Ice::OperationNotExistException&)
+ {
+ }
+ catch(...)
+ {
+ test(false);
+ }
+ }
+#else
+ {
CallbackPtr cb = new Callback;
- Callback_Thrower_throwLocalExceptionPtr callback =
+ Callback_Thrower_throwLocalExceptionPtr callback =
newCallback_Thrower_throwLocalException(cb, &Callback::response, &Callback::exception_LocalException);
thrower->begin_throwLocalException(callback);
cb->check();
@@ -1286,23 +1710,40 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
CallbackPtr cb = new Callback;
- Callback_Thrower_throwLocalExceptionIdempotentPtr callback =
- newCallback_Thrower_throwLocalExceptionIdempotent(cb, &Callback::response,
+ Callback_Thrower_throwLocalExceptionIdempotentPtr callback =
+ newCallback_Thrower_throwLocalExceptionIdempotent(cb, &Callback::response,
&Callback::exception_LocalException);
thrower->begin_throwLocalExceptionIdempotent(callback);
cb->check();
}
-
+#endif
cout << "ok" << endl;
cout << "catching unknown non-Ice exception with new AMI mapping... " << flush;
{
+#ifdef ICE_CPP11_MAPPING
+ auto f = thrower->throwNonIceExceptionAsync();
+ try
+ {
+ f.get();
+ test(false);
+ }
+ catch(const Ice::UnknownException&)
+ {
+ }
+ catch(...)
+ {
+ test(false);
+ }
+
+#else
CallbackPtr cb = new Callback;
- Callback_Thrower_throwNonIceExceptionPtr callback =
+ Callback_Thrower_throwNonIceExceptionPtr callback =
newCallback_Thrower_throwNonIceException(cb, &Callback::response, &Callback::exception_NonIceException);
thrower->begin_throwNonIceException(callback);
cb->check();
+#endif
}
cout << "ok" << endl;