Teach sal-remoterpc-connector to route actions
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / registry / gossip / GossiperTest.java
index 9fccb069437a2a33b171cbd3f309b186b42f4f08..896c0245393f22374f5077cacbe88680f58159cc 100644 (file)
@@ -20,8 +20,8 @@ import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
 import akka.actor.Address;
 import akka.actor.Props;
 import akka.actor.ActorSystem;
 import akka.actor.Address;
 import akka.actor.Props;
-import akka.testkit.JavaTestKit;
 import akka.testkit.TestActorRef;
 import akka.testkit.TestActorRef;
+import akka.testkit.javadsl.TestKit;
 import com.typesafe.config.ConfigFactory;
 import java.util.Map;
 import org.junit.After;
 import com.typesafe.config.ConfigFactory;
 import java.util.Map;
 import org.junit.After;
@@ -29,10 +29,8 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig;
+import org.opendaylight.controller.remote.rpc.RemoteOpsProviderConfig;
 import org.opendaylight.controller.remote.rpc.TerminationMonitor;
 import org.opendaylight.controller.remote.rpc.TerminationMonitor;
-import org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipEnvelope;
-import org.opendaylight.controller.remote.rpc.registry.gossip.Messages.GossiperMessages.GossipStatus;
 
 
 public class GossiperTest {
 
 
 public class GossiperTest {
@@ -43,7 +41,7 @@ public class GossiperTest {
     private Gossiper mockGossiper;
 
     @BeforeClass
     private Gossiper mockGossiper;
 
     @BeforeClass
-    public static void setup() throws InterruptedException {
+    public static void setup() {
         system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("unit-test"));
         system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");
 
         system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("unit-test"));
         system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");
 
@@ -52,7 +50,7 @@ public class GossiperTest {
 
     @AfterClass
     public static void teardown() {
 
     @AfterClass
     public static void teardown() {
-        JavaTestKit.shutdownActorSystem(system);
+        TestKit.shutdownActorSystem(system);
     }
 
     @Before
     }
 
     @Before
@@ -63,7 +61,6 @@ public class GossiperTest {
     @After
     public void resetMocks() {
         reset(mockGossiper);
     @After
     public void resetMocks() {
         reset(mockGossiper);
-
     }
 
     @Test
     }
 
     @Test
@@ -85,7 +82,6 @@ public class GossiperTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testReceiveGossipStatus_WhenSenderIsNonMemberShouldIgnore() {
     @SuppressWarnings("unchecked")
     @Test
     public void testReceiveGossipStatus_WhenSenderIsNonMemberShouldIgnore() {
-
         Address nonMember = new Address("tcp", "non-member");
         GossipStatus remoteStatus = new GossipStatus(nonMember, mock(Map.class));
 
         Address nonMember = new Address("tcp", "non-member");
         GossipStatus remoteStatus = new GossipStatus(nonMember, mock(Map.class));
 
@@ -95,14 +91,12 @@ public class GossiperTest {
         verify(mockGossiper, times(0)).getSender();
     }
 
         verify(mockGossiper, times(0)).getSender();
     }
 
-    @SuppressWarnings({ "unchecked", "rawtypes" })
+    @SuppressWarnings("unchecked")
     @Test
     public void testReceiveGossipWhenNotAddressedToSelfShouldIgnore() {
     @Test
     public void testReceiveGossipWhenNotAddressedToSelfShouldIgnore() {
-        Address notSelf = new Address("tcp", "not-self");
-
-        GossipEnvelope envelope = new GossipEnvelope(notSelf, notSelf, mock(Map.class));
         doNothing().when(mockGossiper).updateRemoteBuckets(anyMap());
         doNothing().when(mockGossiper).updateRemoteBuckets(anyMap());
-        mockGossiper.receiveGossip(envelope);
+        Address notSelf = new Address("tcp", "not-self");
+        mockGossiper.receiveGossip(new GossipEnvelope(notSelf, notSelf, mock(Map.class)));
         verify(mockGossiper, times(0)).updateRemoteBuckets(anyMap());
     }
 
         verify(mockGossiper, times(0)).updateRemoteBuckets(anyMap());
     }
 
@@ -112,7 +106,10 @@ public class GossiperTest {
      * @return instance of Gossiper class
      */
     private static Gossiper createGossiper() {
      * @return instance of Gossiper class
      */
     private static Gossiper createGossiper() {
-        final Props props = Gossiper.testProps(new RemoteRpcProviderConfig(system.settings().config()));
+        final RemoteOpsProviderConfig config =
+                new RemoteOpsProviderConfig.Builder("unit-test")
+                        .withConfigReader(ConfigFactory::load).build();
+        final Props props = Gossiper.testProps(config);
         final TestActorRef<Gossiper> testRef = TestActorRef.create(system, props, "testGossiper");
 
         return testRef.underlyingActor();
         final TestActorRef<Gossiper> testRef = TestActorRef.create(system, props, "testGossiper");
 
         return testRef.underlyingActor();