From 3492b186c33b875dc2f0fb18fc32ab4dadd77a3d Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 15 Jun 2011 11:48:43 +0000 Subject: QPID-3200: Add new method to session for cumulative acknowledgement upto (and including) a specified message git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1136003 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/MessagingSessionTests.cpp | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'cpp/src/tests/MessagingSessionTests.cpp') diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp index a93d8f78ae..fae45a94d0 100644 --- a/cpp/src/tests/MessagingSessionTests.cpp +++ b/cpp/src/tests/MessagingSessionTests.cpp @@ -1024,6 +1024,46 @@ QPID_AUTO_TEST_CASE(testNonExclusiveSubscriber) fix.session.acknowledge(); } +QPID_AUTO_TEST_CASE(testAcknowledgeUpTo) +{ + QueueFixture fix; + Sender sender = fix.session.createSender(fix.queue); + const uint count(20); + for (uint i = 0; i < count; ++i) { + sender.send(Message((boost::format("Message_%1%") % (i+1)).str())); + } + + Session other = fix.connection.createSession(); + Receiver receiver = other.createReceiver(fix.queue); + std::vector messages; + for (uint i = 0; i < count; ++i) { + Message msg = receiver.fetch(); + BOOST_CHECK_EQUAL(msg.getContent(), (boost::format("Message_%1%") % (i+1)).str()); + messages.push_back(msg); + } + const uint batch = 10; + other.acknowledgeUpTo(messages[batch-1]);//acknowledge first 10 messages only + + messages.clear(); + other.sync(); + other.close(); + + other = fix.connection.createSession(); + receiver = other.createReceiver(fix.queue); + Message msg; + for (uint i = 0; i < (count-batch); ++i) { + msg = receiver.fetch(); + BOOST_CHECK_EQUAL(msg.getContent(), (boost::format("Message_%1%") % (i+1+batch)).str()); + } + other.acknowledgeUpTo(msg); + other.sync(); + other.close(); + + Message m; + //check queue is empty + BOOST_CHECK(!fix.session.createReceiver(fix.queue).fetch(m, Duration::IMMEDIATE)); +} + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests -- cgit v1.2.1