summaryrefslogtreecommitdiff
path: root/cpp/src/tests/ClientSessionTest.cpp
diff options
context:
space:
mode:
authorKim van der Riet <kpvdr@apache.org>2010-02-15 18:36:21 +0000
committerKim van der Riet <kpvdr@apache.org>2010-02-15 18:36:21 +0000
commitdef38493b7c9ac3766d60e0cdd334bb1db7f6139 (patch)
tree34b7ea764ad0bf24dcaffcef1c7e67a5135cba08 /cpp/src/tests/ClientSessionTest.cpp
parent18ab7b99112de6c137285da1f147efbe6fca3216 (diff)
downloadqpid-python-def38493b7c9ac3766d60e0cdd334bb1db7f6139.tar.gz
Added handling for adjusting TTL on outgoing message based on how long a message has been on the queue. Added a new TTL test as ClientSessionTest.testTtl.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@910289 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/ClientSessionTest.cpp')
-rw-r--r--cpp/src/tests/ClientSessionTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/cpp/src/tests/ClientSessionTest.cpp b/cpp/src/tests/ClientSessionTest.cpp
index e8cdb1f232..596f3282ce 100644
--- a/cpp/src/tests/ClientSessionTest.cpp
+++ b/cpp/src/tests/ClientSessionTest.cpp
@@ -642,6 +642,36 @@ QPID_AUTO_TEST_CASE(testQueueDeleted)
BOOST_CHECK_THROW(queue.get(1*qpid::sys::TIME_SEC), qpid::framing::ResourceDeletedException);
}
+QPID_AUTO_TEST_CASE(testTtl)
+{
+ const uint64_t ms = 1000ULL; // convert sec to ms
+ const uint64_t us = 1000ULL * 1000ULL; // convert sec to us
+
+ ClientSessionFixture fix;
+ fix.session.queueDeclare(arg::queue="ttl-test", arg::exclusive=true, arg::autoDelete=true);
+ Message msg1 = Message("AAA", "ttl-test");
+ uint64_t ttl = 2 * ms; // 2 sec
+ msg1.getDeliveryProperties().setTtl(ttl);
+ Connection c = fix.session.getConnection();
+ Session s = c.newSession();
+ s.messageTransfer(arg::content=msg1);
+
+ Message msg2 = Message("BBB", "ttl-test");
+ ttl = 10 * ms; // 10 sec
+ msg2.getDeliveryProperties().setTtl(ttl);
+ s.messageTransfer(arg::content=msg2);
+
+ ::usleep(5 * us); // 5 sec
+
+ // Message "AAA" should be expired and never be delivered
+ // Check "BBB" has ttl somewhere between 1 and 5 secs
+ Message got;
+ BOOST_CHECK(fix.subs.get(got, "ttl-test"));
+ BOOST_CHECK_EQUAL("BBB", got.getData());
+ BOOST_CHECK(got.getDeliveryProperties().getTtl() > 1 * ms);
+ BOOST_CHECK(got.getDeliveryProperties().getTtl() < ttl - (5 * ms));
+}
+
QPID_AUTO_TEST_SUITE_END()
}} // namespace qpid::tests