X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fmessaging%2FAbstractMessagingTest.java;h=b0e0c55f18e4428557e029738c10df6dc3b38935;hb=refs%2Fchanges%2F39%2F74339%2F5;hp=3d93755ee1a67ae2d7edd3e3955c483a7c0ad7ec;hpb=3582bb6dbc506b0c79dd3e4b4f791f4e17cd3103;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java index 3d93755ee1..b0e0c55f18 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java @@ -13,8 +13,8 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import com.google.common.io.ByteSource; import java.io.IOException; import java.io.InputStream; @@ -50,7 +50,7 @@ public class AbstractMessagingTest { protected InputStream mockInputStream; @BeforeClass - public static void setupClass() throws IOException { + public static void setupClass() { ACTOR_SYSTEM = ActorSystem.create("test"); } @@ -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(); @@ -76,6 +71,16 @@ public class AbstractMessagingTest { @AfterClass public static void tearDownClass() { - JavaTestKit.shutdownActorSystem(ACTOR_SYSTEM, Boolean.TRUE); + TestKit.shutdownActorSystem(ACTOR_SYSTEM, true); + } + + void setupMockFiledBackedStream(final FileBackedOutputStream mockOutputStream) throws IOException { + doNothing().when(mockOutputStream).write(any(byte[].class), anyInt(), anyInt()); + doNothing().when(mockOutputStream).write(any(byte[].class)); + doNothing().when(mockOutputStream).write(anyInt()); + doNothing().when(mockOutputStream).close(); + doNothing().when(mockOutputStream).cleanup(); + doNothing().when(mockOutputStream).flush(); + doReturn(mockByteSource).when(mockOutputStream).asByteSource(); } }