summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-02-15 11:26:56 +0000
committerBhupendra Bhusman Bhardwaj <bhupendrab@apache.org>2007-02-15 11:26:56 +0000
commitbf21a0f95a143ae33aeb14896a9436f033546e7c (patch)
treee83de78e85c599c22f1f1ed9bcb81a74a9a5d618
parent2f400ad3fa8a76da1dbce8472e1269c985a50ede (diff)
downloadqpid-python-bf21a0f95a143ae33aeb14896a9436f033546e7c.tar.gz
QPID-369
Adding test-classes for java management console git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@507894 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/management/eclipse-plugin/pom.xml16
-rw-r--r--java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java114
2 files changed, 127 insertions, 3 deletions
diff --git a/java/management/eclipse-plugin/pom.xml b/java/management/eclipse-plugin/pom.xml
index f58520ab64..c61adde877 100644
--- a/java/management/eclipse-plugin/pom.xml
+++ b/java/management/eclipse-plugin/pom.xml
@@ -167,6 +167,16 @@
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>qpid-broker</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -209,9 +219,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
</plugin>
</plugins>
</build>
diff --git a/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java b/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java
new file mode 100644
index 0000000000..6b0394f1a6
--- /dev/null
+++ b/java/management/eclipse-plugin/src/test/java/org/apache/qpid/management/ui/ManagementConsoleTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.qpid.management.ui;
+
+import junit.framework.TestCase;
+import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.exchange.DestNameExchange;
+import org.apache.qpid.server.management.AMQManagedObject;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQQueueMBean;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+
+import javax.management.MBeanFeatureInfo;
+import javax.management.MBeanInfo;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Test class to test if any change in the broker JMX code is affesting the management console
+ * There are some hardcoding of management feature names and parameter names to create a customized
+ * look in the console.
+ */
+public class ManagementConsoleTest extends TestCase
+{
+ private VirtualHost _virtualHost;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ IApplicationRegistry applicationRegistry = ApplicationRegistry.getInstance();
+ _virtualHost = applicationRegistry.getVirtualHostRegistry().getVirtualHost("test");
+ }
+
+ /**
+ * Test for AMQQueueMBean attribute and operation names, which are used in the management console
+ * @throws Exception
+ */
+ public void testAMQQueueMBeanInfo() throws Exception
+ {
+ // If this test fails due to changes in the broker code,
+ // then the constants in the Constants.java shoule be updated accordingly
+ AMQQueue queue = new AMQQueue(new AMQShortString("testQueueForManagement"), false, null, false, _virtualHost);
+ AMQManagedObject mbean = new AMQQueueMBean(queue);
+ MBeanInfo mbeanInfo = mbean.getMBeanInfo();
+
+ List<String> operationNames = getNamesList(mbeanInfo.getOperations());
+ assertTrue(operationNames.contains(Constants.OPERATION_MOVE_MESSAGES));
+
+ List<String> attributesList = getNamesList(mbeanInfo.getAttributes());
+ assertTrue(attributesList.contains(Constants.ATTRIBUTE_QUEUE_CONSUMERCOUNT));
+ assertTrue(attributesList.contains(Constants.ATTRIBUTE_QUEUE_DEPTH));
+ }
+
+ /**
+ * Test for Exchange MBean attribute and operation names, which are used in the management console
+ * @throws Exception
+ */
+ public void testExchangeMBeanInfo() throws Exception
+ {
+ // If this test fails due to changes in the broker code,
+ // then the constants in the Constants.java shoule be updated accordingly
+ DestNameExchange exchange = new DestNameExchange();
+ exchange.initialise(_virtualHost, ExchangeDefaults.DIRECT_EXCHANGE_NAME, false, 0, true);
+ AMQManagedObject mbean = (AMQManagedObject)exchange.getManagedObject();
+ MBeanInfo mbeanInfo = mbean.getMBeanInfo();
+
+ // Check for the Exchange Type property in the ObjectName
+ assertNotNull(mbean.getObjectName().getKeyProperty(Constants.EXCHANGE_TYPE));
+
+ // Check for operation names
+ List<String> operationNames = getNamesList(mbeanInfo.getOperations());
+ assertTrue(operationNames.contains(Constants.OPERATION_CREATE_BINDING));
+ }
+
+ /**
+ * Test for VirtualHostManagerMBean features used in Management console for customizing the GUI
+ * @throws Exception
+ */
+ public void testVirtualHostManagerMBeanInfo() throws Exception
+ {
+ AMQManagedObject mbean = (AMQManagedObject)_virtualHost.getManagedObject();
+ assertTrue(mbean.getType().equals(Constants.VIRTUAL_HOST));
+ }
+
+ private List<String> getNamesList(MBeanFeatureInfo[] features)
+ {
+ List<String> names = new ArrayList<String>();
+ for (MBeanFeatureInfo feature : features)
+ {
+ names.add(feature.getName());
+ }
+
+ return names;
+ }
+}