X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futils%2FActorContextTest.java;h=2ca2192ef7a4df655e5e584b02ae7b7445dad8cc;hb=refs%2Fchanges%2F74%2F75374%2F41;hp=2b8b2bb528bd6e4bc2019cfdb8d6d02ee82df502;hpb=bf887b0ecebf65746684691a0cd4d448ad8606f1;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java index 2b8b2bb528..2ca2192ef7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java @@ -34,6 +34,7 @@ import com.google.common.base.Optional; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.typesafe.config.ConfigFactory; +import java.time.Duration; import java.util.Arrays; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -64,7 +65,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import scala.concurrent.Await; import scala.concurrent.Future; -import scala.concurrent.duration.Duration; import scala.concurrent.duration.FiniteDuration; public class ActorContextTest extends AbstractActorTest { @@ -143,7 +143,7 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testFindLocalShardWithShardFound() { final TestKit testKit = new TestKit(getSystem()); - testKit.within(testKit.duration("1 seconds"), () -> { + testKit.within(Duration.ofSeconds(1), () -> { ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class)); ActorRef shardManagerActorRef = getSystem().actorOf(MockShardManager.props(true, shardActorRef)); @@ -200,7 +200,7 @@ public class ActorContextTest extends AbstractActorTest { Future future = actorContext.executeOperationAsync(actor, "hello"); - Object result = Await.result(future, Duration.create(3, TimeUnit.SECONDS)); + Object result = Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS)); assertEquals("Result", "hello", result); } @@ -210,62 +210,60 @@ public class ActorContextTest extends AbstractActorTest { ActorContext actorContext = null; actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(false, actorContext.isPathLocal(null)); - assertEquals(false, actorContext.isPathLocal("")); + assertFalse(actorContext.isPathLocal(null)); + assertFalse(actorContext.isPathLocal("")); clusterWrapper.setSelfAddress(null); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(false, actorContext.isPathLocal("")); + assertFalse(actorContext.isPathLocal("")); // even if the path is in local format, match the primary path (first 3 elements) and return true clusterWrapper.setSelfAddress(new Address("akka", "test")); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(true, actorContext.isPathLocal("akka://test/user/$a")); + assertTrue(actorContext.isPathLocal("akka://test/user/$a")); clusterWrapper.setSelfAddress(new Address("akka", "test")); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(true, actorContext.isPathLocal("akka://test/user/$a")); + assertTrue(actorContext.isPathLocal("akka://test/user/$a")); clusterWrapper.setSelfAddress(new Address("akka", "test")); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(true, actorContext.isPathLocal("akka://test/user/token2/token3/$a")); + assertTrue(actorContext.isPathLocal("akka://test/user/token2/token3/$a")); // self address of remote format,but Tx path local format. clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(true, actorContext.isPathLocal( - "akka://system/user/shardmanager/shard/transaction")); + assertTrue(actorContext.isPathLocal("akka://system/user/shardmanager/shard/transaction")); // self address of local format,but Tx path remote format. clusterWrapper.setSelfAddress(new Address("akka", "system")); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(false, actorContext.isPathLocal( - "akka://system@127.0.0.1:2550/user/shardmanager/shard/transaction")); + assertFalse(actorContext.isPathLocal("akka://system@127.0.0.1:2550/user/shardmanager/shard/transaction")); //local path but not same clusterWrapper.setSelfAddress(new Address("akka", "test")); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(true, actorContext.isPathLocal("akka://test1/user/$a")); + assertTrue(actorContext.isPathLocal("akka://test1/user/$a")); //ip and port same clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(true, actorContext.isPathLocal("akka://system@127.0.0.1:2550/")); + assertTrue(actorContext.isPathLocal("akka://system@127.0.0.1:2550/")); // forward-slash missing in address clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(false, actorContext.isPathLocal("akka://system@127.0.0.1:2550")); + assertFalse(actorContext.isPathLocal("akka://system@127.0.0.1:2550")); //ips differ clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(false, actorContext.isPathLocal("akka://system@127.1.0.1:2550/")); + assertFalse(actorContext.isPathLocal("akka://system@127.1.0.1:2550/")); //ports differ clusterWrapper.setSelfAddress(new Address("akka", "system", "127.0.0.1", 2550)); actorContext = new ActorContext(getSystem(), null, clusterWrapper, mock(Configuration.class)); - assertEquals(false, actorContext.isPathLocal("akka://system@127.0.0.1:2551/")); + assertFalse(actorContext.isPathLocal("akka://system@127.0.0.1:2551/")); } @Test @@ -309,7 +307,7 @@ public class ActorContextTest extends AbstractActorTest { actorContext.setDatastoreContext(mockContextFactory); - testKit.expectMsgClass(testKit.duration("5 seconds"), DatastoreContextFactory.class); + testKit.expectMsgClass(Duration.ofSeconds(5), DatastoreContextFactory.class); Assert.assertSame("getDatastoreContext", newContext, actorContext.getDatastoreContext()); @@ -338,10 +336,10 @@ public class ActorContextTest extends AbstractActorTest { }; Future foobar = actorContext.findPrimaryShardAsync("foobar"); - PrimaryShardInfo actual = Await.result(foobar, Duration.apply(5000, TimeUnit.MILLISECONDS)); + PrimaryShardInfo actual = Await.result(foobar, FiniteDuration.apply(5000, TimeUnit.MILLISECONDS)); assertNotNull(actual); - assertEquals("LocalShardDataTree present", false, actual.getLocalShardDataTree().isPresent()); + assertFalse("LocalShardDataTree present", actual.getLocalShardDataTree().isPresent()); assertTrue("Unexpected PrimaryShardActor path " + actual.getPrimaryShardActor().path(), expPrimaryPath.endsWith(actual.getPrimaryShardActor().pathString())); assertEquals("getPrimaryShardVersion", expPrimaryVersion, actual.getPrimaryShardVersion()); @@ -379,10 +377,10 @@ public class ActorContextTest extends AbstractActorTest { }; Future foobar = actorContext.findPrimaryShardAsync("foobar"); - PrimaryShardInfo actual = Await.result(foobar, Duration.apply(5000, TimeUnit.MILLISECONDS)); + PrimaryShardInfo actual = Await.result(foobar, FiniteDuration.apply(5000, TimeUnit.MILLISECONDS)); assertNotNull(actual); - assertEquals("LocalShardDataTree present", true, actual.getLocalShardDataTree().isPresent()); + assertTrue("LocalShardDataTree present", actual.getLocalShardDataTree().isPresent()); assertSame("LocalShardDataTree", mockDataTree, actual.getLocalShardDataTree().get()); assertTrue("Unexpected PrimaryShardActor path " + actual.getPrimaryShardActor().path(), expPrimaryPath.endsWith(actual.getPrimaryShardActor().pathString())); @@ -431,7 +429,7 @@ public class ActorContextTest extends AbstractActorTest { Future foobar = actorContext.findPrimaryShardAsync("foobar"); try { - Await.result(foobar, Duration.apply(100, TimeUnit.MILLISECONDS)); + Await.result(foobar, FiniteDuration.apply(100, TimeUnit.MILLISECONDS)); fail("Expected" + expectedException.getClass().toString()); } catch (Exception e) { if (!expectedException.getClass().isInstance(e)) {