db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r631448 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/ManagementMBeanTest.java
Date Wed, 27 Feb 2008 01:04:55 GMT
Author: djd
Date: Tue Feb 26 17:04:48 2008
New Revision: 631448

URL: http://svn.apache.org/viewvc?rev=631448&view=rev
Log:
DERBY-3385 Add testing to ManagementMBean to ensure Derby's MBeans register and unregister
when management is started and stopped

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/ManagementMBeanTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/ManagementMBeanTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/ManagementMBeanTest.java?rev=631448&r1=631447&r2=631448&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/ManagementMBeanTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/ManagementMBeanTest.java
Tue Feb 26 17:04:48 2008
@@ -21,6 +21,8 @@
 
 package org.apache.derbyTesting.functionTests.tests.management;
 
+import java.util.Set;
+
 import javax.management.ObjectName;
 
 import junit.framework.Test;
@@ -43,6 +45,10 @@
                                         "ManagementMBeanTest:client");
     }
     
+    /**
+     * Test that the MBean created by the application can
+     * successfully start and stop Derby's JMX management.
+     */
     public void testStartStopManagementFromApplication()
         throws Exception
     {
@@ -50,22 +56,40 @@
         startStopManagement(appMgmtBean);
     }
     
+    /**
+     * Test that the MBean with the passed in name can
+     * successfully start and stop Derby's JMX management.
+     */
     private void startStopManagement(ObjectName mbean) throws Exception
     {
         // Test fixtures start off active
         assertBooleanAttribute(true, mbean, "ManagementActive");
         
+        int derbyMbeanCount = getDerbyDomainMBeans().size();
+        assertTrue(derbyMbeanCount > 0);
+        
         // Should be a no-op
         invokeOperation(mbean, "startManagement");
         assertBooleanAttribute(true, mbean, "ManagementActive");
         
+        // so should have the same number of MBeans registered
+        assertEquals(derbyMbeanCount, getDerbyDomainMBeans().size());
+        
         // now stop management
         invokeOperation(mbean, "stopManagement");
         assertBooleanAttribute(false, mbean, "ManagementActive");
         
-        // now start management again
+        // leaving only management MBeans.
+        Set<ObjectName> managementOnly = getDerbyDomainMBeans();
+        assertEquals(1, managementOnly.size());
+        for (ObjectName name : managementOnly)
+        {
+            assertEquals("Management", name.getKeyProperty("type"));
+        }
+        
+        // now start management again and have the same MBeans.
         invokeOperation(mbean, "startManagement");
         assertBooleanAttribute(true, mbean, "ManagementActive");
-
+        assertEquals(derbyMbeanCount, getDerbyDomainMBeans().size());
     }
 }



Mime
View raw message