use of org.exoplatform.container.jmx.support.ManagedDependent in project kernel by exoplatform.
the class TestRootContainerManagedIntegration method testManagementAware.
public void testManagementAware() throws Exception {
RootContainer container = createRootContainer("configuration4.xml");
ManagedManagementAware aware = (ManagedManagementAware) container.getComponentInstance("ManagedManagementAware");
assertNotNull(aware.context);
MBeanServer server = container.getMBeanServer();
assertNotNull(server);
Object foo = server.getAttribute(ObjectName.getInstance("exo:object=Foo"), "Reference");
assertNotNull(foo);
assertEquals(aware.foo, foo);
ManagedDependent expectedBar = new ManagedDependent("Bar");
aware.context.register(expectedBar);
assertEquals(1, server.queryMBeans(ObjectName.getInstance("exo:object=Bar"), null).size());
Object bar = server.getAttribute(ObjectName.getInstance("exo:object=Bar"), "Reference");
assertEquals(expectedBar, bar);
aware.context.unregister(expectedBar);
assertEquals(0, server.queryMBeans(ObjectName.getInstance("exo:object=Bar"), null).size());
}
Aggregations