X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fmessagebus-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fmessagebus%2Fapp%2Fimpl%2FMessageBusAppImplModuleTest.java;h=e26502f949fd8fbddbd04f49edfcfd2e46691f27;hp=85d1a1b109819228a2bf8425077f4e12878d33a7;hb=a7e57cf252c2a19a1acfbc23402eed634ae2ac5a;hpb=2d62916cb1f4b4045f4fc38fbd313f8339f9ac67 diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java index 85d1a1b109..e26502f949 100644 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java +++ b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/config/yang/messagebus/app/impl/MessageBusAppImplModuleTest.java @@ -7,17 +7,37 @@ */ package org.opendaylight.controller.config.yang.messagebus.app.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; - import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.config.api.DependencyResolver; +import org.opendaylight.controller.config.api.JmxAttribute; import org.opendaylight.controller.config.api.ModuleIdentifier; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.MountPointService; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.Provider; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.osgi.framework.BundleContext; +import javax.management.ObjectName; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + public class MessageBusAppImplModuleTest { MessageBusAppImplModule messageBusAppImplModule; @@ -55,5 +75,34 @@ public class MessageBusAppImplModuleTest { assertEquals("Set and/or get method/s don't work correctly.", bundleContext, messageBusAppImplModule.getBundleContext()); } - //TODO: create MessageBusAppImplModule.createInstance test -} + @Test + public void createInstanceTest() throws Exception{ + org.opendaylight.controller.sal.binding.api.BindingAwareBroker bindingAwareBrokerMock = mock(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class); + Broker brokerMock = mock(Broker.class); + doReturn(brokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.core.api.Broker.class), any(ObjectName.class), any(JmxAttribute.class)); + doReturn(bindingAwareBrokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class)); + messageBusAppImplModule.resolveDependencies(); + + BindingAwareBroker.ProviderContext providerContext = mock(BindingAwareBroker.ProviderContext.class); + doReturn(providerContext).when(bindingAwareBrokerMock).registerProvider(any(BindingAwareProvider.class)); + Broker.ProviderSession providerSessionMock = mock(Broker.ProviderSession.class); + doReturn(providerSessionMock).when(brokerMock).registerProvider(any(Provider.class)); + DataBroker dataBrokerMock = mock(DataBroker.class); + doReturn(dataBrokerMock).when(providerContext).getSALService(eq(DataBroker.class)); + DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class); + doReturn(domNotificationPublishServiceMock).when(providerSessionMock).getService(DOMNotificationPublishService.class); + DOMMountPointService domMountPointServiceMock = mock(DOMMountPointService.class); + doReturn(domMountPointServiceMock).when(providerSessionMock).getService(DOMMountPointService.class); + MountPointService mountPointServiceMock = mock(MountPointService.class); + doReturn(mountPointServiceMock).when(providerContext).getSALService(eq(MountPointService.class)); + RpcProviderRegistry rpcProviderRegistryMock = mock(RpcProviderRegistry.class); + doReturn(rpcProviderRegistryMock).when(providerContext).getSALService(eq(RpcProviderRegistry.class)); + + WriteTransaction writeTransactionMock = mock(WriteTransaction.class); + doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction(); + doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true)); + + assertNotNull("EventSourceRegistryWrapper has not been created correctly.", messageBusAppImplModule.createInstance()); + } + +} \ No newline at end of file