summaryrefslogtreecommitdiff
path: root/cpp/src/tests/exception_test.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-01-24 22:26:12 +0000
committerAlan Conway <aconway@apache.org>2008-01-24 22:26:12 +0000
commitf0a31beb7a609591e7b34e60ddfd85e9e183fbc0 (patch)
tree5582c3f04ee1b417d11050b0c994da657db09b39 /cpp/src/tests/exception_test.cpp
parentf2ab2fa9fcb713eedf21e98a2a3f9fab8e76dead (diff)
downloadqpid-python-f0a31beb7a609591e7b34e60ddfd85e9e183fbc0.tar.gz
Improved/additional client API tests.
- Replaced InProcessBroker with a more accurate loopback BrokerFixture. - Added asserts for mutex/condition/thread errors in debug build. - Added client tests for several exception conditions. - Added peer address to log ouput, client/server distinguished by (addr) or [addr] - Fixed various deadlocks & races exposed by the new asserts & tests. File-by-file: New BrokerFixture replaces InProcessBroker D src/tests/InProcessBroker.h M src/tests/BrokerFixture.h M src/tests/SocketProxy.h M src/tests/Makefile.am Made it run a bit faster. M src/tests/quick_perftest Redundant D src/tests/APRBaseTest.cpp Updated tests to use BrokerFixture M src/tests/ClientChannelTest.cpp M src/tests/exception_test.cpp M src/tests/ClientSessionTest.cpp Print thread IDs in decimal, same as GDB. M src/qpid/log/Logger.cpp Assert mutex/condition ops in debug build. M src/qpid/sys/posix/check.h M src/qpid/sys/posix/Mutex.h M src/qpid/sys/posix/Condition.h M src/qpid/sys/posix/Thread.h Added toFd() so SocketProxy can use ::select() M src/qpid/sys/Socket.h M src/qpid/sys/posix/Socket.cpp Fixes for races & deadlocks shown up by new tests & asserts. Mostly shutdown/close issues. M src/qpid/client/ConnectionHandler.h M src/qpid/client/ConnectionImpl.cpp M src/qpid/client/Demux.h M src/qpid/client/SessionCore.cpp M src/qpid/client/ConnectionHandler.cpp M src/qpid/client/Connector.h M src/qpid/client/Demux.cpp M src/qpid/client/Dispatcher.cpp M src/qpid/client/ConnectionImpl.h Logging peer address. M src/qpid/sys/AsynchIOAcceptor.cpp git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@615063 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/exception_test.cpp')
-rw-r--r--cpp/src/tests/exception_test.cpp53
1 files changed, 22 insertions, 31 deletions
diff --git a/cpp/src/tests/exception_test.cpp b/cpp/src/tests/exception_test.cpp
index d19307a5c0..700aeef47c 100644
--- a/cpp/src/tests/exception_test.cpp
+++ b/cpp/src/tests/exception_test.cpp
@@ -21,7 +21,6 @@
#include "unit_test.h"
#include "BrokerFixture.h"
-#include "SocketProxy.h"
#include "qpid/client/SubscriptionManager.h"
#include "qpid/sys/Runnable.h"
#include "qpid/sys/Thread.h"
@@ -52,7 +51,7 @@ struct Catcher : public Runnable {
try { f(); }
catch(const Ex& e) {
caught=true;
- BOOST_MESSAGE(e.what());
+ BOOST_MESSAGE(string("Caught expected exception: ")+e.what());
}
catch(const std::exception& e) {
BOOST_ERROR(string("Bad exception: ")+e.what());
@@ -71,37 +70,29 @@ struct Catcher : public Runnable {
}
};
-// FIXME aconway 2007-12-11: Disabled hanging tests.
-// BOOST_FIXTURE_TEST_CASE(DisconnectedGet, BrokerFixture) {
-// ProxyConnection c(broker->getPort());
-// Catcher<ClosedException> get(bind(&Session_0_10::get, c.session));
-// c.proxy.client.close(); // Close the client side.
-// BOOST_CHECK(get.join());
-// }
-
-// BOOST_FIXTURE_TEST_CASE(DisconnectedPop, BrokerFixture) {
-// ProxyConnection c(broker->getPort());
-// c.session.queueDeclare(arg::queue="q");
-// subs.subscribe(lq, "q");
-// Catcher<ClosedException> pop(bind(&LocalQueue::pop, boost::ref(lq)));
-// c.proxy.client.close();
-// BOOST_CHECK(pop.join());
-// }
+BOOST_FIXTURE_TEST_CASE(DisconnectedPop, ProxySessionFixture) {
+ ProxyConnection c(broker->getPort());
+ session.queueDeclare(arg::queue="q");
+ subs.subscribe(lq, "q");
+ Catcher<ClosedException> pop(bind(&LocalQueue::pop, boost::ref(lq)));
+ connection.proxy.close();
+ BOOST_CHECK(pop.join());
+}
-// BOOST_FIXTURE_TEST_CASE(DisconnectedListen, BrokerFixture) {
-// struct NullListener : public MessageListener {
-// void received(Message&) { BOOST_FAIL("Unexpected message"); }
-// } l;
-// ProxyConnection c(broker->getPort());
-// c.session.queueDeclare(arg::queue="q");
-// subs.subscribe(l, "q");
-// Thread t(subs);
-// c.proxy.client.close();
-// t.join();
-// BOOST_CHECK_THROW(c.session.close(), InternalErrorException);
-// }
+BOOST_FIXTURE_TEST_CASE(DisconnectedListen, ProxySessionFixture) {
+ struct NullListener : public MessageListener {
+ void received(Message&) { BOOST_FAIL("Unexpected message"); }
+ } l;
+ ProxyConnection c(broker->getPort());
+ session.queueDeclare(arg::queue="q");
+ subs.subscribe(l, "q");
+ Thread t(subs);
+ connection.proxy.close();
+ t.join();
+ BOOST_CHECK_THROW(session.close(), InternalErrorException);
+}
-BOOST_FIXTURE_TEST_CASE(NoSuchQueueTest, BrokerFixture) {
+BOOST_FIXTURE_TEST_CASE(NoSuchQueueTest, SessionFixture) {
BOOST_CHECK_THROW(subs.subscribe(lq, "no such queue").sync(), NotFoundException);
}