@Test
public void testConfigMXBean() throws Exception {
ObjectName name = new ObjectName(ConfigMXBean.MXBEAN_NAME);
// Ensure the object was registered at startup
ConfigMXBean bean =
(ConfigMXBean) profileCollector.getRegisteredMBean(
ConfigMXBean.MXBEAN_NAME);
assertNotNull(bean);
// Get individual fields
String appListener = (String) mbsc.getAttribute(name, "AppListener");
String appName = (String) mbsc.getAttribute(name, "AppName");
String hostName = (String) mbsc.getAttribute(name, "HostName");
String appRoot = (String) mbsc.getAttribute(name, "AppRoot");
int jmxPort = (Integer) mbsc.getAttribute(name, "JmxPort");
NodeType type = NodeType.valueOf(
(String) mbsc.getAttribute(name, "NodeType"));
String serverHost = (String) mbsc.getAttribute(name, "ServerHostName");
long timeout = (Long) mbsc.getAttribute(name, "StandardTxnTimeout");
String desc = (String) mbsc.getAttribute(name, "ProtocolDescriptor");
System.out.println("This node's data:");
System.out.println(" node type: " + type);
System.out.println(" app listener: " + appListener);
System.out.println(" app name: " + appName);
System.out.println(" app root: " + appRoot);
System.out.println(" txn timeout:" + timeout);
System.out.println(" host name: " + hostName);
System.out.println(" jmx port: " + jmxPort);
System.out.println(" server host:" + serverHost);
System.out.println(" protocol descriptor:" + desc);
// Create the proxy for the object
ConfigMXBean proxy =
JMX.newMXBeanProxy(mbsc, name, ConfigMXBean.class);
assertEquals(appListener, proxy.getAppListener());
assertEquals(appName, proxy.getAppName());
assertEquals(hostName, proxy.getHostName());
assertEquals(appRoot, proxy.getAppRoot());
assertEquals(jmxPort, proxy.getJmxPort());
assertEquals(type, proxy.getNodeType());
assertEquals(serverHost, proxy.getServerHostName());
assertEquals(timeout, proxy.getStandardTxnTimeout());
assertEquals(desc, proxy.getProtocolDescriptor());
assertEquals(appListener, bean.getAppListener());
assertEquals(appName, bean.getAppName());
assertEquals(hostName, bean.getHostName());
assertEquals(appRoot, bean.getAppRoot());