diff options
| author | Alan Conway <aconway@apache.org> | 2007-12-10 17:57:49 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-12-10 17:57:49 +0000 |
| commit | 22ef0be441cd0f12b1ca6402f397deac390ce4d0 (patch) | |
| tree | c124a8348ad9f0517116e2c638884c6e0adb50d1 /cpp/src/tests/exception_test.cpp | |
| parent | e997eeb68fdb7f975f9e70848832f2b0d7612683 (diff) | |
| download | qpid-python-22ef0be441cd0f12b1ca6402f397deac390ce4d0.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/qpid@602980 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/exception_test.cpp')
| -rw-r--r-- | cpp/src/tests/exception_test.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/cpp/src/tests/exception_test.cpp b/cpp/src/tests/exception_test.cpp index e774c48070..a8ee3bd37c 100644 --- a/cpp/src/tests/exception_test.cpp +++ b/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); |
