git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1311239 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-04-09 14:11:50 +00:00
parent 2280719835
commit 681c1abf37
1 changed files with 43 additions and 0 deletions

View File

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