{
String operation = "operation1";
ObjectName name = new ObjectName(":type=test");
MutableInteger counter = new MutableInteger(0);
ModelMBeanTarget bean = new ModelMBeanTarget(counter);
String[] names1 = new String[]{"name", "descriptorType", "displayName", "role", "targetObject", "targetObjectType", "currencyTimeLimit"};
// changed to match the actual behaviour indicated in the specs about currencyTimeLimit
// currencyTimeLimit is now -1
Object[] values1 = new Object[]{operation, "operation", "", "operation", null, null, "-1"};
DescriptorSupport operDescr = new DescriptorSupport(names1, values1);
MBeanParameterInfo paramInfo1 = new MBeanParameterInfo("c", "char", "");
MBeanParameterInfo paramInfo2 = new MBeanParameterInfo("s", "short", "");
MBeanParameterInfo paramInfo3 = new MBeanParameterInfo("f", new float[0].getClass().getName(), "");
MBeanParameterInfo paramInfo4 = new MBeanParameterInfo("c", new Object[0][0].getClass().getName(), "");
ModelMBeanOperationInfo operInfo = new ModelMBeanOperationInfo(operation, "", new MBeanParameterInfo[]{paramInfo1, paramInfo2, paramInfo3, paramInfo4}, "java.util.List", ModelMBeanOperationInfo.UNKNOWN, operDescr);
ModelMBeanInfoSupport info = new ModelMBeanInfoSupport(ModelMBeanTarget.class.getName(), "", null, null, new ModelMBeanOperationInfo[]{operInfo}, null);
RequiredModelMBean rmmb = new RequiredModelMBean();
rmmb.setModelMBeanInfo(info);
rmmb.setManagedResource(bean, "ObjectReference");
m_server.registerMBean(rmmb, name);
short s = 10;
Object[] args = new Object[]{new Character('z'), new Short(s), new float[]{1.0F}, new Object[][]{{"Hello"}, {"World"}}};
String[] params = new String[]{paramInfo1.getType(), paramInfo2.getType(), paramInfo3.getType(), paramInfo4.getType()};
List list = (List)m_server.invoke(name, operation, args, params);
// Test that was really called
assertEquals(counter.get(), 1);
// Right values ?
for (int i = 0; i < list.size(); ++i)
{
Object obj = list.get(i);
assertEquals("Returned value is different: " + obj, args[i], obj);
}
m_server.unregisterMBean(name);
ModelMBeanTarget.TargetBean target = new ModelMBeanTarget.TargetBean();
operDescr.setField("targetObject", target);
operDescr.setField("targetObjectType", "ObjectReference");
info.setDescriptor(operDescr, "operation");
rmmb.setModelMBeanInfo(info);
m_server.registerMBean(rmmb, name);
list = (List)m_server.invoke(name, operation, args, params);
// Test that was not called
assertEquals("Operation should not have been called", counter.get(), 1);
// Right values ?
for (int i = 0; i < list.size(); ++i)
{
Object obj = list.get(list.size() - 1 - i);
assertEquals("Returned value is different: " + obj, args[i], obj);