mirror of https://github.com/apache/activemq.git
add a test for: https://issues.apache.org/jira/browse/AMQ-3802
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1311239 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2280719835
commit
681c1abf37
|
@ -952,6 +952,49 @@ public class MBeanTest extends EmbeddedBrokerTestSupport {
|
|||
assertEquals(0, connectionView.getProducers().length);
|
||||
}
|
||||
|
||||
public void testCreateAndUnsubscribeDurableSubscriptions() throws Exception {
|
||||
|
||||
connection = connectionFactory.createConnection("admin", "admin");
|
||||
connection.setClientID("MBeanTest");
|
||||
|
||||
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
String topicName = getDestinationString() + ".DurableTopic";
|
||||
Topic topic = session.createTopic(topicName);
|
||||
|
||||
ObjectName brokerName = assertRegisteredObjectName(domain + ":Type=Broker,BrokerName=localhost");
|
||||
echo("Create QueueView MBean...");
|
||||
BrokerViewMBean broker = (BrokerViewMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, brokerName, BrokerViewMBean.class, true);
|
||||
|
||||
assertEquals("Durable subscriber count", 0, broker.getDurableTopicSubscribers().length);
|
||||
assertEquals("Durable subscriber count", 0, broker.getInactiveDurableTopicSubscribers().length);
|
||||
|
||||
MessageConsumer durableConsumer1 = session.createDurableSubscriber(topic, "subscription1");
|
||||
MessageConsumer durableConsumer2 = session.createDurableSubscriber(topic, "subscription2");
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
assertEquals("Durable subscriber count", 2, broker.getDurableTopicSubscribers().length);
|
||||
assertEquals("Durable subscriber count", 0, broker.getInactiveDurableTopicSubscribers().length);
|
||||
|
||||
durableConsumer1.close();
|
||||
durableConsumer2.close();
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
assertEquals("Durable subscriber count", 0, broker.getDurableTopicSubscribers().length);
|
||||
assertEquals("Durable subscriber count", 2, broker.getInactiveDurableTopicSubscribers().length);
|
||||
|
||||
session.unsubscribe("subscription1");
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
assertEquals("Inactive Durable subscriber count", 1, broker.getInactiveDurableTopicSubscribers().length);
|
||||
|
||||
session.unsubscribe("subscription2");
|
||||
|
||||
assertEquals("Inactive Durable subscriber count", 0, broker.getInactiveDurableTopicSubscribers().length);
|
||||
}
|
||||
|
||||
public void testUserNamePopulated() throws Exception {
|
||||
doTestUserNameInMBeans(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue