Improve cleanup after device disconnected event
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / lifecycle / LifecycleServiceImplTest.java
index 8ac5337d5fdeb2e1f34b06452ce34900d66ed109..7d02cdb2e14fd7bd25e47692ff78fc5573870637 100644 (file)
@@ -16,6 +16,7 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
@@ -45,6 +46,8 @@ public class LifecycleServiceImplTest {
     private DeviceFlowRegistry deviceFlowRegistry;
     @Mock
     private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
+    @Mock
+    private ClusterSingletonServiceRegistration clusterSingletonServiceRegistration;
 
     private LifecycleService lifecycleService;
 
@@ -57,6 +60,8 @@ public class LifecycleServiceImplTest {
         Mockito.when(deviceFlowRegistry.fill()).thenReturn(Futures.immediateFuture(null));
         Mockito.when(connectionContext.getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
         Mockito.when(deviceInfo.getLOGValue()).thenReturn(TEST_NODE);
+        Mockito.when(clusterSingletonServiceProvider.registerClusterSingletonService(Mockito.any()))
+                .thenReturn(clusterSingletonServiceRegistration);
 
         Mockito.when(deviceContext.stopClusterServices(Mockito.anyBoolean())).thenReturn(Futures.immediateFuture(null));
         Mockito.when(statContext.stopClusterServices(Mockito.anyBoolean())).thenReturn(Futures.immediateFuture(null));
@@ -80,7 +85,7 @@ public class LifecycleServiceImplTest {
 
     @Test
     public void closeServiceInstance() throws Exception {
-        lifecycleService.closeServiceInstance();
+        lifecycleService.closeServiceInstance().get();
         Mockito.verify(statContext).stopClusterServices(false);
         Mockito.verify(deviceContext).stopClusterServices(false);
         Mockito.verify(rpcContext).stopClusterServices(false);