From cb3392c307f0177da0372044ac2edd48b8b1bab4 Mon Sep 17 00:00:00 2001 From: "Timothy A. Bish" Date: Wed, 31 Oct 2012 13:10:14 +0000 Subject: [PATCH] updated test case to check: https://issues.apache.org/jira/browse/AMQ-4149 could not reproduce issue. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1404122 13f79535-47bb-0310-9956-ffa450edef68 --- .../DurableSubscriptionRemoveOfflineTest.java | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java index c9d37a1597..b6c7d0d695 100644 --- a/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/usecases/DurableSubscriptionRemoveOfflineTest.java @@ -16,16 +16,17 @@ */ package org.apache.activemq.usecases; -import junit.framework.Test; -import org.apache.activemq.EmbeddedBrokerTestSupport; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.util.Wait; - import javax.jms.Connection; import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicSubscriber; +import junit.framework.Test; + +import org.apache.activemq.EmbeddedBrokerTestSupport; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.util.Wait; + public class DurableSubscriptionRemoveOfflineTest extends EmbeddedBrokerTestSupport { protected void setUp() throws Exception { @@ -46,6 +47,21 @@ public class DurableSubscriptionRemoveOfflineTest extends EmbeddedBrokerTestSupp return answer; } + protected BrokerService restartBroker() throws Exception { + broker.stop(); + broker.waitUntilStopped(); + broker = null; + + broker = super.createBroker(); + broker.setOfflineDurableSubscriberTaskSchedule(3 * 1000); + broker.setOfflineDurableSubscriberTimeout(5 * 1000); + + broker.start(); + broker.waitUntilStarted(); + + return broker; + } + public void testRemove() throws Exception { Connection connection = createConnection(); connection.setClientID("cliID"); @@ -60,10 +76,29 @@ public class DurableSubscriptionRemoveOfflineTest extends EmbeddedBrokerTestSupp public boolean isSatisified() throws Exception { return broker.getAdminView().getInactiveDurableTopicSubscribers().length == 0; } - }, 10000); - + }, 15000); } + public void testRemoveAfterRestart() throws Exception { + Connection connection = createConnection(); + connection.setClientID("cliID"); + connection.start(); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + TopicSubscriber subscriber = session.createDurableSubscriber((Topic) createDestination(), "subName"); + subscriber.close(); + connection.close(); + + restartBroker(); + + assertTrue(broker.getAdminView().getInactiveDurableTopicSubscribers().length == 1); + + Wait.waitFor(new Wait.Condition() { + @Override + public boolean isSatisified() throws Exception { + return broker.getAdminView().getInactiveDurableTopicSubscribers().length == 0; + } + }, 20000); + } protected boolean isPersistent() { return true;