X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2Fregistry%2Fmbeans%2FRemoteRpcRegistryMXBeanImplTest.java;h=d445ae1e6e31e0567e829e0afe8a1f8e9ef86ccd;hp=b48d40bac81a2e629911ca3aee1b26f8969c0a9f;hb=91cbd66f53b89d89e419bf23e6969da1f8df137e;hpb=3eee17a3bbd0f7ca65aa812164b0fe3df7b79cfc diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java index b48d40bac8..d445ae1e6e 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java @@ -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.testkit.JavaTestKit; +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.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( @@ -53,24 +55,25 @@ public class RemoteRpcRegistryMXBeanImplTest { buckets = Lists.newArrayList(emptyRpcIdentifier, localRpcIdentifier); final RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder("system").build(); - final JavaTestKit invoker = new JavaTestKit(system); - final JavaTestKit registrar = new JavaTestKit(system); - final JavaTestKit supervisor = new JavaTestKit(system); - final Props props = RpcRegistry.props(config, invoker.getRef(), registrar.getRef()); + 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()) + .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 { - JavaTestKit.shutdownActorSystem(system, null, Boolean.TRUE); + public void tearDown() { + TestKit.shutdownActorSystem(system, Boolean.TRUE); } @Test - public void testGetGlobalRpcEmptyBuckets() throws Exception { + public void testGetGlobalRpcEmptyBuckets() { final Set 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 globalRpc = mxBean.getGlobalRpc(); @@ -90,7 +93,7 @@ public class RemoteRpcRegistryMXBeanImplTest { } @Test - public void testGetLocalRegisteredRoutedRpcEmptyBuckets() throws Exception { + public void testGetLocalRegisteredRoutedRpcEmptyBuckets() { final Set 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 localRegisteredRoutedRpc = mxBean.getLocalRegisteredRoutedRpc(); @@ -111,7 +114,7 @@ public class RemoteRpcRegistryMXBeanImplTest { } @Test - public void testFindRpcByNameEmptyBuckets() throws Exception { + public void testFindRpcByNameEmptyBuckets() { final Map 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 rpcByName = mxBean.findRpcByName(""); @@ -129,7 +132,7 @@ public class RemoteRpcRegistryMXBeanImplTest { } @Test - public void testFindRpcByRouteEmptyBuckets() throws Exception { + public void testFindRpcByRouteEmptyBuckets() { final Map 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 rpcByRoute = mxBean.findRpcByRoute(""); @@ -147,16 +150,16 @@ 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(); Assert.assertTrue(bucketVersions.contains(testActor.provider().getDefaultAddress().toString())); } -} \ No newline at end of file +}