MBeanHelper { public void set(ObjectName bean, String attr, String value) throws Exception { Map<String, MBeanAttributeInfo> attrInfos = getAttributeInfos(bean, Collections.singletonList(attr), false, true); Object ov = convert(value, attrInfos.get(attr).getType()); mserver.setAttribute(bean, new Attribute(attr, ov)); } MBeanHelper(MBeanServerConnection connection); void setFormatingOption(String name, Object value); Map<String, String> get(ObjectName bean, Collection<String> attrs); void getAsTable(ObjectName bean, Collection<String> attrs, MTable table); void set(ObjectName bean, String attr, String value); String invoke(ObjectName bean, String operation, String... params); String describe(ObjectName bean); static String FORMAT_TABLE_COLUMN_WIDTH_THRESHOLD; static String FORMAT_COMPOSITE_FIELD_WIDTH_THRESHODL; }
@Test(expected=IllegalArgumentException.class) public void test_bean_invalid_set() throws Exception { MBeanHelper helper = new MBeanHelper(ManagementFactory.getPlatformMBeanServer()); helper.set(managementMXBean(), "ThreadCpuTimeEnabled", "true"); }