activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1311239 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Date Mon, 09 Apr 2012 14:11:51 GMT
Author: tabish
Date: Mon Apr  9 14:11:50 2012
New Revision: 1311239

URL: http://svn.apache.org/viewvc?rev=1311239&view=rev
Log:
add a test for: https://issues.apache.org/jira/browse/AMQ-3802

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java?rev=1311239&r1=1311238&r2=1311239&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/jmx/MBeanTest.java
Mon Apr  9 14:11:50 2012
@@ -952,6 +952,49 @@ public class MBeanTest extends EmbeddedB
         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);
     }



Mime
View raw message