Remove unused exceptions
[controller.git] / opendaylight / md-sal / cds-access-client / src / test / java / org / opendaylight / controller / cluster / access / client / ConnectingClientConnectionTest.java
index b436429..911f349 100644 (file)
@@ -16,6 +16,7 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 
@@ -44,6 +45,7 @@ import org.opendaylight.controller.cluster.access.concepts.RequestEnvelope;
 import org.opendaylight.controller.cluster.access.concepts.RequestException;
 import org.opendaylight.controller.cluster.access.concepts.RequestFailure;
 import org.opendaylight.controller.cluster.access.concepts.Response;
+import org.opendaylight.controller.cluster.messaging.MessageSlicer;
 import org.opendaylight.yangtools.concepts.WritableIdentifier;
 import scala.concurrent.duration.FiniteDuration;
 
@@ -142,6 +144,11 @@ public class ConnectingClientConnectionTest {
         ticker.advance(ThreadLocalRandom.current().nextLong());
         doReturn(ticker).when(mockContext).ticker();
 
+        final ClientActorConfig mockConfig = AccessClientUtil.newMockClientActorConfig();
+        doReturn(mockConfig).when(mockContext).config();
+
+        doReturn(mock(MessageSlicer.class)).when(mockContext).messageSlicer();
+
         mockActor = TestProbe.apply(actorSystem);
         mockBackendInfo = new BackendInfo(mockActor.ref(), 0, ABIVersion.current(), 5);
         mockRequest = new MockRequest(mockIdentifier, mockReplyTo);
@@ -214,14 +221,14 @@ public class ConnectingClientConnectionTest {
     }
 
     @Test
-    public void testRunTimeoutEmpty() throws NoProgressException {
+    public void testRunTimeoutEmpty() {
         Optional<Long> ret = queue.checkTimeout(ticker.read());
         assertNotNull(ret);
         assertFalse(ret.isPresent());
     }
 
     @Test
-    public void testRunTimeoutWithoutShift() throws NoProgressException {
+    public void testRunTimeoutWithoutShift() {
         queue.sendRequest(mockRequest, mockCallback);
         Optional<Long> ret = queue.checkTimeout(ticker.read());
         assertNotNull(ret);
@@ -229,10 +236,10 @@ public class ConnectingClientConnectionTest {
     }
 
     @Test
-    public void testRunTimeoutWithTimeoutLess() throws NoProgressException {
+    public void testRunTimeoutWithTimeoutLess() {
         queue.sendRequest(mockRequest, mockCallback);
 
-        ticker.advance(AbstractClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS - 1);
+        ticker.advance(AbstractClientConnection.DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS - 1);
 
         Optional<Long> ret = queue.checkTimeout(ticker.read());
         assertNotNull(ret);
@@ -240,34 +247,34 @@ public class ConnectingClientConnectionTest {
     }
 
     @Test
-    public void testRunTimeoutWithTimeoutExact() throws NoProgressException {
+    public void testRunTimeoutWithTimeoutExact() {
         setupBackend();
 
         queue.sendRequest(mockRequest, mockCallback);
 
-        ticker.advance(AbstractClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS);
+        ticker.advance(AbstractClientConnection.DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS);
 
         Optional<Long> ret = queue.checkTimeout(ticker.read());
         assertNull(ret);
     }
 
     @Test
-    public void testRunTimeoutWithTimeoutMore() throws NoProgressException {
+    public void testRunTimeoutWithTimeoutMore() {
         setupBackend();
 
         queue.sendRequest(mockRequest, mockCallback);
 
-        ticker.advance(AbstractClientConnection.BACKEND_ALIVE_TIMEOUT_NANOS + 1);
+        ticker.advance(AbstractClientConnection.DEFAULT_BACKEND_ALIVE_TIMEOUT_NANOS + 1);
 
         Optional<Long> ret = queue.checkTimeout(ticker.read());
         assertNull(ret);
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    public void testRunTimeoutWithoutProgressExact() throws NoProgressException {
+    public void testRunTimeoutWithoutProgressExact() {
         queue.sendRequest(mockRequest, mockCallback);
 
-        ticker.advance(AbstractClientConnection.NO_PROGRESS_TIMEOUT_NANOS);
+        ticker.advance(AbstractClientConnection.DEFAULT_NO_PROGRESS_TIMEOUT_NANOS);
 
         // Kaboom
         queue.runTimer((ClientActorBehavior) mockBehavior);
@@ -275,10 +282,10 @@ public class ConnectingClientConnectionTest {
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    public void testRunTimeoutWithoutProgressMore() throws NoProgressException {
+    public void testRunTimeoutWithoutProgressMore() {
         queue.sendRequest(mockRequest, mockCallback);
 
-        ticker.advance(AbstractClientConnection.NO_PROGRESS_TIMEOUT_NANOS + 1);
+        ticker.advance(AbstractClientConnection.DEFAULT_NO_PROGRESS_TIMEOUT_NANOS + 1);
 
         // Kaboom
         queue.runTimer((ClientActorBehavior) mockBehavior);
@@ -286,8 +293,8 @@ public class ConnectingClientConnectionTest {
     }
 
     @Test
-    public void testRunTimeoutEmptyWithoutProgressExact() throws NoProgressException {
-        ticker.advance(AbstractClientConnection.NO_PROGRESS_TIMEOUT_NANOS);
+    public void testRunTimeoutEmptyWithoutProgressExact() {
+        ticker.advance(AbstractClientConnection.DEFAULT_NO_PROGRESS_TIMEOUT_NANOS);
 
         // No problem
         Optional<Long> ret = queue.checkTimeout(ticker.read());
@@ -296,8 +303,8 @@ public class ConnectingClientConnectionTest {
     }
 
     @Test
-    public void testRunTimeoutEmptyWithoutProgressMore() throws NoProgressException {
-        ticker.advance(AbstractClientConnection.NO_PROGRESS_TIMEOUT_NANOS + 1);
+    public void testRunTimeoutEmptyWithoutProgressMore() {
+        ticker.advance(AbstractClientConnection.DEFAULT_NO_PROGRESS_TIMEOUT_NANOS + 1);
 
         // No problem
         Optional<Long> ret = queue.checkTimeout(ticker.read());
@@ -337,7 +344,7 @@ public class ConnectingClientConnectionTest {
     }
 
     @Test
-    public void testProgressRecord() throws NoProgressException {
+    public void testProgressRecord() {
         setupBackend();
 
         queue.sendRequest(mockRequest, mockCallback);
@@ -346,17 +353,19 @@ public class ConnectingClientConnectionTest {
         queue.sendRequest(mockRequest2, mockCallback);
         queue.receiveResponse(mockResponseEnvelope);
 
-        ticker.advance(AbstractClientConnection.NO_PROGRESS_TIMEOUT_NANOS - 11);
+        ticker.advance(AbstractClientConnection.DEFAULT_NO_PROGRESS_TIMEOUT_NANOS - 11);
 
         Optional<Long> ret = queue.checkTimeout(ticker.read());
         assertNull(ret);
     }
 
     private void setupBackend() {
-        final ConnectedClientConnection<?> newConn = new ConnectedClientConnection<>(mockContext, mockCookie,
-                mockBackendInfo);
-        queue.setForwarder(new SimpleReconnectForwarder(newConn));
-        queue = newConn;
+        final ConnectingClientConnection<BackendInfo> connectingConn =
+                new ConnectingClientConnection<>(mockContext, mockCookie);
+        final ConnectedClientConnection<BackendInfo> connectedConn =
+                new ConnectedClientConnection<>(connectingConn, mockBackendInfo);
+        queue.setForwarder(new SimpleReconnectForwarder(connectedConn));
+        queue = connectedConn;
     }
 
     private void assertTransmit(final Request<?, ?> expected, final long sequence) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.