Slice front-end request messages
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / messaging / AbstractMessagingTest.java
index 3d93755ee1a67ae2d7edd3e3955c483a7c0ad7ec..5ff1f38e838d297488b4f42b88205bd45fd6a220 100644 (file)
@@ -59,12 +59,7 @@ public class AbstractMessagingTest {
         MockitoAnnotations.initMocks(this);
 
         doReturn(mockFiledBackedStream).when(mockFiledBackedStreamFactory).newInstance();
-        doNothing().when(mockFiledBackedStream).write(any(byte[].class), anyInt(), anyInt());
-        doNothing().when(mockFiledBackedStream).write(any(byte[].class));
-        doNothing().when(mockFiledBackedStream).write(anyInt());
-        doNothing().when(mockFiledBackedStream).close();
-        doNothing().when(mockFiledBackedStream).cleanup();
-        doNothing().when(mockFiledBackedStream).flush();
+        setupMockFiledBackedStream(mockFiledBackedStream);
         doReturn(mockByteSource).when(mockFiledBackedStream).asByteSource();
 
         doReturn(mockInputStream).when(mockByteSource).openStream();
@@ -78,4 +73,14 @@ public class AbstractMessagingTest {
     public static void tearDownClass() {
         JavaTestKit.shutdownActorSystem(ACTOR_SYSTEM, Boolean.TRUE);
     }
+
+    void setupMockFiledBackedStream(final FileBackedOutputStream mockFiledBackedStream) throws IOException {
+        doNothing().when(mockFiledBackedStream).write(any(byte[].class), anyInt(), anyInt());
+        doNothing().when(mockFiledBackedStream).write(any(byte[].class));
+        doNothing().when(mockFiledBackedStream).write(anyInt());
+        doNothing().when(mockFiledBackedStream).close();
+        doNothing().when(mockFiledBackedStream).cleanup();
+        doNothing().when(mockFiledBackedStream).flush();
+        doReturn(mockByteSource).when(mockFiledBackedStream).asByteSource();
+    }
 }