summaryrefslogtreecommitdiff
path: root/cpp/src/tests/MessageReplayTracker.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-11-06 16:45:27 +0000
committerGordon Sim <gsim@apache.org>2008-11-06 16:45:27 +0000
commitf5371ed7a94deb0c261d1ca8b5185d8c94cdf325 (patch)
tree142d6b52c36c4b50e0079d296f6ce5be5a58f364 /cpp/src/tests/MessageReplayTracker.cpp
parent357557ff3f16b3dc0e6dacfab00e2d0a84f5c8fb (diff)
downloadqpid-python-f5371ed7a94deb0c261d1ca8b5185d8c94cdf325.tar.gz
* 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
Diffstat (limited to 'cpp/src/tests/MessageReplayTracker.cpp')
-rw-r--r--cpp/src/tests/MessageReplayTracker.cpp20
1 files changed, 20 insertions, 0 deletions
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++) {