Improve error reporting for tell-based reads
[controller.git] / opendaylight / md-sal / cds-access-client / src / test / java / org / opendaylight / controller / cluster / access / client / ReconnectingClientConnectionTest.java
index a281b1208a3334b948fe7834fbdaeb6a5c0ce356..0b7d0c26559d999be4a9fdaaec2d4b2d733dcb4f 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.controller.cluster.access.client;
 
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.after;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -31,10 +31,10 @@ public class ReconnectingClientConnectionTest
         extends AbstractClientConnectionTest<ReconnectingClientConnection<BackendInfo>, BackendInfo> {
 
     @Test
-    public void testCheckTimeoutConnectionTimedout() throws Exception {
+    public void testCheckTimeoutConnectionTimedout() {
         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 long now = context.ticker().read() + ConnectedClientConnection.DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS;
         final Optional<Long> timeout = connection.checkTimeout(now);
         Assert.assertNotNull(timeout);
         Assert.assertTrue(timeout.isPresent());
@@ -42,31 +42,32 @@ public class ReconnectingClientConnectionTest
 
     @Override
     protected ReconnectingClientConnection<BackendInfo> createConnection() {
-        final BackendInfo backend = new BackendInfo(backendProbe.ref(), 0L, ABIVersion.BORON, 10);
-
-        final ConnectedClientConnection<BackendInfo> oldConnection =
-                new ConnectedClientConnection<>(context, 0L, backend);
-        return new ReconnectingClientConnection<>(oldConnection, mock(RequestException.class));
+        final BackendInfo backend = new BackendInfo(backendProbe.ref(), "test", 0L, ABIVersion.BORON, 10);
+        final ConnectingClientConnection<BackendInfo> connectingConn = new ConnectingClientConnection<>(context, 0L,
+                backend.getName());
+        final ConnectedClientConnection<BackendInfo> connectedConn =
+                new ConnectedClientConnection<>(connectingConn, backend);
+        return new ReconnectingClientConnection<>(connectedConn, mock(RequestException.class));
     }
 
     @Override
     @Test
-    public void testReconnectConnection() throws Exception {
+    public void testReconnectConnection() {
         final ClientActorBehavior<BackendInfo> behavior = mock(ClientActorBehavior.class);
         Assert.assertSame(behavior, connection.lockedReconnect(behavior, mock(RequestException.class)));
     }
 
     @Override
     @Test
-    public void testSendRequestReceiveResponse() throws Exception {
+    public void testSendRequestReceiveResponse() {
         final Consumer<Response<?, ?>> callback = mock(Consumer.class);
         final Request<?, ?> request = createRequest(replyToProbe.ref());
         connection.sendRequest(request, callback);
-        backendProbe.expectNoMsg();
+        backendProbe.expectNoMessage();
         final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(CLIENT_ID, 0L);
         final RequestSuccess<?, ?> message = new TransactionAbortSuccess(new TransactionIdentifier(historyId, 0L), 0L);
         final ResponseEnvelope<?> envelope = new SuccessEnvelope(message, 0L, 0L, 0L);
         connection.receiveResponse(envelope);
         verify(callback, after(1000).never()).accept(any());
     }
-}
\ No newline at end of file
+}