X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Flifecycle%2FContextChainHolderImplTest.java;h=a5761ec8f2a24b0a032a465d745f9e244690f1c7;hb=674f0fd3f64be8aba1bfa989ddc9c864a682123f;hp=4c3b719b9f3b73cf70b57ec2e95078e6b505364a;hpb=f6181dcd534edba831d73729fdb642ac7deaeda2;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java index 4c3b719b9f..a5761ec8f2 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImplTest.java @@ -9,6 +9,7 @@ package org.opendaylight.openflowplugin.impl.lifecycle; import com.google.common.util.concurrent.Futures; import io.netty.util.HashedWheelTimer; +import java.util.concurrent.ExecutorService; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -16,16 +17,20 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; +import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo; import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager; +import org.opendaylight.openflowplugin.api.openflow.lifecycle.OwnershipChangeListener; import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext; import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager; import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext; import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; @RunWith(MockitoJUnitRunner.class) public class ContextChainHolderImplTest { @@ -51,25 +56,51 @@ public class ContextChainHolderImplTest { @Mock private ClusterSingletonServiceProvider singletonServicesProvider; @Mock + private ExecutorService executorService; + @Mock + private ClusterSingletonServiceRegistration clusterSingletonServiceRegistration; + @Mock private EntityOwnershipService entityOwnershipService; + @Mock + private EntityOwnershipListenerRegistration entityOwnershipListenerRegistration; + @Mock + private OwnershipChangeListener ownershipChangeListener; + @Mock + private OpenflowProviderConfig config; private ContextChainHolderImpl contextChainHolder; @Before public void setUp() throws Exception { - contextChainHolder = new ContextChainHolderImpl(timer); - contextChainHolder.addManager(statisticsManager); - contextChainHolder.addManager(rpcManager); - contextChainHolder.addManager(deviceManager); - contextChainHolder.addSingletonServicesProvider(singletonServicesProvider); + Mockito.doAnswer(invocation -> { + invocation.getArgumentAt(0, Runnable.class).run(); + return null; + }).when(executorService).submit(Mockito.any()); + + Mockito.when(connectionContext.getDeviceInfo()).thenReturn(deviceInfo); Mockito.when(deviceManager.createContext(connectionContext)).thenReturn(deviceContext); - Mockito.when(rpcManager.createContext( - deviceInfo, - deviceContext)) - .thenReturn(rpcContext); + Mockito.when(rpcManager.createContext(deviceContext)).thenReturn(rpcContext); Mockito.when(statisticsManager.createContext(deviceContext)).thenReturn(statisticsContext); Mockito.when(deviceContext.makeDeviceSlave()).thenReturn(Futures.immediateFuture(null)); + Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo); + + Mockito.when(singletonServicesProvider.registerClusterSingletonService(Mockito.any())) + .thenReturn(clusterSingletonServiceRegistration); + Mockito.when(entityOwnershipService.registerListener(Mockito.any(), Mockito.any())) + .thenReturn(entityOwnershipListenerRegistration); + Mockito.when(config.isUsingReconciliationFramework()).thenReturn(false); + + contextChainHolder = new ContextChainHolderImpl( + timer, + executorService, + singletonServicesProvider, + entityOwnershipService, + ownershipChangeListener, + config); + contextChainHolder.addManager(statisticsManager); + contextChainHolder.addManager(rpcManager); + contextChainHolder.addManager(deviceManager); } @Test @@ -81,7 +112,7 @@ public class ContextChainHolderImplTest { public void createContextChain() throws Exception { contextChainHolder.createContextChain(connectionContext); Mockito.verify(deviceManager).createContext(Mockito.any(ConnectionContext.class)); - Mockito.verify(rpcManager).createContext(Mockito.any(DeviceInfo.class), Mockito.any(DeviceContext.class)); + Mockito.verify(rpcManager).createContext(Mockito.any(DeviceContext.class)); Mockito.verify(statisticsManager).createContext(Mockito.any(DeviceContext.class)); }