/* Check that all descriptors have been returned */ private static void checkDescriptors( ModelMBeanInfo modelMBeanInfo, Descriptor[] descriptors, String string) { int errCount = 0; final ArrayList<Descriptor> list = new ArrayList<Descriptor>(descriptors.length); list.addAll(Arrays.asList(descriptors)); System.out.println("Got " + list.size() + " descriptors for " + string); // checks that MBean's descriptor is returned. // final Descriptor mbd = ((MBeanInfo) modelMBeanInfo).getDescriptor(); if (!mbd.equals(remove(list, mbd))) { System.err.println("modelMBeanInfo.getDescriptor(): not found"); errCount++; } // checks that MBean's attributes descriptors are returned. // final MBeanAttributeInfo[] attrs = modelMBeanInfo.getAttributes(); for (MBeanAttributeInfo att : attrs) { final Descriptor ad = att.getDescriptor(); final String name = att.getName(); if (!ad.equals(remove(list, ad))) { System.err.println("attInfo.getDescriptor(): not found for " + name); errCount++; } } // checks that MBean's operations descriptors are returned. // final MBeanOperationInfo[] ops = modelMBeanInfo.getOperations(); for (MBeanOperationInfo op : ops) { final Descriptor od = op.getDescriptor(); final String name = op.getName(); if (!od.equals(remove(list, od))) { System.err.println("opInfo.getDescriptor(): not found for " + name); errCount++; } } // checks that MBean's notifications descriptors are returned. // final MBeanNotificationInfo[] ntfs = modelMBeanInfo.getNotifications(); for (MBeanNotificationInfo ntf : ntfs) { final Descriptor nd = ntf.getDescriptor(); final String name = ntf.getName(); if (!nd.equals(remove(list, nd))) { System.err.println("notifInfo.getDescriptor(): not found for " + name); errCount++; } } if (errCount > 0) { throw new RuntimeException(string + ": failed with " + errCount + " errors"); } else if (list.size() != 0) { // Check that there are no additional descriptors // throw new RuntimeException(string + ": Unexpected remaining descriptors: " + list); } else System.out.println(string + ": PASSED"); }
/** * Compare this MBeanNotificationInfo to another. * * @param o the object to compare to. * @return true if and only if <code>o</code> is an MBeanNotificationInfo such that its {@link * #getName()}, {@link #getDescription()}, {@link #getDescriptor()}, and {@link * #getNotifTypes()} values are equal (not necessarily identical) to those of this * MBeanNotificationInfo. Two notification type arrays are equal if their corresponding * elements are equal. They are not equal if they have the same elements but in a different * order. */ public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof MBeanNotificationInfo)) return false; MBeanNotificationInfo p = (MBeanNotificationInfo) o; return (p.getName().equals(getName()) && p.getDescription().equals(getDescription()) && p.getDescriptor().equals(getDescriptor()) && Arrays.equals(p.fastGetNotifTypes(), fastGetNotifTypes())); }