use of javax.management.MBeanRegistrationException in project ddf by codice.
the class ResourceDownloadTest method setupMockMBeanServer.
private void setupMockMBeanServer(boolean isRegistered, boolean throwMBeanRegException) throws Exception {
when(mockMBeanServer.isRegistered(resourceDownloadObjectName)).thenReturn(isRegistered);
if (throwMBeanRegException) {
doThrow(new MBeanRegistrationException(new Exception(), "")).when(mockMBeanServer).registerMBean(any(StandardMBean.class), eq(resourceDownloadObjectName));
doThrow(new MBeanRegistrationException(new Exception(), "")).when(mockMBeanServer).unregisterMBean(resourceDownloadObjectName);
}
}
use of javax.management.MBeanRegistrationException in project ddf by codice.
the class UndeliveredMessages method registerMbean.
private void registerMbean() {
try {
undeliveredMessagesObjectName = new ObjectName(UndeliveredMessages.class.getName() + M_BEAN_NAME);
} catch (MalformedObjectNameException e) {
LOGGER.warn("Unable to create MBean: [{}]. For more " + "information, set logging level to DEBUG.", undeliveredMessagesObjectName);
LOGGER.debug("Unable to create MBean: [{}].", undeliveredMessagesObjectName, e);
}
if (mBeanServer == null) {
LOGGER.warn("Could not register MBean: [{}], MBean server is null.", undeliveredMessagesObjectName);
return;
}
try {
try {
mBeanServer.registerMBean(this, undeliveredMessagesObjectName);
LOGGER.info("Registered MBean under object name: {}", undeliveredMessagesObjectName);
} catch (InstanceAlreadyExistsException e) {
// Try to remove and re-register
mBeanServer.unregisterMBean(undeliveredMessagesObjectName);
mBeanServer.registerMBean(this, undeliveredMessagesObjectName);
LOGGER.info("Re-registered MBean: [{}]", undeliveredMessagesObjectName);
}
} catch (MBeanRegistrationException | InstanceNotFoundException | InstanceAlreadyExistsException | NotCompliantMBeanException e) {
LOGGER.warn("Could not register MBean: [{}]. For more information, set " + "logging level to DEBUG.", undeliveredMessagesObjectName);
LOGGER.debug("Could not register MBean: [{}].", undeliveredMessagesObjectName, e);
}
}
use of javax.management.MBeanRegistrationException in project ddf by codice.
the class TestMigratable method initWhenMBeanUnregistrationFails.
@Test(expected = MBeanRegistrationException.class)
public void initWhenMBeanUnregistrationFails() throws Exception {
ConfigurationMigrationManager configurationMigrationManager = createConfigurationMigrationManager();
when(mBeanServer.registerMBean(configurationMigrationManager, configMigrationServiceObjectName)).thenThrow(new InstanceAlreadyExistsException());
doThrow(new MBeanRegistrationException(new Exception())).when(mBeanServer).unregisterMBean(configMigrationServiceObjectName);
configurationMigrationManager.init();
}
Aggregations