Example usage for javax.management MBeanRegistrationException MBeanRegistrationException

List of usage examples for javax.management MBeanRegistrationException MBeanRegistrationException

Introduction

In this page you can find the example usage for javax.management MBeanRegistrationException MBeanRegistrationException.

Prototype

public MBeanRegistrationException(java.lang.Exception e) 

Source Link

Document

Creates an MBeanRegistrationException that wraps the actual java.lang.Exception.

Usage

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();
}