diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2009-07-31 16:52:59 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2009-07-31 16:52:59 +0000 |
commit | d4408a59e892bd66cd17ac9fd09b949821260b77 (patch) | |
tree | 84e703d42c69ee1cb49b152a141b179830aade11 /cpp/src/tests/QueueTest.cpp | |
parent | 1b8de5a72a9bb1faadfd685975f2c99efdb0b0d4 (diff) | |
download | qpid-python-d4408a59e892bd66cd17ac9fd09b949821260b77.tar.gz |
handle fail setting last-node-standing with unit test, still needs system test
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@799658 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/QueueTest.cpp')
-rw-r--r-- | cpp/src/tests/QueueTest.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp index be4a87d2ab..b70afa52a7 100644 --- a/cpp/src/tests/QueueTest.cpp +++ b/cpp/src/tests/QueueTest.cpp @@ -19,6 +19,7 @@ * */ #include "unit_test.h" +#include "test_tools.h" #include "qpid/Exception.h" #include "qpid/broker/Broker.h" #include "qpid/broker/Queue.h" @@ -275,11 +276,13 @@ class TestMessageStoreOC : public NullMessageStore uint enqCnt; uint deqCnt; + bool error; virtual void dequeue(TransactionContext*, const boost::intrusive_ptr<PersistableMessage>& /*msg*/, const PersistableQueue& /*queue*/) { + if (error) throw Exception("Dequeue error test"); deqCnt++; } @@ -287,10 +290,16 @@ class TestMessageStoreOC : public NullMessageStore const boost::intrusive_ptr<PersistableMessage>& /*msg*/, const PersistableQueue& /* queue */) { + if (error) throw Exception("Enqueue error test"); enqCnt++; } - TestMessageStoreOC() : NullMessageStore(),enqCnt(0),deqCnt(0) {} + void createError() + { + error=true; + } + + TestMessageStoreOC() : NullMessageStore(),enqCnt(0),deqCnt(0),error(false) {} ~TestMessageStoreOC(){} }; @@ -689,6 +698,30 @@ not requeued to the store. } -QPID_AUTO_TEST_SUITE_END() +QPID_AUTO_TEST_CASE(testLastNodeJournalError){ +/* +simulate store excption going into last node standing + +*/ + TestMessageStoreOC testStore; + client::QueueOptions args; + // set queue mode + args.setPersistLastNode(); + + Queue::shared_ptr queue1(new Queue("my-queue", true, &testStore)); + intrusive_ptr<Message> received; + queue1->configure(args); + + // check requeue 1 + intrusive_ptr<Message> msg1 = create_message("e", "C"); + + queue1->deliver(msg1); + testStore.createError(); + + ScopedSuppressLogging sl; // Suppress messages for expected errors. + queue1->setLastNodeFailure(); + BOOST_CHECK_EQUAL(testStore.enqCnt, 0u); + +}QPID_AUTO_TEST_SUITE_END() |