X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2Fregistry%2FRpcRegistryTest.java;h=d32e8d8a6ea8522ca2faec9a4a5d4fac7cdb56f7;hb=refs%2Fchanges%2F74%2F75374%2F41;hp=d9c686c9abbede1493c9ce4dd6de601875defb06;hpb=e9fc7e7ed2b13d274518d6a872ab67749ef4507a;p=controller.git
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java
index d9c686c9ab..d32e8d8a6e 100644
--- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java
+++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java
@@ -5,9 +5,11 @@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.remote.rpc.registry;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_ALL_BUCKETS;
import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_BUCKET_VERSIONS;
@@ -26,6 +28,7 @@ import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Uninterruptibles;
import com.typesafe.config.ConfigFactory;
import java.net.URI;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -37,24 +40,21 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.AddOrUpdateRoutes;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.RemoveRoutes;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints;
import org.opendaylight.controller.remote.rpc.registry.RpcRegistry.RemoteRpcEndpoint;
import org.opendaylight.controller.remote.rpc.registry.gossip.Bucket;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.Duration;
-import scala.concurrent.duration.FiniteDuration;
public class RpcRegistryTest {
private static final Logger LOG = LoggerFactory.getLogger(RpcRegistryTest.class);
@@ -76,7 +76,7 @@ public class RpcRegistryTest {
private int routeIdCounter = 1;
@BeforeClass
- public static void staticSetup() throws InterruptedException {
+ public static void staticSetup() {
AkkaConfigurationReader reader = ConfigFactory::load;
RemoteRpcProviderConfig config1 = new RemoteRpcProviderConfig.Builder("memberA").gossipTickInterval("200ms")
@@ -173,7 +173,7 @@ public class RpcRegistryTest {
* deleted
*/
@Test
- public void testAddRemoveRpcOnSameNode() throws Exception {
+ public void testAddRemoveRpcOnSameNode() {
LOG.info("testAddRemoveRpcOnSameNode starting");
Address nodeAddress = node1.provider().getDefaultAddress();
@@ -191,7 +191,7 @@ public class RpcRegistryTest {
verifyBucket(buckets.get(nodeAddress), addedRouteIds);
Map
versions = retrieveVersions(registry1, testKit);
- Assert.assertEquals("Version for bucket " + nodeAddress, (Long) buckets.get(nodeAddress).getVersion(),
+ assertEquals("Version for bucket " + nodeAddress, (Long) buckets.get(nodeAddress).getVersion(),
versions.get(nodeAddress));
// Now remove rpc
@@ -210,7 +210,7 @@ public class RpcRegistryTest {
* 1 node, ensure 2nd node gets updated
*/
@Test
- public void testRpcAddRemoveInCluster() throws Exception {
+ public void testRpcAddRemoveInCluster() {
LOG.info("testRpcAddRemoveInCluster starting");
@@ -262,21 +262,21 @@ public class RpcRegistryTest {
* Three node cluster. Register rpc on 2 nodes. Ensure 3rd gets updated.
*/
@Test
- public void testRpcAddedOnMultiNodes() throws Exception {
+ public void testRpcAddedOnMultiNodes() {
final TestKit testKit = new TestKit(node3);
// Add rpc on node 1
List addedRouteIds1 = createRouteIds();
registry1.tell(new AddOrUpdateRoutes(addedRouteIds1), ActorRef.noSender());
- final UpdateRemoteEndpoints req1 = registrar3.expectMsgClass(Duration.create(3, TimeUnit.SECONDS),
+ final UpdateRemoteEndpoints req1 = registrar3.expectMsgClass(Duration.ofSeconds(3),
UpdateRemoteEndpoints.class);
// Add rpc on node 2
List addedRouteIds2 = createRouteIds();
registry2.tell(new AddOrUpdateRoutes(addedRouteIds2), ActorRef.noSender());
- final UpdateRemoteEndpoints req2 = registrar3.expectMsgClass(Duration.create(3, TimeUnit.SECONDS),
+ final UpdateRemoteEndpoints req2 = registrar3.expectMsgClass(Duration.ofSeconds(3),
UpdateRemoteEndpoints.class);
Address node2Address = node2.provider().getDefaultAddress();
Address node1Address = node1.provider().getDefaultAddress();
@@ -288,9 +288,9 @@ public class RpcRegistryTest {
verifyBucket(buckets.get(node2Address), addedRouteIds2);
Map versions = retrieveVersions(registry3, testKit);
- Assert.assertEquals("Version for bucket " + node1Address, (Long) buckets.get(node1Address).getVersion(),
+ assertEquals("Version for bucket " + node1Address, (Long) buckets.get(node1Address).getVersion(),
versions.get(node1Address));
- Assert.assertEquals("Version for bucket " + node2Address, (Long) buckets.get(node2Address).getVersion(),
+ assertEquals("Version for bucket " + node2Address, (Long) buckets.get(node2Address).getVersion(),
versions.get(node2Address));
assertEndpoints(req1, node1Address, invoker1);
@@ -300,38 +300,38 @@ public class RpcRegistryTest {
private static void assertEndpoints(final UpdateRemoteEndpoints msg, final Address address, final TestKit invoker) {
final Map> endpoints = msg.getEndpoints();
- Assert.assertEquals(1, endpoints.size());
+ assertEquals(1, endpoints.size());
final Optional maybeEndpoint = endpoints.get(address);
- Assert.assertNotNull(maybeEndpoint);
- Assert.assertTrue(maybeEndpoint.isPresent());
+ assertNotNull(maybeEndpoint);
+ assertTrue(maybeEndpoint.isPresent());
final RemoteRpcEndpoint endpoint = maybeEndpoint.get();
final ActorRef router = endpoint.getRouter();
- Assert.assertNotNull(router);
+ assertNotNull(router);
router.tell("hello", ActorRef.noSender());
- final String s = invoker.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), String.class);
- Assert.assertEquals("hello", s);
+ final String s = invoker.expectMsgClass(Duration.ofSeconds(3), String.class);
+ assertEquals("hello", s);
}
private static Map retrieveVersions(final ActorRef bucketStore, final TestKit testKit) {
bucketStore.tell(GET_BUCKET_VERSIONS, testKit.getRef());
@SuppressWarnings("unchecked")
- final Map reply = testKit.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), Map.class);
+ final Map reply = testKit.expectMsgClass(Duration.ofSeconds(3), Map.class);
return reply;
}
private static void verifyBucket(final Bucket bucket, final List expRouteIds) {
RoutingTable table = bucket.getData();
- Assert.assertNotNull("Bucket RoutingTable is null", table);
+ assertNotNull("Bucket RoutingTable is null", table);
for (DOMRpcIdentifier r : expRouteIds) {
if (!table.contains(r)) {
- Assert.fail("RoutingTable does not contain " + r + ". Actual: " + table);
+ fail("RoutingTable does not contain " + r + ". Actual: " + table);
}
}
- Assert.assertEquals("RoutingTable size", expRouteIds.size(), table.size());
+ assertEquals("RoutingTable size", expRouteIds.size(), table.size());
}
private static Map> retrieveBuckets(final ActorRef bucketStore,
@@ -340,8 +340,7 @@ public class RpcRegistryTest {
while (true) {
bucketStore.tell(GET_ALL_BUCKETS, testKit.getRef());
@SuppressWarnings("unchecked")
- Map> buckets = testKit.expectMsgClass(Duration.create(3, TimeUnit.SECONDS),
- Map.class);
+ Map> buckets = testKit.expectMsgClass(Duration.ofSeconds(3), Map.class);
boolean foundAll = true;
for (Address addr : addresses) {
@@ -357,8 +356,7 @@ public class RpcRegistryTest {
}
if (++numTries >= 50) {
- Assert.fail("Missing expected buckets for addresses: " + Arrays.toString(addresses)
- + ", Actual: " + buckets);
+ fail("Missing expected buckets for addresses: " + Arrays.toString(addresses) + ", Actual: " + buckets);
}
Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
@@ -381,25 +379,24 @@ public class RpcRegistryTest {
ActorRef.noSender());
}
- FiniteDuration duration = Duration.create(3, TimeUnit.SECONDS);
int numTries = 0;
while (true) {
registry1.tell(GET_ALL_BUCKETS, testKit.getRef());
@SuppressWarnings("unchecked")
- Map> buckets = testKit.expectMsgClass(duration, Map.class);
+ Map> buckets = testKit.expectMsgClass(Duration.ofSeconds(3), Map.class);
Bucket localBucket = buckets.values().iterator().next();
RoutingTable table = localBucket.getData();
if (table != null && table.size() == nRoutes) {
for (DOMRpcIdentifier r : added) {
- Assert.assertTrue("RoutingTable contains " + r, table.contains(r));
+ assertTrue("RoutingTable contains " + r, table.contains(r));
}
break;
}
if (++numTries >= 50) {
- Assert.fail("Expected # routes: " + nRoutes + ", Actual: " + table.size());
+ fail("Expected # routes: " + nRoutes + ", Actual: " + table.size());
}
Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);