Teach sal-remoterpc-connector to route actions
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / registry / mbeans / RemoteRpcRegistryMXBeanImplTest.java
index 8b23154232e59613301ff03eb76393816aa34bbe..dbeccb24564cdcb345e885da0203ffadfb42c1ba 100644 (file)
@@ -10,10 +10,11 @@ package org.opendaylight.controller.remote.rpc.registry.mbeans;
 import akka.actor.ActorRef;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
+import akka.dispatch.Dispatchers;
 import akka.testkit.TestActorRef;
 import akka.testkit.javadsl.TestKit;
+import akka.util.Timeout;
 import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -23,9 +24,10 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig;
+import org.opendaylight.controller.remote.rpc.RemoteOpsProviderConfig;
 import org.opendaylight.controller.remote.rpc.registry.RpcRegistry;
+import org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -42,7 +44,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     private RemoteRpcRegistryMXBeanImpl mxBean;
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         system = ActorSystem.create("test");
 
         final DOMRpcIdentifier emptyRpcIdentifier = DOMRpcIdentifier.create(
@@ -52,25 +54,26 @@ public class RemoteRpcRegistryMXBeanImplTest {
 
         buckets = Lists.newArrayList(emptyRpcIdentifier, localRpcIdentifier);
 
-        final RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder("system").build();
+        final RemoteOpsProviderConfig config = new RemoteOpsProviderConfig.Builder("system").build();
         final TestKit invoker = new TestKit(system);
         final TestKit registrar = new TestKit(system);
         final TestKit supervisor = new TestKit(system);
-        final Props props = RpcRegistry.props(config, invoker.getRef(), registrar.getRef());
+        final Props props = RpcRegistry.props(config, invoker.getRef(), registrar.getRef())
+                .withDispatcher(Dispatchers.DefaultDispatcherId());
         testActor = new TestActorRef<>(system, props, supervisor.getRef(), "testActor");
-        final RpcRegistry rpcRegistry = testActor.underlyingActor();
 
-        mxBean = new RemoteRpcRegistryMXBeanImpl(rpcRegistry);
-        Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
+        final Timeout timeout = Timeout.apply(10, TimeUnit.SECONDS);
+        mxBean = new RemoteRpcRegistryMXBeanImpl(new BucketStoreAccess(testActor, system.dispatcher(), timeout),
+                timeout);
     }
 
     @After
-    public void tearDown() throws Exception {
+    public void tearDown() {
         TestKit.shutdownActorSystem(system, Boolean.TRUE);
     }
 
     @Test
-    public void testGetGlobalRpcEmptyBuckets() throws Exception {
+    public void testGetGlobalRpcEmptyBuckets() {
         final Set<String> globalRpc = mxBean.getGlobalRpc();
 
         Assert.assertNotNull(globalRpc);
@@ -78,7 +81,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testGetGlobalRpc() throws Exception {
+    public void testGetGlobalRpc() {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Set<String> globalRpc = mxBean.getGlobalRpc();
 
@@ -90,7 +93,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testGetLocalRegisteredRoutedRpcEmptyBuckets() throws Exception {
+    public void testGetLocalRegisteredRoutedRpcEmptyBuckets() {
         final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
 
         Assert.assertNotNull(localRegisteredRoutedRpc);
@@ -98,7 +101,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testGetLocalRegisteredRoutedRpc() throws Exception {
+    public void testGetLocalRegisteredRoutedRpc() {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Set<String> localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc();
 
@@ -111,7 +114,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testFindRpcByNameEmptyBuckets() throws Exception {
+    public void testFindRpcByNameEmptyBuckets() {
         final Map<String, String> rpcByName = mxBean.findRpcByName("");
 
         Assert.assertNotNull(rpcByName);
@@ -119,7 +122,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testFindRpcByName() throws Exception {
+    public void testFindRpcByName() {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Map<String, String> rpcByName = mxBean.findRpcByName("");
 
@@ -129,7 +132,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testFindRpcByRouteEmptyBuckets() throws Exception {
+    public void testFindRpcByRouteEmptyBuckets() {
         final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
 
         Assert.assertNotNull(rpcByRoute);
@@ -137,7 +140,7 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testFindRpcByRoute() throws Exception {
+    public void testFindRpcByRoute() {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final Map<String, String> rpcByRoute = mxBean.findRpcByRoute("");
 
@@ -147,13 +150,13 @@ public class RemoteRpcRegistryMXBeanImplTest {
     }
 
     @Test
-    public void testGetBucketVersionsEmptyBuckets() throws Exception {
+    public void testGetBucketVersionsEmptyBuckets() {
         final String bucketVersions = mxBean.getBucketVersions();
         Assert.assertEquals(Collections.EMPTY_MAP.toString(), bucketVersions);
     }
 
     @Test
-    public void testGetBucketVersions() throws Exception {
+    public void testGetBucketVersions() {
         testActor.tell(new RpcRegistry.Messages.AddOrUpdateRoutes(Lists.newArrayList(buckets)), ActorRef.noSender());
         final String bucketVersions = mxBean.getBucketVersions();