From 652d551063f377940e80e7590cc2c65aaef23964 Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Thu, 5 Nov 2009 12:14:21 +0000 Subject: [PATCH] adding durable topic expiration test git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@833034 13f79535-47bb-0310-9956-ffa450edef68 --- .../DurableSubscriptionTestSupport.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java index d87f5dc910..60e078a104 100755 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionTestSupport.java @@ -110,6 +110,32 @@ public abstract class DurableSubscriptionTestSupport extends TestSupport { } protected abstract PersistenceAdapter createPersistenceAdapter() throws Exception; + + public void testMessageExpire() throws Exception { + session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); + Topic topic = session.createTopic("TestTopic"); + consumer = session.createDurableSubscriber(topic, "sub1"); + producer = session.createProducer(topic); + producer.setDeliveryMode(DeliveryMode.PERSISTENT); + producer.setTimeToLive(1000); + connection.start(); + + // Make sure it works when the durable sub is active. + producer.send(session.createTextMessage("Msg:1")); + assertTextMessageEquals("Msg:1", consumer.receive(1000)); + + consumer.close(); + + producer.send(session.createTextMessage("Msg:2")); + producer.send(session.createTextMessage("Msg:3")); + + consumer = session.createDurableSubscriber(topic, "sub1"); + + // Try to get the message. + assertTextMessageEquals("Msg:2", consumer.receive(1000)); + Thread.sleep(1000); + assertNull(consumer.receive(1000)); + } public void testUnsubscribeSubscription() throws Exception { session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);