Migrate most of CDS to use java.util.Optional
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / TestActorFactory.java
index 639436d026c04c5c96169b3fc330a120484896ba..c71c8b7de4fd8f204aa7667eea5103644527d0d5 100644 (file)
@@ -5,17 +5,8 @@
  * 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.cluster.raft;
 
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
 import akka.actor.Actor;
 import akka.actor.ActorIdentity;
 import akka.actor.ActorRef;
@@ -26,8 +17,8 @@ import akka.actor.InvalidActorNameException;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.pattern.Patterns;
-import akka.testkit.JavaTestKit;
 import akka.testkit.TestActorRef;
+import akka.testkit.javadsl.TestKit;
 import akka.util.Timeout;
 import com.google.common.base.Stopwatch;
 import com.google.common.util.concurrent.Uninterruptibles;
@@ -160,7 +151,7 @@ public class TestActorFactory implements AutoCloseable {
                 ActorSelection actorSelection = system.actorSelection(actorRef.path().toString());
                 Future<Object> future = Patterns.ask(actorSelection, new Identify(""), timeout);
                 ActorIdentity reply = (ActorIdentity)Await.result(future, timeout.duration());
-                Assert.assertNotNull("Identify returned null", reply.getRef());
+                Assert.assertTrue("Identify returned non-present", reply.getActorRef().isPresent());
                 return;
             } catch (Exception | AssertionError e) {
                 Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
@@ -181,15 +172,15 @@ public class TestActorFactory implements AutoCloseable {
         return prefix + actorCount++;
     }
 
-    public void killActor(ActorRef actor, JavaTestKit kit) {
+    public void killActor(ActorRef actor, TestKit kit) {
         killActor(actor, kit, true);
     }
 
-    private void killActor(ActorRef actor, JavaTestKit kit, boolean remove) {
+    private void killActor(ActorRef actor, TestKit kit, boolean remove) {
         LOG.info("Killing actor {}", actor);
         kit.watch(actor);
         actor.tell(PoisonPill.getInstance(), ActorRef.noSender());
-        kit.expectTerminated(JavaTestKit.duration("5 seconds"), actor);
+        kit.expectTerminated(kit.duration("5 seconds"), actor);
 
         if (remove) {
             createdActors.remove(actor);
@@ -202,7 +193,7 @@ public class TestActorFactory implements AutoCloseable {
 
     @Override
     public void close() {
-        JavaTestKit kit = new JavaTestKit(system);
+        TestKit kit = new TestKit(system);
         for (ActorRef actor : createdActors) {
             killActor(actor, kit, false);
         }