From f5371ed7a94deb0c261d1ca8b5185d8c94cdf325 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 6 Nov 2008 16:45:27 +0000 Subject: * fix bug causing last message to occasionally be lost on replay * make presence of gaps an error condition in the resuming_receiver example * add ability to apply functor to replay buffer git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@711903 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/MessageReplayTracker.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cpp/src/tests/MessageReplayTracker.cpp') diff --git a/cpp/src/tests/MessageReplayTracker.cpp b/cpp/src/tests/MessageReplayTracker.cpp index ba0174345f..a5121cdeb7 100644 --- a/cpp/src/tests/MessageReplayTracker.cpp +++ b/cpp/src/tests/MessageReplayTracker.cpp @@ -29,6 +29,23 @@ using namespace qpid::client; using namespace qpid::sys; using std::string; +class ReplayBufferChecker +{ + public: + + ReplayBufferChecker(uint from, uint to) : end(to), i(from) {} + + void operator()(const Message& m) + { + if (i > end) BOOST_FAIL("Extra message found: " + m.getData()); + BOOST_CHECK_EQUAL((boost::format("Message_%1%") % (i++)).str(), m.getData()); + } + private: + const uint end; + uint i; + +}; + QPID_AUTO_TEST_CASE(testReplay) { ProxySessionFixture fix; @@ -40,6 +57,9 @@ QPID_AUTO_TEST_CASE(testReplay) Message message((boost::format("Message_%1%") % (i+1)).str(), "my-queue"); tracker.send(message); } + ReplayBufferChecker checker(1, 10); + tracker.foreach(checker); + tracker.replay(fix.session); for (uint j = 0; j < 2; j++) {//each message should have been sent twice for (uint i = 0; i < 5; i++) { -- cgit v1.2.1