activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1021425 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/jmx/BrokerView.java test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java
Date Mon, 11 Oct 2010 16:50:12 GMT
Author: dejanb
Date: Mon Oct 11 16:50:12 2010
New Revision: 1021425

URL: http://svn.apache.org/viewvc?rev=1021425&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2970 - advisory and jmx create/delete destination

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java?rev=1021425&r1=1021424&r2=1021425&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/jmx/BrokerView.java
Mon Oct 11 16:50:12 2010
@@ -242,20 +242,20 @@ public class BrokerView implements Broke
     }
 
     public void addTopic(String name) throws Exception {
-        broker.addDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQTopic(name),true);
+        broker.getContextBroker().addDestination(getConnectionContext(broker.getContextBroker()),
new ActiveMQTopic(name),true);
     }
 
     public void addQueue(String name) throws Exception {
-        broker.addDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQQueue(name),true);
+        broker.getContextBroker().addDestination(getConnectionContext(broker.getContextBroker()),
new ActiveMQQueue(name),true);
     }
 
     public void removeTopic(String name) throws Exception {
-        broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQTopic(name),
+        broker.getContextBroker().removeDestination(getConnectionContext(broker.getContextBroker()),
new ActiveMQTopic(name),
                                  1000);
     }
 
     public void removeQueue(String name) throws Exception {
-        broker.removeDestination(getConnectionContext(broker.getContextBroker()), new ActiveMQQueue(name),
+        broker.getContextBroker().removeDestination(getConnectionContext(broker.getContextBroker()),
new ActiveMQQueue(name),
                                  1000);
     }
 

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java?rev=1021425&r1=1021424&r2=1021425&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryBrokerTest.java
Mon Oct 11 16:50:12 2010
@@ -30,6 +30,10 @@ import org.apache.activemq.command.Produ
 import org.apache.activemq.command.RemoveInfo;
 import org.apache.activemq.command.SessionInfo;
 
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
 public class AdvisoryBrokerTest extends BrokerTestSupport {
      
     public void testConnectionAdvisories() throws Exception {

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java?rev=1021425&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/advisory/AdvisoryJmxTest.java
Mon Oct 11 16:50:12 2010
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.broker.advisory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.EmbeddedBrokerTestSupport;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.jmx.BrokerViewMBean;
+import org.apache.activemq.broker.jmx.ManagementContext;
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.command.ActiveMQMessage;
+import org.apache.activemq.command.DestinationInfo;
+
+import javax.jms.*;
+import javax.management.MBeanServerConnection;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+public class AdvisoryJmxTest extends EmbeddedBrokerTestSupport {
+
+        protected BrokerService createBroker() throws Exception {
+        BrokerService answer = new BrokerService();
+        answer.setPersistent(isPersistent());
+        answer.addConnector(bindAddress);
+        ManagementContext context = new ManagementContext();
+        context.setConnectorPort(1199);
+        answer.setManagementContext(context);
+        return answer;
+    }
+
+    public void testCreateDeleteDestinations() throws Exception {
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
+        JMXConnector connector = JMXConnectorFactory.connect(url, null);
+        connector.connect();
+        MBeanServerConnection connection = connector.getMBeanServerConnection();
+        ObjectName name = new ObjectName("org.apache.activemq:Type=Broker,BrokerName=localhost");
+        BrokerViewMBean brokerMbean = (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(connection,
name, BrokerViewMBean.class, true);
+        Connection conn = createConnection();
+        Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        MessageConsumer consumer = sess.createConsumer(sess.createTopic("ActiveMQ.Advisory.Queue"));
+        conn.start();
+        Destination dest = sess.createQueue("test");
+
+        brokerMbean.addQueue("test");
+
+        ActiveMQMessage msg = (ActiveMQMessage)consumer.receive(1000);
+        assertNotNull(msg);
+        assertTrue(msg.getDataStructure() instanceof DestinationInfo);
+        assertEquals(((DestinationInfo)msg.getDataStructure()).getDestination(), dest);
+        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 0);
+
+        brokerMbean.removeQueue("test");
+
+        msg = (ActiveMQMessage)consumer.receive(1000);
+        assertNotNull(msg);
+        assertTrue(msg.getDataStructure() instanceof DestinationInfo);
+        assertEquals(((DestinationInfo)msg.getDataStructure()).getDestination(), dest);
+        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 1);
+
+
+        brokerMbean.addQueue("test");
+        msg = (ActiveMQMessage)consumer.receive(1000);
+        assertNotNull(msg);
+        assertTrue(msg.getDataStructure() instanceof DestinationInfo);
+        assertEquals(((DestinationInfo)msg.getDataStructure()).getDestination(), dest);
+        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 0);
+        assertEquals(((DestinationInfo)msg.getDataStructure()).getOperationType(), 0);
+    }
+
+
+}



Mime
View raw message