use of org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver in project controller by opendaylight.
the class ConfigRegistryImplTest method testFailOnTwoFactoriesExportingSameImpl.
@Test
@SuppressWarnings("IllegalCatch")
public void testFailOnTwoFactoriesExportingSameImpl() {
ModuleFactory factory = new TestingFixedThreadPoolModuleFactory();
BundleContext context = mock(BundleContext.class);
ConfigRegistryImpl configRegistry = null;
try {
ModuleFactoriesResolver resolver = new HardcodedModuleFactoriesResolver(mock(BundleContext.class), factory, factory);
configRegistry = new ConfigRegistryImpl(resolver, ManagementFactory.getPlatformMBeanServer(), null);
configRegistry.beginConfig();
fail();
} catch (final IllegalArgumentException e) {
assertTrue(e.getMessage(), e.getMessage().startsWith("Module name is not unique. Found two conflicting factories with same name " + "'fixed':"));
verifyZeroInteractions(context);
} finally {
try {
configRegistry.close();
} catch (final Exception e) {
// ignore
LOG.warn("Ignoring exception", e);
}
}
}
use of org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver in project controller by opendaylight.
the class ShutdownTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
ModuleFactoriesResolver factoriesResolver = new HardcodedModuleFactoriesResolver(mockedContext, factory);
super.initConfigTransactionManagerImpl(factoriesResolver);
doReturn(mockedSysBundle).when(mockedContext).getBundle(0);
mockedContext.getBundle(0);
doNothing().when(mockedSysBundle).stop();
doReturn(mockedContext).when(mockedSysBundle).getBundleContext();
doReturn(new Bundle[] { mockedSysBundle }).when(mockedContext).getBundles();
doReturn("system bundle").when(mockedSysBundle).getSymbolicName();
ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
// initialize default instance
transaction.commit();
}
Aggregations