Search in sources :

Example 1 with HardcodedModuleFactoriesResolver

use of org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver in project controller by opendaylight.

the class ITTest method setUp.

@Before
public void setUp() {
    factory = new TestImplModuleFactory();
    super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory));
}
Also used : TestImplModuleFactory(org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) Before(org.junit.Before)

Example 2 with HardcodedModuleFactoriesResolver

use of org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver 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);
        }
    }
}
Also used : TestingFixedThreadPoolModuleFactory(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory) ModuleFactory(org.opendaylight.controller.config.spi.ModuleFactory) TestingFixedThreadPoolModuleFactory(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory) ModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) ConfigRegistryImpl(org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test) AbstractLockedPlatformMBeanServerTest(org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest)

Example 3 with HardcodedModuleFactoriesResolver

use of org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver in project controller by opendaylight.

the class AbstractScheduledTest method setUp.

@Before
public final void setUp() {
    assertEquals(0, TestingScheduledThreadPoolImpl.getNumberOfCloseMethodCalls());
    super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new TestingScheduledThreadPoolModuleFactory(), new TestingFixedThreadPoolModuleFactory(), new TestingParallelAPSPModuleFactory()));
}
Also used : TestingFixedThreadPoolModuleFactory(org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory) TestingParallelAPSPModuleFactory(org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory) TestingScheduledThreadPoolModuleFactory(org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) Before(org.junit.Before)

Example 4 with HardcodedModuleFactoriesResolver

use of org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver 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();
}
Also used : ConfigTransactionJMXClient(org.opendaylight.controller.config.util.ConfigTransactionJMXClient) ModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) Before(org.junit.Before)

Example 5 with HardcodedModuleFactoriesResolver

use of org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver in project controller by opendaylight.

the class GlobalEventExecutorModuleTest method setUp.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Before
public void setUp() throws Exception {
    factory = new GlobalEventExecutorModuleFactory();
    super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, factory));
    Filter mockFilter = mock(Filter.class);
    doReturn("mock").when(mockFilter).toString();
    doReturn(mockFilter).when(mockedContext).createFilter(anyString());
    doNothing().when(mockedContext).addServiceListener(any(ServiceListener.class), anyString());
    ServiceReference mockServiceRef = mock(ServiceReference.class);
    doReturn(new ServiceReference[] { mockServiceRef }).when(mockedContext).getServiceReferences(anyString(), anyString());
    doReturn(mock(EventExecutor.class)).when(mockedContext).getService(mockServiceRef);
}
Also used : ServiceListener(org.osgi.framework.ServiceListener) EventExecutor(io.netty.util.concurrent.EventExecutor) Filter(org.osgi.framework.Filter) HardcodedModuleFactoriesResolver(org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver) ServiceReference(org.osgi.framework.ServiceReference) Before(org.junit.Before)

Aggregations

HardcodedModuleFactoriesResolver (org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver)9 Before (org.junit.Before)8 ModuleFactoriesResolver (org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver)2 TestingParallelAPSPModuleFactory (org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory)2 TestingFixedThreadPoolModuleFactory (org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory)2 Filter (org.osgi.framework.Filter)2 ServiceListener (org.osgi.framework.ServiceListener)2 ServiceReference (org.osgi.framework.ServiceReference)2 EventLoopGroup (io.netty.channel.EventLoopGroup)1 EventExecutor (io.netty.util.concurrent.EventExecutor)1 Test (org.junit.Test)1 AbstractLockedPlatformMBeanServerTest (org.opendaylight.controller.config.manager.impl.AbstractLockedPlatformMBeanServerTest)1 ClassBasedModuleFactory (org.opendaylight.controller.config.manager.impl.ClassBasedModuleFactory)1 ConfigRegistryImpl (org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl)1 TestingScheduledThreadPoolModuleFactory (org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory)1 ModuleFactory (org.opendaylight.controller.config.spi.ModuleFactory)1 ConfigTransactionJMXClient (org.opendaylight.controller.config.util.ConfigTransactionJMXClient)1 TestImplModuleFactory (org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory)1 BundleContext (org.osgi.framework.BundleContext)1