activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cepo...@apache.org
Subject svn commit: r1438666 - in /activemq/trunk/activemq-web: ./ src/main/java/org/apache/activemq/web/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/activemq/ src/test/java/org/apache/activemq/web/
Date Fri, 25 Jan 2013 19:50:16 GMT
Author: ceposta
Date: Fri Jan 25 19:50:15 2013
New Revision: 1438666

URL: http://svn.apache.org/viewvc?rev=1438666&view=rev
Log:
Fix Type --> type and BrokerName --> brokerName in RemoteJMXBrokerFacade + Test, related
to https://issues.apache.org/jira/browse/AMQ-4237

Added:
    activemq/trunk/activemq-web/src/test/
    activemq/trunk/activemq-web/src/test/java/
    activemq/trunk/activemq-web/src/test/java/org/
    activemq/trunk/activemq-web/src/test/java/org/apache/
    activemq/trunk/activemq-web/src/test/java/org/apache/activemq/
    activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/
    activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/RemoteJMXBrokerTest.java
Modified:
    activemq/trunk/activemq-web/pom.xml
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java

Modified: activemq/trunk/activemq-web/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/pom.xml?rev=1438666&r1=1438665&r2=1438666&view=diff
==============================================================================
--- activemq/trunk/activemq-web/pom.xml (original)
+++ activemq/trunk/activemq-web/pom.xml Fri Jan 25 19:50:15 2013
@@ -121,5 +121,10 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+      <dependency>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+          <scope>test</scope>
+      </dependency>
   </dependencies>
 </project>
\ No newline at end of file

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java?rev=1438666&r1=1438665&r2=1438666&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java
(original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/RemoteJMXBrokerFacade.java
Fri Jan 25 19:50:15 2013
@@ -197,10 +197,10 @@ public class RemoteJMXBrokerFacade exten
 			throws IOException, MalformedObjectNameException {
 		ObjectName name;
 		if (this.brokerName == null) {
-			name = new ObjectName("org.apache.activemq:Type=Broker,*");
+			name = new ObjectName("org.apache.activemq:type=Broker,*");
 		} else {
-			name = new ObjectName("org.apache.activemq:BrokerName="
-					+ this.brokerName + ",Type=Broker");
+			name = new ObjectName("org.apache.activemq:brokerName="
+					+ this.brokerName + ",Type=broker");
 		}
 
 		Set<ObjectName> brokers = connection.queryNames(name, null);

Added: activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/RemoteJMXBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/RemoteJMXBrokerTest.java?rev=1438666&view=auto
==============================================================================
--- activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/RemoteJMXBrokerTest.java
(added)
+++ activemq/trunk/activemq-web/src/test/java/org/apache/activemq/web/RemoteJMXBrokerTest.java
Fri Jan 25 19:50:15 2013
@@ -0,0 +1,85 @@
+/**
+ * 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.web;
+
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.jmx.ManagementContext;
+import org.apache.activemq.web.config.SystemPropertiesConfiguration;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnectorServer;
+import java.lang.reflect.Field;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author <a href="http://www.christianposta.com/blog">Christian Posta</a>
+ *
+ * You can use this class to connect up to a running web console and run some queries.
+ * Used to work through https://issues.apache.org/jira/browse/AMQ-4272 but would be useful
+ * in any scenario where you need access to the underlying broker in the web-console to hack
+ * at it
+ *
+ */
+public class RemoteJMXBrokerTest {
+
+
+    private BrokerService brokerService;
+
+    @Before
+    public void startUp() throws Exception {
+        brokerService = BrokerFactory.createBroker("broker:()/remoteBroker?useJmx=true");
+        brokerService.start();
+        brokerService.waitUntilStarted();
+
+    }
+
+    /**
+     * Test that we can query the remote broker...
+     * Specifically this tests that the domain and objectnames are correct (type and brokerName
+     * instead of Type and BrokerName, which they were)
+     * @throws Exception
+     */
+    @Test
+    public void testConnectRemoteBrokerFacade() throws Exception {
+        String jmxUri = getJmxUri();
+        System.setProperty("webconsole.jmx.url", jmxUri);
+        RemoteJMXBrokerFacade brokerFacade = new RemoteJMXBrokerFacade();
+
+        SystemPropertiesConfiguration configuration = new SystemPropertiesConfiguration();
+        brokerFacade.setConfiguration(configuration);
+
+        ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=remoteBroker");
+        Set<ObjectName> queryResult = brokerFacade.queryNames(query, null);
+
+        System.out.println("Number: "  + queryResult.size());
+        assertEquals(1, queryResult.size());
+
+    }
+
+
+    public String  getJmxUri() throws NoSuchFieldException, IllegalAccessException {
+        Field field = ManagementContext.class.getDeclaredField("connectorServer");
+        field.setAccessible(true);
+        JMXConnectorServer server = (JMXConnectorServer) field.get(brokerService.getManagementContext());
+        return server.getAddress().toString();
+    }
+}



Mime
View raw message