List of usage examples for javax.management MBeanRegistrationException MBeanRegistrationException
public MBeanRegistrationException(java.lang.Exception e)
MBeanRegistrationException
that wraps the actual java.lang.Exception
. From source file:org.codice.ddf.admin.application.service.impl.ApplicationServiceBeanTest.java
/** * Tests the {@link ApplicationServiceBean#destroy()} method * for the case where an MBeanRegistrationException is thrown * by mBeanServer.unregisterMBean(...)// ww w . j a v a2 s.c om * * @throws Exception */ @Test(expected = ApplicationServiceException.class) public void testDestroyWhenUnregisterMBeanThrowsMBeanRegistrationException() throws Exception { ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer); doThrow(new MBeanRegistrationException(new Exception())).when(mBeanServer) .unregisterMBean(any(ObjectName.class)); serviceBean.destroy(); }
From source file:org.codice.ddf.registry.federationadmin.impl.FederationAdmin.java
public void destroy() throws MBeanRegistrationException { try {//from www. jav a 2s .c o m if (objectName != null && mbeanServer != null) { mbeanServer.unregisterMBean(objectName); } } catch (Exception e) { LOGGER.info("Exception un registering mbean: ", e); throw new MBeanRegistrationException(e); } }
From source file:org.ops4j.gaderian.management.TestMBeanRegistry.java
/** * Tests the handling of registrations errors during processing of the contributed mbeans *///from w w w . ja va 2s .co m public void testRegistrationException() throws Exception { Registry registry = buildFrameworkRegistry("testMBeanRegistry.xml", false); List mBeanList = registry.getConfiguration("gaderian.management.MBeans"); ServicePoint sp1 = ((MBeanRegistrationContribution) mBeanList.get(0)).getServicePoint(); ObjectName on1 = objectNameBuilder.createServiceObjectName(sp1); // Training expect(server.registerMBean(isA(MBeanTestService.class), eq(on1))) .andThrow(new MBeanRegistrationException(new Exception("Registration failed"))); expect(server.registerMBean(isA(MBeanTestService.class), isA(ObjectName.class))) .andThrow(new MBeanRegistrationException(new Exception("Registration failed"))); expect(server.registerMBean(isA(MBeanNonInterfaceTestService.class), isA(ObjectName.class))) .andThrow(new MBeanRegistrationException(new Exception("Registration failed"))); replayAllRegisteredMocks(); interceptLogging(MBeanRegistry.class.getName()); new MBeanRegistryImpl(errorHandler, log, server, objectNameBuilder, mBeanList); assertLoggedMessage("Registering MBean " + on1.toString() + " failed"); verifyAllRegisteredMocks(); }