Example usage for javax.management InstanceAlreadyExistsException InstanceAlreadyExistsException

List of usage examples for javax.management InstanceAlreadyExistsException InstanceAlreadyExistsException

Introduction

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

Prototype

public InstanceAlreadyExistsException() 

Source Link

Document

Default constructor.

Usage

From source file:org.codice.ddf.admin.application.service.impl.ApplicationServiceBeanTest.java

/**
 * Tests the {@link ApplicationServiceBean#init()} method for the case
 * where the serviceBean has already been initialized
 *
 * @throws Exception//from  ww w.jav a 2  s .c o m
 */
@Test
public void testInitTwice() throws Exception {
    ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt,
            mBeanServer);
    when(mBeanServer.registerMBean(any(Object.class), any(ObjectName.class)))
            .thenThrow(new InstanceAlreadyExistsException()).thenReturn(null);

    serviceBean.init();

    verify(mBeanServer, atMost(1)).unregisterMBean(objectName);
    verify(mBeanServer, times(2)).registerMBean(serviceBean, objectName);
}

From source file:org.codice.ddf.admin.core.impl.AdminConsoleServiceTest.java

/**
 * Tests the {@link AdminConsoleService#init()} method for the case where it has already been
 * initialized/*w  ww.j  a  v a 2  s .com*/
 *
 * @throws Exception
 */
@Test
public void testInitAlreadyExists() throws Exception {
    when(testServer.registerMBean(any(Object.class), any(ObjectName.class)))
            .thenThrow(new InstanceAlreadyExistsException()).thenReturn(null);

    configAdmin.init();

    verify(testServer, times(2)).registerMBean(any(Object.class), any(ObjectName.class));
    verify(testServer).unregisterMBean(any(ObjectName.class));
}

From source file:org.codice.ddf.ui.admin.api.ConfigurationAdminTest.java

/**
 * Tests the {@link ConfigurationAdmin#init()} method for the case where
 * it has already been initialized//ww w . j  a  v  a  2 s .  c om
 *
 * @throws Exception
 */
@Test
public void testInitAlreadyExists() throws Exception {
    org.osgi.service.cm.ConfigurationAdmin testConfigAdmin = mock(org.osgi.service.cm.ConfigurationAdmin.class);
    MBeanServer testServer = mock(MBeanServer.class);

    ConfigurationAdmin configAdmin = new ConfigurationAdmin(testConfigAdmin);

    configAdmin.setMBeanServer(testServer);
    when(testServer.registerMBean(any(Object.class), any(ObjectName.class)))
            .thenThrow(new InstanceAlreadyExistsException()).thenReturn(null);

    configAdmin.init();

    verify(testServer, times(2)).registerMBean(any(Object.class), any(ObjectName.class));
    verify(testServer).unregisterMBean(any(ObjectName.class));
}

From source file:org.entando.edo.report.Report.java

private Report() throws InstanceAlreadyExistsException {
    if (obj != null) {
        System.out.println("\nObject already created....");
        throw new InstanceAlreadyExistsException();
    }/*  ww  w  .  ja  v  a 2  s .  co  m*/
}