summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/exception_test.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-12-10 17:57:49 +0000
committerAlan Conway <aconway@apache.org>2007-12-10 17:57:49 +0000
commitef19d923c46c43e937f1d4dd91c906bda08d64bd (patch)
treee4e8fa91f12edbebccb80f4916d1654fcbae2022 /qpid/cpp/src/tests/exception_test.cpp
parent92a003c58ae103c30024b588accfe2ef86de561d (diff)
downloadqpid-python-ef19d923c46c43e937f1d4dd91c906bda08d64bd.tar.gz
src/tests/SocketProxy.h: proxy between local client & server to simulate network disconnect.
src/qpid/client/Connector.h: remove friend hack for previous flawed disconnect approach. src/tests/BrokerFixture.h: "" src/tests/ClientSessionTest.cpp, exception_test.cpp: use ProxyConnection git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@602980 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/exception_test.cpp')
-rw-r--r--qpid/cpp/src/tests/exception_test.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/qpid/cpp/src/tests/exception_test.cpp b/qpid/cpp/src/tests/exception_test.cpp
index e774c48070..a8ee3bd37c 100644
--- a/qpid/cpp/src/tests/exception_test.cpp
+++ b/qpid/cpp/src/tests/exception_test.cpp
@@ -21,6 +21,7 @@
#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"
@@ -71,31 +72,33 @@ struct Catcher : public Runnable {
};
BOOST_FIXTURE_TEST_CASE(DisconnectedGet, BrokerFixture) {
- Catcher<ClosedException> get(bind(&Session_0_10::get, session));
- disconnect(connection);
+ 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) {
- session.queueDeclare(arg::queue="q");
+ ProxyConnection c(broker->getPort());
+ c.session.queueDeclare(arg::queue="q");
subs.subscribe(lq, "q");
Catcher<ClosedException> pop(bind(&LocalQueue::pop, boost::ref(lq)));
- disconnect(connection);
+ c.proxy.client.close();
BOOST_CHECK(pop.join());
}
-// FIXME aconway 2007-12-07: This test hangs sporadically at t.join
-// BOOST_FIXTURE_TEST_CASE(DisconnectedListen, BrokerFixture) {
-// struct NullListener : public MessageListener {
-// void received(Message&) { BOOST_FAIL("Unexpected message"); }
-// } l;
-// session.queueDeclare(arg::queue="q");
-// subs.subscribe(l, "q");
-// Thread t(subs);
-// disconnect(connection);
-// t.join();
-// BOOST_CHECK_THROW(session.close(), InternalErrorException);
-// }
+BOOST_FIXTURE_TEST_CASE(DisconnectedListen, BrokerFixture) {
+ struct NullListener : public MessageListener {
+ void received(Message&) { BOOST_FAIL("Unexpected message"); }
+ } l;
+ ProxyConnection c;
+ 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(NoSuchQueueTest, BrokerFixture) {
BOOST_CHECK_THROW(subs.subscribe(lq, "no such queue").sync(), NotFoundException);