WebMBeanAdapter { public Map<String, MBeanAttributeInfo> getAttributeMetadata() { MBeanAttributeInfo[] attributeList = mBeanInfo.getAttributes(); Map<String, MBeanAttributeInfo> attributeMap = new TreeMap<String, MBeanAttributeInfo>(); for (MBeanAttributeInfo attribute: attributeList) { attributeMap.put(attribute.getName(), attribute); } return attributeMap; } WebMBeanAdapter(MBeanServer mBeanServer, String mBeanName, String encoding); Map<String, MBeanAttributeInfo> getAttributeMetadata(); Map<String, MBeanOperationInfo> getOperationMetadata(); MBeanOperationInfo getOperationInfo(String operationName); Map<String,Object> getAttributeValues(); String getAttributeValue(String attributeName); String invokeOperation(String operationName, Map<String, String[]> parameterMap);  }
@Test public void testGetAttributeMetadata() throws Exception { String attributeName1 = "attribute_name_1"; MBeanAttributeInfo mockAttribute1 = createMock(MBeanAttributeInfo.class); String attributeName2 = "attribute_name_2"; MBeanAttributeInfo mockAttribute2 = createMock(MBeanAttributeInfo.class); MBeanAttributeInfo[] attributeList = new MBeanAttributeInfo[2]; attributeList[0] = mockAttribute1; attributeList[1] = mockAttribute2; expect(mockMBeanInfo.getAttributes()).andReturn(attributeList); expect(mockAttribute1.getName()).andReturn(attributeName1); expect(mockAttribute2.getName()).andReturn(attributeName2); replay(mockMBeanServer, mockSanitizer, mockObjectName, mockMBeanInfo, mockAttribute1, mockAttribute2); Map<String, MBeanAttributeInfo> attributeMap = webMBeanAdapter.getAttributeMetadata(); assertEquals(2, attributeMap.size()); assertEquals(mockAttribute1, attributeMap.get(attributeName1)); assertEquals(mockAttribute2, attributeMap.get(attributeName2)); verify(mockMBeanServer, mockSanitizer, mockObjectName, mockMBeanInfo, mockAttribute1, mockAttribute2); }