diff options
| author | Gordon Sim <gsim@apache.org> | 2011-06-15 11:48:43 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2011-06-15 11:48:43 +0000 |
| commit | 02a6c2f7ab64332ea13dff4605a8478b4ec9bd37 (patch) | |
| tree | 8daf10524a6b7f20dd342df4ced6fc458d608817 /qpid/cpp/src/tests/MessagingSessionTests.cpp | |
| parent | ffffe1b5cd71d2f12a26124a903811a1e3da3c12 (diff) | |
| download | qpid-python-02a6c2f7ab64332ea13dff4605a8478b4ec9bd37.tar.gz | |
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@1136003 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/MessagingSessionTests.cpp')
| -rw-r--r-- | qpid/cpp/src/tests/MessagingSessionTests.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/qpid/cpp/src/tests/MessagingSessionTests.cpp b/qpid/cpp/src/tests/MessagingSessionTests.cpp index a93d8f78ae..fae45a94d0 100644 --- a/qpid/cpp/src/tests/MessagingSessionTests.cpp +++ b/qpid/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<Message> 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 |
