6746754: jmx namespace: test for leading separator missing
authordfuchs
Wed, 10 Sep 2008 16:27:13 +0200
changeset 1227 4546977d0d66
parent 1226 eba24d3b9c0c
child 1228 1515928f48cd
6746754: jmx namespace: test for leading separator missing 6669137: RFE: InstanceNotFoundException should have a constructor that takes an ObjectName 6746796: jmx namespaces: Several tests are missing an @bug or @run keyword Summary: Note on 6669137: first implementation of 6669137 was actually pushed with 5072476 - here we only have a small update and a test case. Also re-fixes 6737133: Compilation failure of test/javax/management/eventService/LeaseManagerDeadlockTest.java which had failed. Reviewed-by: emcmanus, yjoan
jdk/src/share/classes/com/sun/jmx/namespace/RoutingProxy.java
jdk/src/share/classes/javax/management/InstanceNotFoundException.java
jdk/test/javax/management/MBeanServer/InstanceNotFoundExceptionTest.java
jdk/test/javax/management/MBeanServerFactory/NamedMBeanServerTest.java
jdk/test/javax/management/eventService/LeaseManagerDeadlockTest.java
jdk/test/javax/management/namespace/DomainCreationTest.java
jdk/test/javax/management/namespace/EventWithNamespaceControlTest.java
jdk/test/javax/management/namespace/EventWithNamespaceTest.java
jdk/test/javax/management/namespace/ExportNamespaceTest.java
jdk/test/javax/management/namespace/JMXDomainTest.java
jdk/test/javax/management/namespace/JMXNamespaceSecurityTest.java
jdk/test/javax/management/namespace/JMXNamespaceTest.java
jdk/test/javax/management/namespace/JMXNamespaceViewTest.java
jdk/test/javax/management/namespace/JMXNamespacesTest.java
jdk/test/javax/management/namespace/JMXRemoteNamespaceTest.java
jdk/test/javax/management/namespace/LazyDomainTest.java
jdk/test/javax/management/namespace/LeadingSeparatorsTest.java
jdk/test/javax/management/namespace/NamespaceCreationTest.java
jdk/test/javax/management/namespace/NamespaceNotificationsTest.java
jdk/test/javax/management/namespace/NullObjectNameTest.java
jdk/test/javax/management/namespace/QueryNamesTest.java
jdk/test/javax/management/namespace/RemoveNotificationListenerTest.java
jdk/test/javax/management/namespace/RoutingServerProxyTest.java
jdk/test/javax/management/namespace/SerialParamProcessorTest.java
jdk/test/javax/management/namespace/SourceNamespaceTest.java
jdk/test/javax/management/namespace/VirtualMBeanNotifTest.java
jdk/test/javax/management/namespace/VirtualMBeanTest.java
jdk/test/javax/management/namespace/VirtualNamespaceQueryTest.java
jdk/test/javax/management/namespace/VirtualPropsTest.java
--- a/jdk/src/share/classes/com/sun/jmx/namespace/RoutingProxy.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/src/share/classes/com/sun/jmx/namespace/RoutingProxy.java	Wed Sep 10 16:27:13 2008 +0200
@@ -48,6 +48,19 @@
  * <p>{@link RoutingConnectionProxy}: to narrow down into an
  *    MBeanServerConnection.</p>
  * <p>{@link RoutingServerProxy}: to narrow down into an MBeanServer.</p>
+ *
+ * <p>This class can also be used to "broaden" from a namespace.  The same
+ * class is used for both purposes because in both cases all that happens
+ * is that ObjectNames are rewritten in one way on the way in (e.g. the
+ * parameter of getMBeanInfo) and another way on the way out (e.g. the
+ * return value of queryNames).</p>
+ *
+ * <p>Specifically, if you narrow into "a//" then you want to add the
+ * "a//" prefix to ObjectNames on the way in and subtract it on the way
+ * out.  But ClientContext uses this class to subtract the
+ * "jmx.context//foo=bar//" prefix on the way in and add it back on the
+ * way out.</p>
+ *
  * <p><b>
  * This API is a Sun internal API and is subject to changes without notice.
  * </b></p>
@@ -245,8 +258,8 @@
              throw x;
          } catch (MBeanException ex) {
              throw new IOException("Failed to get "+attributeName+": "+
-                     ex,
-                     ex.getTargetException());
+                     ex.getCause(),
+                     ex.getCause());
          } catch (Exception ex) {
              throw new IOException("Failed to get "+attributeName+": "+
                      ex,ex);
--- a/jdk/src/share/classes/javax/management/InstanceNotFoundException.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/src/share/classes/javax/management/InstanceNotFoundException.java	Wed Sep 10 16:27:13 2008 +0200
@@ -61,6 +61,6 @@
      * @since 1.7
      */
     public InstanceNotFoundException(ObjectName name) {
-        this(name.toString());
+        this(String.valueOf(name));
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/MBeanServer/InstanceNotFoundExceptionTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6669137
+ * @summary Test the constructors of InstanceNotFoundExceptionTest.
+ * @author Daniel Fuchs
+ * @compile InstanceNotFoundExceptionTest.java
+ * @run main InstanceNotFoundExceptionTest
+ */
+
+import javax.management.InstanceNotFoundException;
+import javax.management.ObjectName;
+
+public class InstanceNotFoundExceptionTest {
+    public static void main(String[] args) throws Exception {
+        final InstanceNotFoundException x =
+                new InstanceNotFoundException();
+        System.out.println("InstanceNotFoundException(): "+x.getMessage());
+
+        final String msg = "who is toto?";
+        final InstanceNotFoundException x2 =
+                new InstanceNotFoundException(msg);
+        if (!msg.equals(x2.getMessage()))
+            throw new Exception("Bad message: expected "+msg+
+                    ", got "+x2.getMessage());
+        System.out.println("InstanceNotFoundException(" +
+                msg+"): "+x2.getMessage());
+
+        final InstanceNotFoundException x3 =
+                new InstanceNotFoundException((String)null);
+        if (x3.getMessage() != null)
+            throw new Exception("Bad message: expected "+null+
+                    ", got "+x3.getMessage());
+        System.out.println("InstanceNotFoundException((String)null): "+
+                x3.getMessage());
+
+        final ObjectName n = new ObjectName("who is toto?:type=msg");
+        final InstanceNotFoundException x4 =
+                new InstanceNotFoundException(n);
+        if (!String.valueOf(n).equals(x4.getMessage()))
+            throw new Exception("Bad message: expected "+n+
+                    ", got "+x4.getMessage());
+        System.out.println("InstanceNotFoundException(" +
+                n+"): "+x4.getMessage());
+
+        final InstanceNotFoundException x5 =
+                new InstanceNotFoundException((ObjectName)null);
+        if (!String.valueOf((ObjectName)null).equals(x5.getMessage()))
+            throw new Exception("Bad message: expected " +
+                    String.valueOf((ObjectName)null)+" got "+x5.getMessage());
+        System.out.println("InstanceNotFoundException((ObjectName)null): "+
+                x5.getMessage());
+    }
+}
--- a/jdk/test/javax/management/MBeanServerFactory/NamedMBeanServerTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/MBeanServerFactory/NamedMBeanServerTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  * @test
  * @summary Test named MBeanServers.
  * @author Daniel Fuchs
+ * @bug 6299231
  * @run clean NamedMBeanServerTest
  * @run build NamedMBeanServerTest
  * @run main NamedMBeanServerTest
--- a/jdk/test/javax/management/eventService/LeaseManagerDeadlockTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/eventService/LeaseManagerDeadlockTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -27,6 +27,7 @@
  * @summary Check that a lock is not held when a LeaseManager expires.
  * @author Eamonn McManus
  * @compile -XDignore.symbol.file=true LeaseManagerDeadlockTest.java
+ * @run main LeaseManagerDeadlockTest
  */
 
 import com.sun.jmx.event.LeaseManager;
--- a/jdk/test/javax/management/namespace/DomainCreationTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/DomainCreationTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -23,6 +23,7 @@
 /*
  *
  * @test DomainCreationTest.java
+ * @bug 5072476
  * @summary Test the creation and registration of JMXDomain instances.
  * @author Daniel Fuchs
  * @run clean DomainCreationTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/EventWithNamespaceControlTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/EventWithNamespaceControlTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -27,6 +27,7 @@
  * @summary Check -Djmx.remote.use.event.service=true and
  *                -Djmx.remote.delegate.event.service
  * @author Daniel Fuchs
+ * @bug 5072476 5108776
  * @run clean EventWithNamespaceTest EventWithNamespaceControlTest
  *            Wombat WombatMBean JMXRemoteTargetNamespace
  *            NamespaceController NamespaceControllerMBean
--- a/jdk/test/javax/management/namespace/EventWithNamespaceTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/EventWithNamespaceTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -24,7 +24,7 @@
 /*
  *
  * @test EventWithNamespaceTest.java 1.8
- * @bug 6539857
+ * @bug 6539857 5072476 5108776
  * @summary General Namespace & Notifications test.
  * @author Daniel Fuchs
  * @run clean EventWithNamespaceTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/ExportNamespaceTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/ExportNamespaceTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -26,6 +26,7 @@
  * @summary Test that you can export a single namespace through a
  *          JMXConnectorServer.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean ExportNamespaceTest Wombat WombatMBean
  * @run build ExportNamespaceTest Wombat WombatMBean
  * @run main ExportNamespaceTest
--- a/jdk/test/javax/management/namespace/JMXDomainTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/JMXDomainTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -23,6 +23,7 @@
 /*
  *
  * @test JMXDomainTest.java
+ * @bug 5072476
  * @summary Basic test for JMXDomain.
  * @author Daniel Fuchs
  * @run clean JMXDomainTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/JMXNamespaceSecurityTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/JMXNamespaceSecurityTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -26,6 +26,7 @@
  * @test JMXNamespaceSecurityTest.java
  * @summary General JMXNamespaceSecurityTest test.
  * @author Daniel Fuchs
+ * @bug 5072476 6299231
  * @run clean JMXNamespaceViewTest JMXNamespaceSecurityTest Wombat WombatMBean
  *            LazyDomainTest
  * @run build JMXNamespaceSecurityTest JMXNamespaceViewTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/JMXNamespaceTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/JMXNamespaceTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  *
  * @test JMXNamespaceTest.java
  * @summary General JMXNamespace test.
+ * @bug 5072476
  * @author Daniel Fuchs
  * @run clean JMXNamespaceTest
  *            Wombat WombatMBean JMXRemoteTargetNamespace
--- a/jdk/test/javax/management/namespace/JMXNamespaceViewTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/JMXNamespaceViewTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -24,6 +24,7 @@
  *
  * @test JMXNamespaceViewTest.java
  * @summary Test the JMXNamespaceView class.
+ * @bug 5072476
  * @author Daniel Fuchs
  * @run clean JMXNamespaceViewTest Wombat WombatMBean
  * @run build JMXNamespaceViewTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/JMXNamespacesTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/JMXNamespacesTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -24,6 +24,7 @@
  * @test JMXNamespacesTest.java
  * @summary Test the static method that rewrite ObjectNames in JMXNamespacesTest
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean JMXNamespacesTest
  * @compile -XDignore.symbol.file=true JMXNamespacesTest.java
  * @run main JMXNamespacesTest
--- a/jdk/test/javax/management/namespace/JMXRemoteNamespaceTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/JMXRemoteNamespaceTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  * @test JMXRemoteNamespaceTest.java
  * @summary Basic tests on a JMXRemoteNamespace.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean JMXRemoteNamespaceTest Wombat WombatMBean
  * @run build JMXRemoteNamespaceTest Wombat WombatMBean
  * @run main JMXRemoteNamespaceTest
--- a/jdk/test/javax/management/namespace/LazyDomainTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/LazyDomainTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -23,6 +23,7 @@
 /*
  *
  * @test LazyDomainTest.java
+ * @bug 5072476
  * @summary Basic test for Lazy Domains.
  * @author Daniel Fuchs
  * @run clean LazyDomainTest Wombat WombatMBean
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/namespace/LeadingSeparatorsTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test LeadingSeparatorsTest.java
+ * @summary Test that the semantics of a leading // in ObjectName is respected.
+ * @author Daniel Fuchs
+ * @bug 5072476
+ * @run clean LeadingSeparatorsTest Wombat WombatMBean
+ * @compile -XDignore.symbol.file=true  LeadingSeparatorsTest.java
+ * @run build LeadingSeparatorsTest Wombat WombatMBean
+ * @run main LeadingSeparatorsTest
+ */
+
+import java.lang.management.ManagementFactory;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.logging.Logger;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.namespace.JMXNamespaces;
+import javax.management.namespace.JMXRemoteNamespace;
+import javax.management.namespace.JMXNamespace;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+
+/**
+ * Class LeadingSeparatorsTest
+ * @author Sun Microsystems, 2005 - All rights reserved.
+ */
+public class LeadingSeparatorsTest {
+
+    /**
+     * A logger for this class.
+     **/
+    private static final Logger LOG =
+            Logger.getLogger(LeadingSeparatorsTest.class.getName());
+
+    /** Creates a new instance of NullObjectNameTest */
+    public LeadingSeparatorsTest() {
+    }
+
+    public static interface MyWombatMBean extends WombatMBean {
+        public Set<ObjectName> untrue(ObjectName pat) throws Exception;
+    }
+    public static class MyWombat
+            extends Wombat implements MyWombatMBean {
+        public MyWombat() throws NotCompliantMBeanException {
+            super(MyWombatMBean.class);
+        }
+
+        public Set<ObjectName> untrue(ObjectName pat) throws Exception {
+            final Set<ObjectName> res=listMatching(pat.withDomain("*"));
+            final Set<ObjectName> untrue = new HashSet<ObjectName>();
+            for (ObjectName a:res) {
+                untrue.add(a.withDomain(pat.getDomain()+"//"+a.getDomain()));
+            }
+            return untrue;
+        }
+    }
+
+    static String failure=null;
+
+    public static void testRegister() throws Exception {
+        final MBeanServer top = ManagementFactory.getPlatformMBeanServer();
+        final MBeanServer sub = MBeanServerFactory.createMBeanServer();
+        final JMXServiceURL url = new JMXServiceURL("rmi",null,0);
+        final JMXConnectorServer srv =
+                JMXConnectorServerFactory.newJMXConnectorServer(url,null,sub);
+        srv.start();
+
+        try {
+
+            // Create a namespace rmi// that points to 'sub' and flows through
+            // a JMXRemoteNamespace connected to 'srv'
+            // The namespace rmi// will accept createMBean, but not registerMBean.
+            //
+            final JMXRemoteNamespace rmiHandler = JMXRemoteNamespace.
+                    newJMXRemoteNamespace(srv.getAddress(),null);
+            top.registerMBean(rmiHandler,
+                    JMXNamespaces.getNamespaceObjectName("rmi"));
+            top.invoke(JMXNamespaces.getNamespaceObjectName("rmi"),
+                    "connect", null, null);
+
+            // Create a namespace direct// that points to 'sub' and flows
+            // through a direct reference to 'sub'.
+            // The namespace direct// will accept createMBean, and registerMBean.
+            //
+            final JMXNamespace directHandler = new JMXNamespace(sub);
+            top.registerMBean(directHandler,
+                    JMXNamespaces.getNamespaceObjectName("direct"));
+
+            final ObjectName n1 = new ObjectName("//direct//w:type=Wombat");
+            final ObjectName n2 = new ObjectName("direct//w:type=Wombat");
+            final ObjectName n3 = new ObjectName("//rmi//w:type=Wombat");
+            final ObjectName n4 = new ObjectName("rmi//w:type=Wombat");
+
+            // register wombat using an object name with a leading //
+            final Object     obj = new MyWombat();
+            // check that returned object name doesn't have the leading //
+            assertEquals(n2,top.registerMBean(obj, n1).getObjectName());
+            System.out.println(n1+" registered");
+
+            // check that the registered Wombat can be accessed with all its
+            // names.
+            System.out.println(n2+" mood is: "+top.getAttribute(n2, "Mood"));
+            System.out.println(n1+" mood is: "+top.getAttribute(n1, "Mood"));
+            System.out.println(n4+" mood is: "+top.getAttribute(n4, "Mood"));
+            System.out.println(n3+" mood is: "+top.getAttribute(n3, "Mood"));
+
+            // call listMatching. The result should not contain any prefix.
+            final Set<ObjectName> res = (Set<ObjectName>)
+                    top.invoke(n3, "listMatching",
+                    // remove rmi// from rmi//*:*
+                    JMXNamespaces.deepReplaceHeadNamespace(
+                    new Object[] {ObjectName.WILDCARD.withDomain("rmi//*")},
+                    "rmi", ""), new String[] {ObjectName.class.getName()});
+
+            // add rmi// prefix to all names in res.
+            final Set<ObjectName> res1 =
+                   JMXNamespaces.deepReplaceHeadNamespace(res, "", "rmi");
+            System.out.println("got: "+res1);
+
+            // compute expected result
+            final Set<ObjectName> res2 = sub.queryNames(null,null);
+            final Set<ObjectName> res3 = new HashSet<ObjectName>();
+            for (ObjectName o:res2) {
+               res3.add(o.withDomain("rmi//"+o.getDomain()));
+            }
+            System.out.println("expected: "+res3);
+            assertEquals(res1, res3);
+
+            // invoke "untrue(//niark//niark:*)"
+            // should return a set were all ObjectNames begin with
+            // //niark//niark//
+            //
+            final Set<ObjectName> res4 = (Set<ObjectName>)
+                    top.invoke(n3, "untrue",
+                    // remove niark//niark : should remove nothing since
+                    // our ObjectName begins with a leading //
+                    JMXNamespaces.deepReplaceHeadNamespace(
+                    new Object[] {
+                       ObjectName.WILDCARD.withDomain("//niark//niark")},
+                    "niark//niark", ""),
+                    new String[] {ObjectName.class.getName()});
+            System.out.println("got: "+res4);
+
+            // add rmi// should add nothing since the returned names have a
+            // leading //
+            //
+            final Set<ObjectName> res5 =
+                   JMXNamespaces.deepReplaceHeadNamespace(res4, "", "rmi");
+            System.out.println("got#2: "+res5);
+
+            // compute expected result
+            final Set<ObjectName> res6 = new HashSet<ObjectName>();
+            for (ObjectName o:res2) {
+               res6.add(o.withDomain("//niark//niark//"+o.getDomain()));
+            }
+            System.out.println("expected: "+res6);
+
+            // both res4 and res5 should be equals to the expected result.
+            assertEquals(res4, res6);
+            assertEquals(res5, res6);
+
+        } finally {
+            srv.stop();
+        }
+
+        if (failure != null)
+            throw new Exception(failure);
+
+
+    }
+    private static void assertEquals(Object x, Object y) {
+        if (!equal(x, y))
+            failed("expected " + string(x) + "; got " + string(y));
+    }
+
+    private static boolean equal(Object x, Object y) {
+        if (x == y)
+            return true;
+        if (x == null || y == null)
+            return false;
+        if (x.getClass().isArray())
+            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
+        return x.equals(y);
+    }
+
+    private static String string(Object x) {
+        String s = Arrays.deepToString(new Object[] {x});
+        return s.substring(1, s.length() - 1);
+    }
+
+
+    private static void failed(String why) {
+        failure = why;
+        new Throwable("FAILED: " + why).printStackTrace(System.out);
+    }
+
+    public static void main(String[] args) throws Exception {
+        testRegister();
+    }
+}
--- a/jdk/test/javax/management/namespace/NamespaceCreationTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/NamespaceCreationTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  * @test NamespaceCreationTest.java
  * @summary General JMXNamespace test.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean NamespaceCreationTest Wombat WombatMBean
  * @run build NamespaceCreationTest Wombat WombatMBean
  * @run main NamespaceCreationTest
--- a/jdk/test/javax/management/namespace/NamespaceNotificationsTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/NamespaceNotificationsTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  *
  * @test NamespaceNotificationsTest.java 1.12
  * @summary General Namespace & Notifications test.
+ * @bug 5072476
  * @author Daniel Fuchs
  * @run clean NamespaceNotificationsTest
  *            Wombat WombatMBean JMXRemoteTargetNamespace
--- a/jdk/test/javax/management/namespace/NullObjectNameTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/NullObjectNameTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -24,6 +24,7 @@
  * @test NullObjectNameTest.java
  * @summary Test that null ObjectName are correctly handled in namespaces.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean NullObjectNameTest Wombat WombatMBean
  * @compile -XDignore.symbol.file=true  NullObjectNameTest.java
  * @run build NullObjectNameTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/QueryNamesTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/QueryNamesTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  * @test QueryNamesTest.java 1.4
  * @summary Test how queryNames works with Namespaces.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean QueryNamesTest Wombat WombatMBean
  * @run build QueryNamesTest Wombat WombatMBean
  * @run main QueryNamesTest
--- a/jdk/test/javax/management/namespace/RemoveNotificationListenerTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/RemoveNotificationListenerTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  * @test RemoveNotificationListenerTest.java 1.8
  * @summary General RemoveNotificationListenerTest test.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean RemoveNotificationListenerTest JMXRemoteTargetNamespace
  * @compile -XDignore.symbol.file=true  JMXRemoteTargetNamespace.java
  * @run build RemoveNotificationListenerTest JMXRemoteTargetNamespace
--- a/jdk/test/javax/management/namespace/RoutingServerProxyTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/RoutingServerProxyTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  * @test RoutingServerProxyTest.java 1.6
  * @summary General RoutingServerProxyTest test.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean RoutingServerProxyTest Wombat WombatMBean
  * @compile -XDignore.symbol.file=true RoutingServerProxyTest.java
  * @run build RoutingServerProxyTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/SerialParamProcessorTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/SerialParamProcessorTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -26,6 +26,7 @@
  * @test SerialParamProcessorTest.java 1.8
  * @summary General SerialParamProcessorTest test.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean SerialParamProcessorTest Wombat WombatMBean
  * @compile -XDignore.symbol.file=true  SerialParamProcessorTest.java
  * @run build SerialParamProcessorTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/SourceNamespaceTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/SourceNamespaceTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -24,6 +24,7 @@
  *
  * @test SourceNamespaceTest.java
  * @summary Test how queryNames works with Namespaces.
+ * @bug 5072476
  * @author Daniel Fuchs
  * @run clean SourceNamespaceTest Wombat WombatMBean
  * @run build SourceNamespaceTest Wombat WombatMBean
--- a/jdk/test/javax/management/namespace/VirtualMBeanNotifTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/VirtualMBeanNotifTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -25,6 +25,7 @@
  * @test VirtualMBeanNotifTest.java
  * @bug 5108776
  * @build VirtualMBeanNotifTest Wombat WombatMBean
+ * @run main VirtualMBeanNotifTest
  * @summary Test that Virtual MBeans can be implemented and emit notifs.
  * @author  Daniel Fuchs
  */
--- a/jdk/test/javax/management/namespace/VirtualMBeanTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/VirtualMBeanTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test VirtualMBeanTest.java
- * @bug 5108776
+ * @bug 5108776 5072476
  * @summary Test that Virtual MBeans can be implemented and emit notifs.
  * @author Eamonn McManus
  */
--- a/jdk/test/javax/management/namespace/VirtualNamespaceQueryTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/VirtualNamespaceQueryTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -26,6 +26,7 @@
  * @test VirtualNamespaceQueryTest.java
  * @summary General VirtualNamespaceQueryTest test.
  * @author Daniel Fuchs
+ * @bug 5072476
  * @run clean VirtualNamespaceQueryTest Wombat WombatMBean
  *            NamespaceController NamespaceControllerMBean
  *            JMXRemoteTargetNamespace
--- a/jdk/test/javax/management/namespace/VirtualPropsTest.java	Wed Sep 10 14:56:57 2008 +0200
+++ b/jdk/test/javax/management/namespace/VirtualPropsTest.java	Wed Sep 10 16:27:13 2008 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 5108776
+ * @bug 5108776 5072476
  * @summary Test the properties use case for Virtual MBeans that is documented
  * in MBeanServerSupport.
  * @author Eamonn McManus