use of org.apache.cxf.management.jmx.export.AnnotationTestInstrumentation in project cxf by apache.
the class JMXManagedComponentManagerTest method testRegisterInstrumentation.
@Test
public void testRegisterInstrumentation() throws Exception {
AnnotationTestInstrumentation im = new AnnotationTestInstrumentation();
ObjectName name = new ObjectName("org.apache.cxf:type=foo,name=bar");
im.setName("John Smith");
manager.register(im, name);
Object val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
assertEquals("Incorrect result", "John Smith", val);
try {
manager.register(im, name);
fail("Registering with existing name should fail.");
} catch (JMException jmex) {
// Expected
}
manager.register(im, name, true);
val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
assertEquals("Incorrect result", "John Smith", val);
manager.unregister(name);
im.setName("Foo Bar");
name = manager.register(im);
val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
assertEquals("Incorrect result", "Foo Bar", val);
try {
manager.register(im);
fail("Registering with existing name should fail.");
} catch (JMException jmex) {
// Expected
}
name = manager.register(im, true);
val = manager.getMBeanServer().getAttribute(name, NAME_ATTRIBUTE);
assertEquals("Incorrect result", "Foo Bar", val);
manager.unregister(im);
}
Aggregations