summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/exceptions/AllTests.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-10-14 17:58:55 +0000
committerMarc Laukien <marc@zeroc.com>2001-10-14 17:58:55 +0000
commit5c872d29b6223e23daea5b510a2bcb4d43fa08eb (patch)
treee4e7f5a7f43a76c7cee0a52626b2a1c294763bb9 /cpp/test/Ice/exceptions/AllTests.cpp
parentfixes (diff)
downloadice-5c872d29b6223e23daea5b510a2bcb4d43fa08eb.tar.bz2
ice-5c872d29b6223e23daea5b510a2bcb4d43fa08eb.tar.xz
ice-5c872d29b6223e23daea5b510a2bcb4d43fa08eb.zip
user exceptin factories
Diffstat (limited to 'cpp/test/Ice/exceptions/AllTests.cpp')
-rw-r--r--cpp/test/Ice/exceptions/AllTests.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/cpp/test/Ice/exceptions/AllTests.cpp b/cpp/test/Ice/exceptions/AllTests.cpp
index 128e2ef1bae..e19b456ecab 100644
--- a/cpp/test/Ice/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/exceptions/AllTests.cpp
@@ -14,6 +14,37 @@
using namespace std;
+class MyExceptionFactory : public Ice::UserExceptionFactory
+{
+public:
+
+ virtual void createAndThrow(const string& type)
+ {
+ if (type == "::A")
+ {
+ throw A();
+ }
+ else if (type == "::B")
+ {
+ throw B();
+ }
+ else if (type == "::C")
+ {
+ throw C();
+ }
+ else if (type == "::D")
+ {
+ throw D();
+ }
+ assert(false); // Should never be reached
+ }
+
+ virtual void destroy()
+ {
+ // Nothing to do
+ }
+};
+
ThrowerPrx
allTests(const Ice::CommunicatorPtr& communicator)
{
@@ -186,6 +217,63 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "ok" << endl;
+ cout << "catching derived types w/ exception factories... " << flush;
+
+ Ice::UserExceptionFactoryPtr factory = new MyExceptionFactory;
+ communicator->addUserExceptionFactory(factory, "::A");
+ communicator->addUserExceptionFactory(factory, "::B");
+ communicator->addUserExceptionFactory(factory, "::C");
+ communicator->addUserExceptionFactory(factory, "::D");
+
+ try
+ {
+ thrower->throwBasA(1, 2);
+ test(false);
+ }
+ catch (const B& ex)
+ {
+ test(ex.a == 1);
+ test(ex.b == 2);
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwCasA(1, 2, 3);
+ test(false);
+ }
+ catch (const C& ex)
+ {
+ test(ex.a == 1);
+ test(ex.b == 2);
+ test(ex.c == 3);
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ try
+ {
+ thrower->throwCasB(1, 2, 3);
+ test(false);
+ }
+ catch (const C& ex)
+ {
+ test(ex.a == 1);
+ test(ex.b == 2);
+ test(ex.c == 3);
+ }
+ catch (...)
+ {
+ test(false);
+ }
+
+ cout << "ok" << endl;
+
cout << "catching unknown user exception... " << flush;
try