summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/interceptor/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/test/Ice/interceptor/Client.cpp')
-rw-r--r--cpp/test/Ice/interceptor/Client.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/cpp/test/Ice/interceptor/Client.cpp b/cpp/test/Ice/interceptor/Client.cpp
index fd7c8314d26..dc93891e819 100644
--- a/cpp/test/Ice/interceptor/Client.cpp
+++ b/cpp/test/Ice/interceptor/Client.cpp
@@ -35,6 +35,7 @@ private:
void runTest(const Test::MyObjectPrxPtr&, const InterceptorIPtr&);
void runAmdTest(const Test::MyObjectPrxPtr&, const AMDInterceptorIPtr&);
+ void testInterceptorExceptions(const Test::MyObjectPrx&);
};
void
@@ -169,6 +170,10 @@ Client::runTest(const Test::MyObjectPrxPtr& prx, const InterceptorIPtr& intercep
test(interceptor->getLastOperation() == "amdAdd");
test(!interceptor->getLastStatus());
cout << "ok" << endl;
+
+ cout << "testing exceptions raised by the interceptor... " << flush;
+ testInterceptorExceptions(prx);
+ cout << "ok" << endl;
}
void
@@ -234,6 +239,56 @@ Client::runAmdTest(const Test::MyObjectPrxPtr& prx, const AMDInterceptorIPtr& in
test(!interceptor->getLastStatus());
test(dynamic_cast<MySystemException*>(interceptor->getException()) != 0);
cout << "ok" << endl;
+
+ cout << "testing exceptions raised by the interceptor... " << flush;
+ testInterceptorExceptions(prx);
+ cout << "ok" << endl;
+}
+
+void
+Client::testInterceptorExceptions(const Test::MyObjectPrx& prx)
+{
+ vector<pair<string, string> > exceptions;
+ exceptions.push_back(make_pair("raiseBeforeDispatch", "user"));
+ exceptions.push_back(make_pair("raiseBeforeDispatch", "notExist"));
+ exceptions.push_back(make_pair("raiseBeforeDispatch", "system"));
+ exceptions.push_back(make_pair("raiseAfterDispatch", "user"));
+ exceptions.push_back(make_pair("raiseAfterDispatch", "notExist"));
+ exceptions.push_back(make_pair("raiseAfterDispatch", "system"));
+ for(vector<pair<string, string> >::const_iterator p = exceptions.begin(); p != exceptions.end(); ++p)
+ {
+ Ice::Context ctx;
+ ctx[p->first] = p->second;
+ try
+ {
+ prx->ice_ping(ctx);
+ test(false);
+ }
+ catch(const Ice::UnknownUserException&)
+ {
+ test(p->second == "user");
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ test(p->second == "notExist");
+ }
+ catch(const Ice::UnknownException&)
+ {
+ test(p->second == "system"); // non-collocated
+ }
+ catch(const MySystemException&)
+ {
+ test(p->second == "system"); // collocated
+ }
+ {
+ Ice::ObjectPrx batch = prx->ice_batchOneway();
+ batch->ice_ping(ctx);
+ batch->ice_ping();
+ batch->ice_flushBatchRequests();
+ }
+ }
+ // Force the last batch request to be dispatched by the server thread using invocation timeouts
+ prx->ice_invocationTimeout(10000)->ice_ping();
}
DEFINE_TEST(Client)