}
public void testSetCompositeAttributes() throws Exception
{
MBeanServer server = createMBeanServer();
SimpleObject composite = new SimpleObject();
CompositeMXBeanSupport support = new CompositeMXBeanSupport("Simple", composite);
ObjectName objectName = CompositeMXBeanSupportMXBean.REGISTERED_OBJECT_NAME;
server.registerMBean(support, objectName);
OpenMBeanInfo info = (OpenMBeanInfo) server.getMBeanInfo(objectName);
String[] keys = CompositeInterface.KEYS;
CompositeData data = createCompositeData(SimpleInterface.class.getName(), SimpleInterface.KEYS, SimpleInterface.VALUES);
Object[] values = { "Simple", data };
data = createCompositeData(SimpleInterface.class.getName(), SimpleInterface.KEYS, SimpleInterface.CHANGED_VALUES);
Object[] changedValues = { "Changed", data };
AttributeList list = new AttributeList(keys.length);
for (int i = 0; i < keys.length; ++i)
{
String name = getUpperName(keys[i]);
server.setAttribute(objectName, new Attribute(name, changedValues[i]));
Attribute attribute = new Attribute(name, values[i]);
list.add(attribute);
}
SimpleObject changed = new SimpleObject();
changed.setBigDecimal(SimpleInterface.bigDecimalChangedValue);
changed.setBigInteger(SimpleInterface.bigIntegerChangedValue);
changed.setBoolean(SimpleInterface.booleanChangedValue);
changed.setByte(SimpleInterface.byteChangedValue);
changed.setCharacter(SimpleInterface.characterChangedValue);
changed.setDate(SimpleInterface.dateChangedValue);
changed.setDouble(SimpleInterface.doubleChangedValue);
changed.setFloat(SimpleInterface.floatChangedValue);
changed.setInteger(SimpleInterface.integerChangedValue);
changed.setLong(SimpleInterface.longChangedValue);
changed.setObjectName(SimpleInterface.objectNameChangedValue);
changed.setPrimitiveBoolean(SimpleInterface.primitiveBooleanChangedValue);
changed.setPrimitiveByte(SimpleInterface.primitiveByteChangedValue);
changed.setPrimitiveChar(SimpleInterface.primitiveCharChangedValue);
changed.setPrimitiveDouble(SimpleInterface.primitiveDoubleChangedValue);
changed.setPrimitiveFloat(SimpleInterface.primitiveFloatChangedValue);
changed.setPrimitiveInt(SimpleInterface.primitiveIntChangedValue);
changed.setPrimitiveLong(SimpleInterface.primitiveLongChangedValue);
changed.setPrimitiveShort(SimpleInterface.primitiveShortChangedValue);
changed.setShort(SimpleInterface.shortChangedValue);
changed.setString(SimpleInterface.stringChangedValue);
Object[] realChangedValues = { "Changed", changed };
checkAttributes(server, objectName, CompositeMXBeanSupportMXBean.class, support, CompositeInterface.KEYS, CompositeInterface.TYPES, changedValues, realChangedValues, info);
setAttributes(server, objectName, list);
Object[] realValues = { "Simple", composite };