Search in sources :

Example 1 with ClassLoadingStrategy

use of org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy in project controller by opendaylight.

the class RefreshingSCPModuleInfoRegistryTest method testConstructor.

@Test
public void testConstructor() throws Exception {
    final ModuleInfoRegistry reg = mock(ModuleInfoRegistry.class);
    final SchemaContextProvider prov = mock(SchemaContextProvider.class);
    doReturn("string").when(prov).toString();
    final BundleContext ctxt = mock(BundleContext.class);
    final ServiceRegistration<?> servReg = mock(ServiceRegistration.class);
    doReturn(servReg).when(ctxt).registerService(any(Class.class), any(SchemaContextProvider.class), any(Dictionary.class));
    doReturn(servReg).when(ctxt).registerService(Mockito.anyString(), any(Object.class), any(Dictionary.class));
    doNothing().when(servReg).setProperties(any(Dictionary.class));
    final ClassLoadingStrategy classLoadingStrat = mock(ClassLoadingStrategy.class);
    final BindingContextProvider codecRegistryProvider = mock(BindingContextProvider.class);
    doNothing().when(codecRegistryProvider).update(classLoadingStrat, prov);
    final BindingRuntimeContext bindingRuntimeContext = mock(BindingRuntimeContext.class);
    doReturn("B-runtime-context").when(bindingRuntimeContext).toString();
    doReturn(bindingRuntimeContext).when(codecRegistryProvider).getBindingContext();
    final RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, classLoadingStrat, this.sourceProvider, codecRegistryProvider, ctxt);
    doNothing().when(servReg).unregister();
    final YangModuleInfo modInfo = mock(YangModuleInfo.class);
    doReturn("").when(modInfo).toString();
    final ObjectRegistration<YangModuleInfo> ymi = mock(ObjectRegistration.class);
    doReturn(ymi).when(reg).registerModuleInfo(modInfo);
    scpreg.registerModuleInfo(modInfo);
    scpreg.updateService();
    verify(codecRegistryProvider).update(classLoadingStrat, prov);
    scpreg.close();
    Mockito.verify(servReg, Mockito.times(1)).setProperties(any(Dictionary.class));
    Mockito.verify(servReg, Mockito.times(1)).unregister();
}
Also used : Dictionary(java.util.Dictionary) BindingContextProvider(org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider) RefreshingSCPModuleInfoRegistry(org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry) ModuleInfoRegistry(org.opendaylight.mdsal.binding.generator.api.ModuleInfoRegistry) SchemaContextProvider(org.opendaylight.yangtools.yang.model.api.SchemaContextProvider) ClassLoadingStrategy(org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy) BindingRuntimeContext(org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) RefreshingSCPModuleInfoRegistry(org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 2 with ClassLoadingStrategy

use of org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy in project controller by opendaylight.

the class AbstractConfigTest method initConfigTransactionManagerImpl.

// this method should be called in @Before
protected void initConfigTransactionManagerImpl(final ModuleFactoriesResolver resolver) {
    final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
    this.configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(platformMBeanServer);
    initBundleContext();
    this.baseJmxRegistrator = new BaseJMXRegistrator(platformMBeanServer);
    this.configRegistry = new ConfigRegistryImpl(resolver, platformMBeanServer, this.baseJmxRegistrator, new BindingContextProvider() {

        @Override
        public synchronized void update(final ClassLoadingStrategy classLoadingStrategy, final SchemaContextProvider ctxProvider) {
        // NOOP
        }

        @Override
        public synchronized BindingRuntimeContext getBindingContext() {
            return getBindingRuntimeContext();
        }
    });
    this.notifyingConfigRegistry = new JMXNotifierConfigRegistry(this.configRegistry, platformMBeanServer);
    try {
        this.configRegistryJMXRegistrator.registerToJMXNoNotifications(this.configRegistry);
        this.configRegistryJMXRegistrator.registerToJMX(this.notifyingConfigRegistry);
    } catch (final InstanceAlreadyExistsException e) {
        throw new RuntimeException(e);
    }
    this.configRegistryClient = new ConfigRegistryJMXClient(platformMBeanServer);
    this.currentBundleContextServiceRegistrationHandler = new RecordingBundleContextServiceRegistrationHandler();
}
Also used : JMXNotifierConfigRegistry(org.opendaylight.controller.config.manager.impl.jmx.JMXNotifierConfigRegistry) BindingContextProvider(org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider) BaseJMXRegistrator(org.opendaylight.controller.config.manager.impl.jmx.BaseJMXRegistrator) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ClassLoadingStrategy(org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy) SchemaContextProvider(org.opendaylight.yangtools.yang.model.api.SchemaContextProvider) ConfigRegistryJMXRegistrator(org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator) ConfigRegistryJMXClient(org.opendaylight.controller.config.util.ConfigRegistryJMXClient) MBeanServer(javax.management.MBeanServer)

Aggregations

BindingContextProvider (org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider)2 ClassLoadingStrategy (org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy)2 SchemaContextProvider (org.opendaylight.yangtools.yang.model.api.SchemaContextProvider)2 Dictionary (java.util.Dictionary)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 MBeanServer (javax.management.MBeanServer)1 Test (org.junit.Test)1 BaseJMXRegistrator (org.opendaylight.controller.config.manager.impl.jmx.BaseJMXRegistrator)1 ConfigRegistryJMXRegistrator (org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator)1 JMXNotifierConfigRegistry (org.opendaylight.controller.config.manager.impl.jmx.JMXNotifierConfigRegistry)1 RefreshingSCPModuleInfoRegistry (org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry)1 ConfigRegistryJMXClient (org.opendaylight.controller.config.util.ConfigRegistryJMXClient)1 ModuleInfoRegistry (org.opendaylight.mdsal.binding.generator.api.ModuleInfoRegistry)1 BindingRuntimeContext (org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext)1 YangModuleInfo (org.opendaylight.yangtools.yang.binding.YangModuleInfo)1 BundleContext (org.osgi.framework.BundleContext)1