jdk/test/javax/management/namespace/NullDomainObjectNameTest.java
changeset 1709 392dd6db361a
parent 1570 4165709c91e3
equal deleted inserted replaced
1708:4e1939e6e6b5 1709:392dd6db361a
    38 import javax.management.MBeanServer;
    38 import javax.management.MBeanServer;
    39 import javax.management.MBeanServerFactory;
    39 import javax.management.MBeanServerFactory;
    40 import javax.management.NotCompliantMBeanException;
    40 import javax.management.NotCompliantMBeanException;
    41 import javax.management.ObjectInstance;
    41 import javax.management.ObjectInstance;
    42 import javax.management.ObjectName;
    42 import javax.management.ObjectName;
       
    43 import javax.management.RuntimeOperationsException;
    43 import javax.management.namespace.JMXNamespaces;
    44 import javax.management.namespace.JMXNamespaces;
    44 import javax.management.namespace.JMXRemoteNamespace;
    45 import javax.management.namespace.JMXRemoteNamespace;
    45 import javax.management.namespace.JMXNamespace;
    46 import javax.management.namespace.JMXNamespace;
    46 import javax.management.remote.JMXConnectorServer;
    47 import javax.management.remote.JMXConnectorServer;
    47 import javax.management.remote.JMXConnectorServerFactory;
    48 import javax.management.remote.JMXConnectorServerFactory;
   213                 System.out.println("Checking queryNames(" +
   214                 System.out.println("Checking queryNames(" +
   214                     "new ObjectName(\":*\"),null) with faked//");
   215                     "new ObjectName(\":*\"),null) with faked//");
   215                 assertEquals(proxy.queryNames(
   216                 assertEquals(proxy.queryNames(
   216                         new ObjectName(":*"),null).
   217                         new ObjectName(":*"),null).
   217                         contains(moi3.getObjectName()),true);
   218                         contains(moi3.getObjectName()),true);
   218                 failed("queryNames(null,null) should have failed for faked//");
   219                 failed("queryNames(new ObjectName(\":*\"),null) " +
   219             } catch (IllegalArgumentException x) {
   220                         "should have failed for faked//");
   220                 System.out.println("Received expected exception for faked//: "+x);
   221             } catch (RuntimeOperationsException x) {
       
   222                 if (x.getCause() instanceof IllegalArgumentException)
       
   223                     System.out.println(
       
   224                             "Received expected exception for faked//: "+x);
       
   225                 else {
       
   226                     System.err.println(
       
   227                             "Expected exception has unexpected cause " +
       
   228                             "for faked//: "+x.getCause());
       
   229                     x.printStackTrace();
       
   230                     failed("queryNames(new ObjectName(\":*\"),null)" +
       
   231                             " failed with unexpected cause for faked//");
       
   232                 }
   221             }
   233             }
   222             // These should fail because the ObjectName doesn't start
   234             // These should fail because the ObjectName doesn't start
   223             // with "faked//"
   235             // with "faked//"
   224             try {
   236             try {
   225                 System.out.println("Checking queryMBeans(" +
   237                 System.out.println("Checking queryMBeans(" +
   226                     "new ObjectName(\":*\"),null) with faked//");
   238                     "new ObjectName(\":*\"),null) with faked//");
   227                 assertEquals(proxy.queryMBeans(
   239                 assertEquals(proxy.queryMBeans(
   228                         new ObjectName(":*"),null).contains(moi3),true);
   240                         new ObjectName(":*"),null).contains(moi3),true);
   229                 failed("queryMBeans(null,null) should have failed for faked//");
   241                 failed("queryMBeans(new ObjectName(\":*\"),null)" +
   230             } catch (IllegalArgumentException x) {
   242                     " should have failed for faked//");
   231                 System.out.println("Received expected exception for faked//: "+x);
   243             } catch (RuntimeOperationsException x) {
       
   244                 if (x.getCause() instanceof IllegalArgumentException)
       
   245                     System.out.println(
       
   246                             "Received expected exception for faked//: "+x);
       
   247                 else {
       
   248                     System.err.println(
       
   249                             "Expected exception has unexpected cause " +
       
   250                             "for faked//: "+x.getCause());
       
   251                     x.printStackTrace();
       
   252                     failed("queryMBeans(new ObjectName(\":*\"),null) " +
       
   253                             "failed with unexpected cause for faked//");
       
   254                 }
   232             }
   255             }
   233 
   256 
   234             System.out.println("Checking queryNames(faked//*:*,null)");
   257             System.out.println("Checking queryNames(faked//*:*,null)");
   235             assertEquals(proxy.queryNames(new ObjectName("faked//*:*"),null).
   258             assertEquals(proxy.queryNames(new ObjectName("faked//*:*"),null).
   236                     contains(moi3.getObjectName()),true);
   259                     contains(moi3.getObjectName()),true);