db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r631734 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management: JMXConnectionDecorator.java JMXTest.java MBeanTest.java ManagementMBeanTest.java PlatformConnectionGetter.java VersionMBeanTest.java
Date Wed, 27 Feb 2008 21:34:52 GMT
Author: djd
Date: Wed Feb 27 13:34:48 2008
New Revision: 631734

URL: http://svn.apache.org/viewvc?rev=631734&view=rev
Log:
DERBY-3385 Add framework for running the MBean tests using the platform MBeanServer but don't
enable those tests yet. Error occurs when the tests are run standalone due to Derby not running.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionDecorator.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
    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/ManagementMBeanTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/VersionMBeanTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionDecorator.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionDecorator.java?rev=631734&r1=631733&r2=631734&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionDecorator.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXConnectionDecorator.java
Wed Feb 27 13:34:48 2008
@@ -45,6 +45,15 @@
         return new JMXConnectionDecorator(test, true);
     }
     
+    /**
+     * Decorate a test to use JMX connections directly from the platform
+     * MBean Server.
+     */
+    static Test platformMBeanServer(Test test)
+    {
+        return new JMXConnectionDecorator(test, false);
+    }
+    
     // ignored for now
     private final boolean remote;
     private JMXConnectionGetter oldGetter;
@@ -59,8 +68,12 @@
         super.setUp();
         oldGetter =
             JMXConnectionGetter.mbeanServerConnector.get();
-        JMXConnectionGetter.mbeanServerConnector.set(
-                new RemoteConnectionGetter( getJmxUrl()));
+        
+        JMXConnectionGetter getter = remote ?
+                new RemoteConnectionGetter(getJmxUrl()) :
+                new PlatformConnectionGetter();
+                
+        JMXConnectionGetter.mbeanServerConnector.set(getter);
     }
     
     @Override

Modified: 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=631734&r1=631733&r2=631734&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/JMXTest.java
Wed Feb 27 13:34:48 2008
@@ -43,7 +43,7 @@
     public static Test suite() {
         
         return MBeanTest.suite(JMXTest.class, 
-                                        "JMXTest:client");
+                                        "JMXTest");
     }
     
     /**

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=631734&r1=631733&r2=631734&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
Wed Feb 27 13:34:48 2008
@@ -21,28 +21,17 @@
 
 package org.apache.derbyTesting.functionTests.tests.management;
 
-import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Set;
 
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-import javax.management.MBeanException;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.BaseTestCase;
-import org.apache.derbyTesting.junit.BaseTestSetup;
 import org.apache.derbyTesting.junit.NetworkServerTestSetup;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
@@ -63,8 +52,19 @@
         // Check for J2SE 5.0 or better? Or java.lang.management.ManagementFactory?
         // Older VMs will get UnsupportedClassVersionError anyway...
         
+        TestSuite outerSuite = new TestSuite(suiteName);
+        
+        // TODO: Run with no security for the moment, requires changes in the
+        // test policy files that may clash with a couple of outstanding patches.
+        Test platform = SecurityManagerSetup.noSecurityManager(
+                new TestSuite(testClass,  suiteName + ":platform"))
+                ;
+        platform = JMXConnectionDecorator.platformMBeanServer(platform);
+        // TODO: Disabled - failing at the moment when Derby has not been started.
+        //outerSuite.addTest(platform);
+        
         // Create a suite of all "test..." methods in the class.
-        Test suite = new TestSuite(testClass,  suiteName);
+        Test suite = new TestSuite(testClass,  suiteName + ":client");
         
         // Set up to get JMX connections using remote JMX
         suite = JMXConnectionDecorator.remoteNoSecurity(suite);
@@ -102,7 +102,9 @@
                 SecurityManagerSetup.noSecurityManager(networkServerTestSetup);
         // this decorator makes sure the suite is empty if this configration
         // does not support the network server:
-        return TestConfiguration.defaultServerDecorator(testSetup);
+        outerSuite.addTest(TestConfiguration.defaultServerDecorator(testSetup));
+        
+        return outerSuite;
     }
     
     // ---------- UTILITY METHODS ------------
@@ -201,7 +203,6 @@
      * Get the ObjectName for the application
      * created ManagementMBean. The MBean will be
      * created if it is not already registered.
-     * @return
      * @throws Exception
      */
     protected ObjectName getApplicationManagementMBean() throws Exception

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=631734&r1=631733&r2=631734&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
Wed Feb 27 13:34:48 2008
@@ -42,7 +42,7 @@
     public static Test suite() {
         
         return MBeanTest.suite(ManagementMBeanTest.class, 
-                                        "ManagementMBeanTest:client");
+                                        "ManagementMBeanTest");
     }
     
     /**

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java?rev=631734&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/PlatformConnectionGetter.java
Wed Feb 27 13:34:48 2008
@@ -0,0 +1,49 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.management.RemoteConnectionGetter
+
+ 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.lang.management.ManagementFactory;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+/**
+ * JMXConnectionGetter using the platform MBean server.
+ *
+ */
+class PlatformConnectionGetter implements JMXConnectionGetter {
+
+    PlatformConnectionGetter() {
+    }
+
+    public MBeanServerConnection getMBeanServerConnection() throws Exception {
+        
+        return AccessController.doPrivileged(new PrivilegedAction<MBeanServerConnection>()
{
+
+            public MBeanServerConnection run() {
+                return ManagementFactory.getPlatformMBeanServer(); 
+            }});     
+    }
+}

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/VersionMBeanTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/VersionMBeanTest.java?rev=631734&r1=631733&r2=631734&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/VersionMBeanTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/management/VersionMBeanTest.java
Wed Feb 27 13:34:48 2008
@@ -59,7 +59,7 @@
     public static Test suite() {
         
         return MBeanTest.suite(VersionMBeanTest.class, 
-                                        "VersionMBeanTest:client");
+                                        "VersionMBeanTest");
     }
     
     /**



Mime
View raw message