Convert CDS implementation to use msdal APIs
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / DataChangeListenerRegistrationProxyTest.java
index 64f088f1369d6fac8b1aab9c6a601ee64982d586..26b9aa3e94d7c94b8fc92036cbb05fa02b7b68c2 100644 (file)
@@ -19,7 +19,7 @@ import akka.actor.Props;
 import akka.actor.Terminated;
 import akka.dispatch.ExecutionContexts;
 import akka.dispatch.Futures;
-import akka.testkit.JavaTestKit;
+import akka.testkit.javadsl.TestKit;
 import akka.util.Timeout;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
@@ -28,6 +28,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.cluster.common.actor.Dispatchers;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.exceptions.NotInitializedException;
 import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration;
@@ -37,7 +38,6 @@ import org.opendaylight.controller.cluster.datastore.messages.LocalShardNotFound
 import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListener;
 import org.opendaylight.controller.cluster.datastore.messages.RegisterDataTreeNotificationListenerReply;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
-import org.opendaylight.controller.cluster.datastore.utils.Dispatchers;
 import org.opendaylight.controller.cluster.raft.utils.DoNothingActor;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
@@ -71,7 +71,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
     @Test(timeout = 10000)
     public void testSuccessfulRegistration() {
-        new JavaTestKit(getSystem()) {
+        new TestKit(getSystem()) {
             {
                 ActorContext actorContext = new ActorContext(getSystem(), getRef(),
                         mock(ClusterWrapper.class), mock(Configuration.class));
@@ -81,13 +81,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -128,7 +122,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
     @Test(timeout = 10000)
     public void testSuccessfulRegistrationForClusteredListener() {
-        new JavaTestKit(getSystem()) {
+        new TestKit(getSystem()) {
             {
                 ActorContext actorContext = new ActorContext(getSystem(), getRef(),
                     mock(ClusterWrapper.class), mock(Configuration.class));
@@ -141,13 +135,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -188,7 +176,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
     @Test(timeout = 10000)
     public void testLocalShardNotFound() {
-        new JavaTestKit(getSystem()) {
+        new TestKit(getSystem()) {
             {
                 ActorContext actorContext = new ActorContext(getSystem(), getRef(),
                         mock(ClusterWrapper.class), mock(Configuration.class));
@@ -198,13 +186,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -221,7 +203,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
     @Test(timeout = 10000)
     public void testLocalShardNotInitialized() {
-        new JavaTestKit(getSystem()) {
+        new TestKit(getSystem()) {
             {
                 ActorContext actorContext = new ActorContext(getSystem(), getRef(),
                         mock(ClusterWrapper.class), mock(Configuration.class));
@@ -231,13 +213,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 final YangInstanceIdentifier path = YangInstanceIdentifier.of(TestModel.TEST_QNAME);
                 final DataChangeScope scope = AsyncDataBroker.DataChangeScope.ONE;
-                new Thread() {
-                    @Override
-                    public void run() {
-                        proxy.init(path, scope);
-                    }
-
-                }.start();
+                new Thread(() -> proxy.init(path, scope)).start();
 
                 FiniteDuration timeout = duration("5 seconds");
                 FindLocalShard findLocalShard = expectMsgClass(timeout, FindLocalShard.class);
@@ -245,13 +221,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
                 reply(new NotInitializedException("not initialized"));
 
-                new Within(duration("1 seconds")) {
-                    @Override
-                    protected void run() {
-                        expectNoMsg();
-                    }
-                };
-
+                expectNoMsg(duration("1 seconds"));
                 proxy.close();
             }
         };
@@ -259,7 +229,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
     @Test
     public void testFailedRegistration() {
-        new JavaTestKit(getSystem()) {
+        new TestKit(getSystem()) {
             {
                 ActorSystem mockActorSystem = mock(ActorSystem.class);
 
@@ -298,7 +268,7 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest {
 
     @Test
     public void testCloseBeforeRegistration() {
-        new JavaTestKit(getSystem()) {
+        new TestKit(getSystem()) {
             {
                 ActorContext actorContext = mock(ActorContext.class);