WebMBeanAdapter { public String getAttributeValue(String attributeName) throws JMException, UnsupportedEncodingException { String decodedAttributeName = sanitizer.urlDecode(attributeName, encoding); return sanitizer.escapeValue(mBeanServer.getAttribute(objectName, decodedAttributeName)); } 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 testGetAttributeValue() throws Exception { String attributeName = "attribute_name"; expect(mockSanitizer.urlDecode(attributeName, ENCODING)).andReturn(attributeName); Object value = new Object(); String valueString = "some_string"; expect(mockMBeanServer.getAttribute(mockObjectName, attributeName)).andReturn(value); expect(mockSanitizer.escapeValue(value)).andReturn(valueString); replay(mockMBeanServer, mockSanitizer, mockObjectName); String attributeValue = webMBeanAdapter.getAttributeValue(attributeName); assertEquals(valueString, attributeValue); verify(mockMBeanServer, mockSanitizer, mockObjectName); }