BUG-8494: do not attempt to reconnect ReconnectingClientConnection
[controller.git] / opendaylight / md-sal / cds-access-client / src / test / java / org / opendaylight / controller / cluster / access / client / ConnectedClientConnectionTest.java
index e66512d041b3be2d8e50d5d9372bea5a04e4659e..29cac2315ebccd524f79dfbe1a99cd13990817dc 100644 (file)
@@ -12,13 +12,26 @@ import static org.mockito.Matchers.same;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
+import java.util.Optional;
+import java.util.function.Consumer;
+import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.ABIVersion;
 import org.opendaylight.controller.cluster.access.concepts.RequestException;
+import org.opendaylight.controller.cluster.access.concepts.Response;
 
 public class ConnectedClientConnectionTest
         extends AbstractClientConnectionTest<ConnectedClientConnection<BackendInfo>, BackendInfo> {
 
+    @Test
+    public void testCheckTimeoutConnectionTimedout() throws Exception {
+        final Consumer<Response<?, ?>> callback = mock(Consumer.class);
+        connection.sendRequest(createRequest(replyToProbe.ref()), callback);
+        final long now = context.ticker().read() + ConnectedClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS;
+        final Optional<Long> timeout = connection.checkTimeout(now);
+        Assert.assertNull(timeout);
+    }
+
     @Override
     protected ConnectedClientConnection<BackendInfo> createConnection() {
         final BackendInfo backend = new BackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON, 10);