WebMBeanAdapter { public Map<String, MBeanOperationInfo> getOperationMetadata() { MBeanOperationInfo[] operations = mBeanInfo.getOperations(); Map<String, MBeanOperationInfo> operationMap = new TreeMap<String, MBeanOperationInfo>(); for (MBeanOperationInfo operation: operations) { operationMap.put(operation.getName(), operation); } return operationMap; } 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 testGetOperationMetadata() throws Exception { String operationName1 = "operation_name_1"; MBeanOperationInfo mockOperation1 = createMock(MBeanOperationInfo.class); String operationName2 = "operation_name_2"; MBeanOperationInfo mockOperation2 = createMock(MBeanOperationInfo.class); MBeanOperationInfo[] operationList = new MBeanOperationInfo[2]; operationList[0] = mockOperation1; operationList[1] = mockOperation2; expect(mockMBeanInfo.getOperations()).andReturn(operationList); expect(mockOperation1.getName()).andReturn(operationName1); expect(mockOperation2.getName()).andReturn(operationName2); replay(mockMBeanServer, mockSanitizer, mockObjectName, mockMBeanInfo, mockOperation1, mockOperation2); Map<String, MBeanOperationInfo> operationMap = webMBeanAdapter.getOperationMetadata(); assertEquals(2, operationMap.size()); assertEquals(mockOperation1, operationMap.get(operationName1)); assertEquals(mockOperation2, operationMap.get(operationName2)); verify(mockMBeanServer, mockSanitizer, mockObjectName, mockMBeanInfo, mockOperation1, mockOperation2); }