"MBEAN",
"JMX Metadata for testing purposes",
new Double(0),
"test metadata",
new Double(99.999)};
DescriptorSupport ds = new DescriptorSupport(fields, values);
ModelMBeanInfoSupport info =
new ModelMBeanInfoSupport("TestMetadata",
"An empty model mbean info instance",
new ModelMBeanAttributeInfo[0],
new ModelMBeanConstructorInfo[0],
new ModelMBeanOperationInfo[0],
new ModelMBeanNotificationInfo[0],
ds);
Descriptor d = info.getMBeanDescriptor();
assertFalse("descriptor is null", d == null);
assertTrue("Expecting 9 fields", d.getFieldNames().length == 9);
String[] deffields =
{
"name",
"descriptortype",
"displayname",
"persistpolicy",
"log",
"export",
"visibility"};
String[] infofields = d.getFieldNames();
assertTrue("Expected field names not present",
Arrays.asList(infofields).containsAll(Arrays.asList(deffields)));
assertTrue("Unexpected name",
((String)d.getFieldValue("name")).compareTo((String)ds.getFieldValue("name"))
== 0);
assertTrue("Unexpected descriptorType",
((String)d.getFieldValue("descriptortype")).compareToIgnoreCase((String)ds.getFieldValue("descriptortype"))
== 0);
assertTrue("Unexpected displayName: " + d.getFieldValue("displayname"),
((String)d.getFieldValue("displayname")).compareTo((String)ds.getFieldValue("displayname"))
== 0);
assertTrue("Unexpected targetObject: " + d.getFieldValue("targetObject"),
((Double)d.getFieldValue("targetObject")).equals(new Double(0.0)));
assertTrue("Unexpected persistpolicy",
((String)d.getFieldValue("persistpolicy")).compareToIgnoreCase("never")
== 0);
assertTrue("Unexpected log",
((String)d.getFieldValue("log")).compareToIgnoreCase("F") == 0);
assertTrue("Unexpected export",
((String)d.getFieldValue("export")).compareTo((String)ds.getFieldValue("export"))
== 0);
assertTrue("Unexpected defaultValue",
((Double)d.getFieldValue("defaultValue")).equals(new Double(99.999)));
assertTrue("Unexpected visibility",
((String)d.getFieldValue("visibility")).compareTo("1") == 0);