db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r631440 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management: JMXTest.java MBeanTest.java _Suite.java
Date Wed, 27 Feb 2008 00:40:22 GMT
Author: djd
Date: Tue Feb 26 16:40:20 2008
New Revision: 631440

URL: http://svn.apache.org/viewvc?rev=631440&view=rev
Log:
DERBY-3385 Add a higher level JMX test class that will contain fixtures that test the whole
of Derby's JMX system rather than specific MBeans.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/_Suite.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java?rev=631440&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
Tue Feb 26 16:40:20 2008
@@ -0,0 +1,84 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.management.JMXTest
+
+   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.derbyTesting.functionTests.tests.management;
+
+import java.util.Set;
+
+import javax.management.MBeanInfo;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import junit.framework.Test;
+
+
+/**
+ * Tests against the general JMX management provided by Derby
+ * instead of tests against a specific MBean,
+ */
+public class JMXTest extends MBeanTest {
+    
+    public JMXTest(String name) {
+        super(name);
+    }
+    
+    public static Test suite() {
+        
+        return MBeanTest.suite(JMXTest.class, 
+                                        "JMXTest:client");
+    }
+    
+    /**
+     * Test that all MBeans registered by Derby have:
+     * <UL>
+     * <LI> A type key property correct set.
+     * <LI> Expose a class name in org.apache.derby.mbeans.
+     * </UL>
+     * @throws Exception
+     */
+    public void testDerbyRegisteredMBeansSimpleInfo() throws Exception
+    {        
+        Set<ObjectName> derbyMBeans = getDerbyDomainMBeans();
+        
+        MBeanServerConnection jmx = getMBeanServerConnection();
+        for (ObjectName name : derbyMBeans)
+        {
+            String type = name.getKeyProperty("type");
+            // Every Derby MBean has a type.
+            assertNotNull(type);
+            
+            MBeanInfo mbeanInfo = jmx.getMBeanInfo(name);
+            
+            String mbeanClassName = mbeanInfo.getClassName();
+            // Is the class name in the public api
+            assertTrue(mbeanClassName.startsWith("org.apache.derby.mbeans."));
+            
+            // and is a Derby specific MBean.
+            assertTrue(mbeanClassName.endsWith("MBean"));
+            
+            // Check the type is the class name of the MBean without
+            // the MBean and the package.
+            String scn = mbeanClassName.substring(mbeanClassName.lastIndexOf('.') + 1); 
       
+            scn = scn.substring(0, scn.length() - "MBean".length());
+            assertEquals(scn, type);
+        }
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java?rev=631440&r1=631439&r2=631440&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/MBeanTest.java
Tue Feb 26 16:40:20 2008
@@ -25,6 +25,7 @@
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
+import java.util.Set;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
@@ -209,6 +210,18 @@
         }
         
         assertTrue("Failed to activate Derby's JMX management", active);
+    }
+    
+    /**
+     * Get all MBeans registered in Derby's domain.
+     * @return Set of ObjectNames for all of Derby's registered MBeans.
+     * @throws Exception
+     */
+    protected Set<ObjectName> getDerbyDomainMBeans() throws Exception
+    {
+        ObjectName derbyDomain = new ObjectName("org.apache.derby:*");
+        return  (Set<ObjectName>)
+            getMBeanServerConnection().queryNames(derbyDomain, null);
     }
     
     /**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/_Suite.java?rev=631440&r1=631439&r2=631440&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/_Suite.java
Tue Feb 26 16:40:20 2008
@@ -51,6 +51,7 @@
 
         TestSuite suite = new TestSuite("management");
 
+        suite.addTest(JMXTest.suite());
         suite.addTest(ManagementMBeanTest.suite());
         suite.addTest(VersionMBeanTest.suite());
         



Mime
View raw message