MBeans { private List<MBeanAttribute> getAttributes(ObjectName name, MBeanAttributeInfo[] attributeInfos) { final List<String> attributeNames = new ArrayList<String>(attributeInfos.length); for (final MBeanAttributeInfo attribute : attributeInfos) { if (attribute.isReadable() && !"password".equalsIgnoreCase(attribute.getName())) { attributeNames.add(attribute.getName()); } } final String[] attributeNamesArray = attributeNames.toArray(new String[0]); final List<MBeanAttribute> result = new ArrayList<MBeanAttribute>(); try { final List<Object> attributes = mbeanServer.getAttributes(name, attributeNamesArray); for (final Object object : attributes) { final Attribute attribute = (Attribute) object; final Object value = convertValueIfNeeded(attribute.getValue()); final String attributeDescription = getAttributeDescription(attribute.getName(), attributeInfos); final String formattedAttributeValue = formatAttributeValue(value); final MBeanAttribute mbeanAttribute = new MBeanAttribute(attribute.getName(), attributeDescription, formattedAttributeValue); result.add(mbeanAttribute); } } catch (final Exception e) { final MBeanAttribute mbeanAttribute = new MBeanAttribute("exception", null, e.toString()); result.add(mbeanAttribute); } return result; } MBeans(); private  MBeans(MBeanServer mbeanServer); static List<MBeanNode> getAllMBeanNodes(); static String getConvertedAttributes(String jmxValueParameter); static MBeanServer getPlatformMBeanServer(); static final char ATTRIBUTES_SEPARATOR; }
@Test public void testToString() { final MBeanNode mBeanNode = new MBeanNode("name", "description", Arrays.asList(new MBeanAttribute("name", "description", "formattedValue"))); assertNotNull("mbeanNode", mBeanNode); assertNotNull("toString", mBeanNode.toString()); assertNotNull("getAttributes", mBeanNode.getAttributes()); for (final MBeanAttribute attribute : mBeanNode.getAttributes()) { assertNotNull("attribute", attribute); assertNotNull("toString", attribute.toString()); } }