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
This commit is contained in:
Timothy A. Bish 2012-10-31 13:10:14 +00:00
parent f6a5c7bd47
commit cb3392c307
1 changed files with 42 additions and 7 deletions

View File

@ -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;