try
{
MBeanServer server = MBeanServerFactory.newMBeanServer();
ObjectName name = new ObjectName("test:key=value");
RegistrationAware original = new RegistrationAware();
RegistrationAware ra = new RegistrationAware();
server.registerMBean(original, name);
try
{
server.registerMBean(ra, name);
fail("expected a InstanceAlreadyExistsException");
}
catch (InstanceAlreadyExistsException e)
{
}
assertTrue("preRegister", ra.isPreRegisterCalled());
assertTrue("postRegister", ra.isPostRegisterCalled());
assertTrue("postRegisterRegistrationDone", !ra.isPostRegisterRegistrationDone());
assertTrue("preDeRegister", !ra.isPreDeRegisterCalled());
assertTrue("postDeRegister", !ra.isPostDeRegisterCalled());
assertEquals(name, ra.getRegisteredObjectName());
server.unregisterMBean(name);
}
catch (Exception e)
{