Fix intermittent PreLeaderScenarioTest failure 67/62767/4
authorTom Pantelis <tompantelis@gmail.com>
Wed, 6 Sep 2017 10:59:32 +0000 (06:59 -0400)
committerRobert Varga <nite@hq.sk>
Thu, 7 Sep 2017 10:39:50 +0000 (10:39 +0000)
testUnComittedEntryOnLeaderChange(org.opendaylight.controller.cluster.raft.PreLeaderScenarioTest)  Time elapsed: 5.207 sec  <<< FAILURE!
java.lang.AssertionError: Did not receive message of type class org.opendaylight.controller.cluster.raft.messages.AppendEntries
  at org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching(MessageCollectorActor.java:147)
  at org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching(MessageCollectorActor.java:125)
  at org.opendaylight.controller.cluster.raft.PreLeaderScenarioTest.testUnComittedEntryOnLeaderChange(PreLeaderScenarioTest.java:56)

The MessageCollectorActor does receive the message but occasionally out of order
w.r.t the CLEAR_MESSAGES although the latter is sent prior. The problem is that
AppendEntries is a ControlMessage so can get delivered before CLEAR_MESSAGES thus
CLEAR_MESSAGES needs to also be a ControlMessage.

Another problem with many of the tests is that MessageCollectorActors are created
as TestActors and thus get the CallingThreadDispatcher by default which really isn't
desirable. Some of the tests specifically set the default fork-join dispatcher but
we should just create MessageCollectorActors as normal actors.

Change-Id: I455a500d39aae4c46fb33d59be24c6327a9d321d
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
25 files changed:
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/IsolationScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/LeadershipTransferIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/NonVotingFollowerIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/PreLeaderScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotManagerTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehaviorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/CandidateTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/IsolatedLeaderTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTrackerTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/ForwardMessageToBehaviorActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/MessageCollectorActor.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardManagerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ForwardingDataTreeChangeListenerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/RoleChangeNotifierTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java

index c50a108..05a2df4 100644 (file)
@@ -92,7 +92,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
 
     public static class TestRaftActor extends MockRaftActor {
 
-        private final TestActorRef<MessageCollectorActor> collectorActor;
+        private final ActorRef collectorActor;
         private final Map<Class<?>, Predicate<?>> dropMessages = new ConcurrentHashMap<>();
 
         private TestRaftActor(Builder builder) {
@@ -172,9 +172,9 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         }
 
         public static class Builder extends AbstractBuilder<Builder, TestRaftActor> {
-            private TestActorRef<MessageCollectorActor> collectorActor;
+            private ActorRef collectorActor;
 
-            public Builder collectorActor(TestActorRef<MessageCollectorActor> newCollectorActor) {
+            public Builder collectorActor(ActorRef newCollectorActor) {
                 this.collectorActor = newCollectorActor;
                 return this;
             }
@@ -256,9 +256,8 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
     }
 
     protected TestActorRef<TestRaftActor> newTestRaftActor(String id, TestRaftActor.Builder builder) {
-        builder.collectorActor(factory.<MessageCollectorActor>createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                        factory.generateActorId(id + "-collector"))).id(id);
+        builder.collectorActor(factory.createActor(
+                MessageCollectorActor.props(), factory.generateActorId(id + "-collector"))).id(id);
 
         InvalidActorNameException lastEx = null;
         for (int i = 0; i < 10; i++) {
index fb810e3..179f4f0 100644 (file)
@@ -15,10 +15,7 @@ import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorAct
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.getAllMatching;
 
-import akka.actor.Actor;
 import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.testkit.TestActorRef;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import java.util.List;
@@ -41,8 +38,8 @@ import scala.concurrent.duration.FiniteDuration;
  * @author Thomas Pantelis
  */
 public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
-    private TestActorRef<Actor> follower1NotifierActor;
-    private TestActorRef<Actor> leaderNotifierActor;
+    private ActorRef follower1NotifierActor;
+    private ActorRef leaderNotifierActor;
 
     /**
      * Isolates the leader after all initial payload entries have been committed and applied on all nodes. While
@@ -424,7 +421,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
     private void createRaftActors() {
         testLog.info("createRaftActors starting");
 
-        follower1NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+        follower1NotifierActor = factory.createActor(MessageCollectorActor.props(),
                 factory.generateActorId(follower1Id + "-notifier"));
 
         DefaultConfigParamsImpl followerConfigParams = new DefaultConfigParamsImpl();
@@ -444,7 +441,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setIsolatedLeaderCheckInterval(new FiniteDuration(500, TimeUnit.MILLISECONDS));
 
-        leaderNotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+        leaderNotifierActor = factory.createActor(MessageCollectorActor.props(),
                 factory.generateActorId(leaderId + "-notifier"));
 
         leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses)
index a4a7f55..48c9fee 100644 (file)
@@ -14,7 +14,6 @@ import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorAct
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 
 import akka.actor.ActorRef;
-import akka.actor.Props;
 import akka.actor.Status;
 import akka.pattern.Patterns;
 import akka.testkit.JavaTestKit;
@@ -50,10 +49,10 @@ import scala.concurrent.duration.FiniteDuration;
 public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrationTest {
 
     private final String follower3Id = factory.generateActorId("follower");
-    private TestActorRef<MessageCollectorActor> leaderNotifierActor;
-    private TestActorRef<MessageCollectorActor> follower1NotifierActor;
-    private TestActorRef<MessageCollectorActor> follower2NotifierActor;
-    private TestActorRef<MessageCollectorActor> follower3NotifierActor;
+    private ActorRef leaderNotifierActor;
+    private ActorRef follower1NotifierActor;
+    private ActorRef follower2NotifierActor;
+    private ActorRef follower3NotifierActor;
     private TestActorRef<TestRaftActor> follower3Actor;
     private ActorRef follower3CollectorActor;
     private ActorRef requestLeadershipResultCollectorActor;
@@ -154,21 +153,21 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
         InMemorySnapshotStore.addSnapshot(follower2Id, snapshot);
         InMemorySnapshotStore.addSnapshot(follower3Id, snapshot);
 
-        follower1NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+        follower1NotifierActor = factory.createActor(MessageCollectorActor.props(),
                 factory.generateActorId(follower1Id + "-notifier"));
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id),
                         follower3Id, testActorPath(follower3Id)))
                 .config(newFollowerConfigParams()).roleChangeNotifier(follower1NotifierActor));
 
-        follower2NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+        follower2NotifierActor = factory.createActor(MessageCollectorActor.props(),
                 factory.generateActorId(follower2Id + "-notifier"));
         follower2Actor = newTestRaftActor(follower2Id,TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString(),
                         follower3Id, testActorPath(follower3Id)))
                 .config(newFollowerConfigParams()).roleChangeNotifier(follower2NotifierActor));
 
-        follower3NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+        follower3NotifierActor = factory.createActor(MessageCollectorActor.props(),
                 factory.generateActorId(follower3Id + "-notifier"));
         follower3Actor = newTestRaftActor(follower3Id,TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString(),
@@ -182,7 +181,7 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
 
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setElectionTimeoutFactor(3);
-        leaderNotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+        leaderNotifierActor = factory.createActor(MessageCollectorActor.props(),
                 factory.generateActorId(leaderId + "-notifier"));
         leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses)
                 .config(leaderConfigParams).roleChangeNotifier(leaderNotifierActor));
@@ -203,7 +202,7 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
         verifyRaftState(raftActor, rs -> assertEquals("getRaftState", expState.toString(), rs.getRaftState()));
     }
 
-    private static void verifyLeaderStateChangedMessages(final TestActorRef<MessageCollectorActor> notifierActor,
+    private static void verifyLeaderStateChangedMessages(final ActorRef notifierActor,
             final String... expLeaderIds) {
         List<LeaderStateChanged> leaderStateChanges = expectMatching(notifierActor, LeaderStateChanged.class,
                 expLeaderIds.length);
index 575c4fb..660d791 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.cluster.raft;
 import static org.junit.Assert.assertEquals;
 
 import akka.actor.ActorRef;
-import akka.dispatch.Dispatchers;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
@@ -358,9 +357,8 @@ public class NonVotingFollowerIntegrationTest extends AbstractRaftActorIntegrati
     public void testFollowerLeaderStateChanges() {
         testLog.info("testFollowerLeaderStateChanges");
 
-        ActorRef roleChangeNotifier = factory.<MessageCollectorActor>createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                factory.generateActorId("roleChangeNotifier"));
+        ActorRef roleChangeNotifier = factory.createActor(
+                MessageCollectorActor.props(), factory.generateActorId("roleChangeNotifier"));
         follower1Builder.roleChangeNotifier(roleChangeNotifier);
 
         setupLeaderAndNonVotingFollower();
index e4628d7..bb20186 100644 (file)
@@ -12,10 +12,7 @@ import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorAct
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 
-import akka.actor.Actor;
 import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.testkit.TestActorRef;
 import com.google.common.collect.ImmutableMap;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
@@ -37,7 +34,7 @@ import scala.concurrent.duration.FiniteDuration;
  */
 public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest {
 
-    private TestActorRef<Actor> follower1NotifierActor;
+    private ActorRef follower1NotifierActor;
     private DefaultConfigParamsImpl followerConfigParams;
 
     @Test
@@ -130,7 +127,7 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest {
     private void createRaftActors() {
         testLog.info("createRaftActors starting");
 
-        follower1NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
+        follower1NotifierActor = factory.createActor(MessageCollectorActor.props(),
                 factory.generateActorId(follower1Id + "-notifier"));
 
         followerConfigParams = newFollowerConfigParams();
@@ -171,6 +168,6 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest {
         follower1Context = follower1Actor.underlyingActor().getRaftActorContext();
         follower2Context = follower2Actor.underlyingActor().getRaftActorContext();
 
-        testLog.info("createRaftActors ending");
+        testLog.info("createRaftActors ending - follower1: {}, follower2: {}", follower1Id, follower2Id);
     }
 }
index c22a0e5..e844ddf 100644 (file)
@@ -98,7 +98,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
             actorFactory.generateActorId(FOLLOWER_ID));
 
     private TestActorRef<MockNewFollowerRaftActor> newFollowerRaftActor;
-    private TestActorRef<MessageCollectorActor> newFollowerCollectorActor;
+    private ActorRef newFollowerCollectorActor;
     private RaftActorContext newFollowerActorContext;
 
     private final JavaTestKit testKit = new JavaTestKit(getSystem());
@@ -113,8 +113,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
     private void setupNewFollower() {
         DefaultConfigParamsImpl configParams = newFollowerConfigParams();
 
-        newFollowerCollectorActor = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+        newFollowerCollectorActor = actorFactory.createActor(MessageCollectorActor.props(),
                 actorFactory.generateActorId(NEW_SERVER_ID + "Collector"));
         newFollowerRaftActor = actorFactory.createTestActor(MockNewFollowerRaftActor.props(
                 configParams, newFollowerCollectorActor).withDispatcher(Dispatchers.DefaultDispatcherId()),
@@ -164,7 +163,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         clearMessages(followerActor);
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
-        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
@@ -244,7 +243,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
         final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
-        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
@@ -296,7 +295,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
         final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
-        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), false), testKit.getRef());
 
@@ -366,7 +365,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
         final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
-        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         RaftActorContext follower2ActorContext = newFollowerContext(NEW_SERVER_ID2, followerActor);
         Follower newFollower2 = new Follower(follower2ActorContext);
@@ -429,7 +428,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
         final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         // Drop commit message for now to delay snapshot completion
         leaderRaftActor.setDropMessageOfType(String.class);
@@ -509,7 +508,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
         ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setElectionTimeoutFactor(100);
 
-        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         // Drop the commit message so the snapshot doesn't complete yet.
         leaderRaftActor.setDropMessageOfType(COMMIT_MESSAGE_CLASS);
@@ -559,7 +558,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setElectionTimeoutFactor(8);
 
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         // Drop the UnInitializedFollowerSnapshotReply to delay it.
         leaderRaftActor.setDropMessageOfType(UnInitializedFollowerSnapshotReply.class);
@@ -658,7 +657,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
         final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
-        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final ActorRef leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         // Drop UnInitializedFollowerSnapshotReply initially
         leaderRaftActor.setDropMessageOfType(UnInitializedFollowerSnapshotReply.class);
@@ -731,9 +730,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         configParams.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
-        TestActorRef<MessageCollectorActor> leaderActor = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId(LEADER_ID));
+        ActorRef leaderActor = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId(LEADER_ID));
 
         TestActorRef<MockRaftActor> followerRaftActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(FOLLOWER_ID).peerAddresses(ImmutableMap.of(LEADER_ID,
@@ -828,9 +826,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         configParams.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
-        TestActorRef<MessageCollectorActor> leaderActor = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId(LEADER_ID));
+        ActorRef leaderActor = actorFactory.createTestActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId(LEADER_ID));
 
         TestActorRef<MockRaftActor> followerRaftActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(FOLLOWER_ID).peerAddresses(ImmutableMap.of(LEADER_ID,
@@ -868,20 +865,17 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                         initialActorContext).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
 
-        final TestActorRef<MessageCollectorActor> leaderCollector =
-                newLeaderCollectorActor(leaderActor.underlyingActor());
+        final ActorRef leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
-        TestActorRef<MessageCollectorActor> follower1Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                        actorFactory.generateActorId("collector"));
+        ActorRef follower1Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         final TestActorRef<CollectingMockRaftActor> follower1Actor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                         FOLLOWER_ID2, follower2ActorPath, downNodeId, ""), configParams, NO_PERSISTENCE,
                         follower1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), follower1ActorId);
 
-        TestActorRef<MessageCollectorActor> follower2Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                        actorFactory.generateActorId("collector"));
+        ActorRef follower2Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         final TestActorRef<CollectingMockRaftActor> follower2Actor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID2, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                         FOLLOWER_ID, follower1ActorPath, downNodeId, ""), configParams, NO_PERSISTENCE,
@@ -932,12 +926,10 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                         initialActorContext).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
 
-        final TestActorRef<MessageCollectorActor> leaderCollector =
-                newLeaderCollectorActor(leaderActor.underlyingActor());
+        final ActorRef leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
-        final TestActorRef<MessageCollectorActor> followerCollector =
-                actorFactory.createTestActor(MessageCollectorActor.props()
-                .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId("collector"));
+        final ActorRef followerCollector =
+                actorFactory.createActor(MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString()),
                         configParams, NO_PERSISTENCE, followerCollector)
@@ -993,19 +985,17 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 MockLeaderRaftActor.props(ImmutableMap.of(FOLLOWER_ID, follower1ActorPath,
                         FOLLOWER_ID2, follower2ActorPath), new MockRaftActorContext())
                         .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
-        TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
+        ActorRef leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
-        TestActorRef<MessageCollectorActor> follower1Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef follower1Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         final TestActorRef<CollectingMockRaftActor> follower1RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                         FOLLOWER_ID2, follower2ActorPath), configParams, NO_PERSISTENCE, follower1Collector)
                         .withDispatcher(Dispatchers.DefaultDispatcherId()), follower1ActorId);
 
-        TestActorRef<MessageCollectorActor> follower2Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef follower2Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         final TestActorRef<CollectingMockRaftActor> follower2RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID2, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                         FOLLOWER_ID, follower1ActorPath), configParams, NO_PERSISTENCE, follower2Collector)
@@ -1074,19 +1064,17 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 MockLeaderRaftActor.props(ImmutableMap.of(FOLLOWER_ID, follower1ActorPath,
                         FOLLOWER_ID2, follower2ActorPath), new MockRaftActorContext())
                         .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
-        TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
+        ActorRef leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
-        TestActorRef<MessageCollectorActor> follower1Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef follower1Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         final TestActorRef<CollectingMockRaftActor> follower1RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                         FOLLOWER_ID2, follower2ActorPath), configParams, NO_PERSISTENCE, follower1Collector)
                         .withDispatcher(Dispatchers.DefaultDispatcherId()), follower1ActorId);
 
-        TestActorRef<MessageCollectorActor> follower2Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef follower2Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         final TestActorRef<CollectingMockRaftActor> follower2RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID2, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                         FOLLOWER_ID, follower1ActorPath), configParams, NO_PERSISTENCE, follower2Collector)
@@ -1160,17 +1148,15 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         InMemoryJournal.addEntry(node2ID, 2, persistedServerConfigEntry);
         InMemoryJournal.addEntry(node2ID, 3, new ApplyJournalEntries(0));
 
-        TestActorRef<MessageCollectorActor> node1Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node1Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
         CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
 
-        TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node2Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node2RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node2ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node2Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node2ID);
@@ -1270,9 +1256,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         configParams1.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
         configParams1.setElectionTimeoutFactor(1);
         configParams1.setPeerAddressResolver(peerAddressResolver);
-        TestActorRef<MessageCollectorActor> node1Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node1Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams1,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
@@ -1281,9 +1266,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         DefaultConfigParamsImpl configParams2 = new DefaultConfigParamsImpl();
         configParams2.setElectionTimeoutFactor(1000000);
         configParams2.setPeerAddressResolver(peerAddressResolver);
-        TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node2Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node2RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node2ID, ImmutableMap.<String, String>of(), configParams2,
                         PERSISTENT, node2Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node2ID);
@@ -1337,17 +1321,15 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 new MockRaftActorContext.MockPayload("2")));
         InMemoryJournal.addEntry(node2ID, 4, new ApplyJournalEntries(1));
 
-        TestActorRef<MessageCollectorActor> node1Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node1Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
         final CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
 
-        TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node2Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node2RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node2ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node2Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node2ID);
@@ -1402,17 +1384,15 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         InMemoryJournal.addEntry(node2ID, 1, new UpdateElectionTerm(1, "node1"));
         InMemoryJournal.addEntry(node2ID, 2, persistedServerConfigEntry);
 
-        TestActorRef<MessageCollectorActor> node1Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node1Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
         final CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
 
-        TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId("collector"));
+        ActorRef node2Collector = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId("collector"));
         TestActorRef<CollectingMockRaftActor> node2RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node2ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node2Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node2ID);
@@ -1471,14 +1451,13 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         return new ServerInfo(id, false);
     }
 
-    private TestActorRef<MessageCollectorActor> newLeaderCollectorActor(MockLeaderRaftActor leaderRaftActor) {
+    private ActorRef newLeaderCollectorActor(MockLeaderRaftActor leaderRaftActor) {
         return newCollectorActor(leaderRaftActor, LEADER_ID);
     }
 
-    private TestActorRef<MessageCollectorActor> newCollectorActor(AbstractMockRaftActor raftActor, String id) {
-        TestActorRef<MessageCollectorActor> collectorActor = actorFactory.createTestActor(
-                MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                actorFactory.generateActorId(id + "Collector"));
+    private ActorRef newCollectorActor(AbstractMockRaftActor raftActor, String id) {
+        ActorRef collectorActor = actorFactory.createTestActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId(id + "Collector"));
         raftActor.setCollectorActor(collectorActor);
         return collectorActor;
     }
@@ -1503,11 +1482,11 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
     }
 
     abstract static class AbstractMockRaftActor extends MockRaftActor {
-        private volatile TestActorRef<MessageCollectorActor> collectorActor;
+        private volatile ActorRef collectorActor;
         private volatile Class<?> dropMessageOfType;
 
         AbstractMockRaftActor(String id, Map<String, String> peerAddresses, Optional<ConfigParams> config,
-                boolean persistent, TestActorRef<MessageCollectorActor> collectorActor) {
+                boolean persistent, ActorRef collectorActor) {
             super(builder().id(id).peerAddresses(peerAddresses).config(config.get())
                     .persistent(Optional.of(persistent)));
             this.collectorActor = collectorActor;
@@ -1517,7 +1496,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
             this.dropMessageOfType = dropMessageOfType;
         }
 
-        void setCollectorActor(TestActorRef<MessageCollectorActor> collectorActor) {
+        void setCollectorActor(ActorRef collectorActor) {
             this.collectorActor = collectorActor;
         }
 
@@ -1536,7 +1515,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
     public static class CollectingMockRaftActor extends AbstractMockRaftActor {
 
         CollectingMockRaftActor(String id, Map<String, String> peerAddresses, Optional<ConfigParams> config,
-                boolean persistent, TestActorRef<MessageCollectorActor> collectorActor) {
+                boolean persistent, ActorRef collectorActor) {
             super(id, peerAddresses, config, persistent, collectorActor);
             snapshotCohortDelegate = new RaftActorSnapshotCohort() {
                 @Override
@@ -1558,7 +1537,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         }
 
         public static Props props(final String id, final Map<String, String> peerAddresses,
-                ConfigParams config, boolean persistent, TestActorRef<MessageCollectorActor> collectorActor) {
+                ConfigParams config, boolean persistent, ActorRef collectorActor) {
 
             return Props.create(CollectingMockRaftActor.class, id, peerAddresses, Optional.of(config),
                     persistent, collectorActor);
@@ -1611,13 +1590,13 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
     }
 
     public static class MockNewFollowerRaftActor extends AbstractMockRaftActor {
-        public MockNewFollowerRaftActor(ConfigParams config, TestActorRef<MessageCollectorActor> collectorActor) {
+        public MockNewFollowerRaftActor(ConfigParams config, ActorRef collectorActor) {
             super(NEW_SERVER_ID, Maps.<String, String>newHashMap(), Optional.of(config), NO_PERSISTENCE,
                     collectorActor);
             setPersistence(false);
         }
 
-        static Props props(ConfigParams config, TestActorRef<MessageCollectorActor> collectorActor) {
+        static Props props(ConfigParams config, ActorRef collectorActor) {
             return Props.create(MockNewFollowerRaftActor.class, config, collectorActor);
         }
     }
index a810fe0..b8be07a 100644 (file)
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.verify;
 
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
-import akka.actor.Props;
 import akka.actor.Status.Failure;
 import akka.actor.Terminated;
 import akka.dispatch.Dispatchers;
@@ -420,8 +419,7 @@ public class RaftActorTest extends AbstractActorTest {
 
     @Test
     public void testRaftRoleChangeNotifierWhenRaftActorHasNoPeers() throws Exception {
-        TestActorRef<MessageCollectorActor> notifierActor = factory.createTestActor(
-                Props.create(MessageCollectorActor.class));
+        ActorRef notifierActor = factory.createActor(MessageCollectorActor.props());
         MessageCollectorActor.waitUntilReady(notifierActor);
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
@@ -463,7 +461,7 @@ public class RaftActorTest extends AbstractActorTest {
         assertEquals(raftRoleChanged.getMemberId(), leaderStateChange.getLeaderId());
         assertEquals(MockRaftActor.PAYLOAD_VERSION, leaderStateChange.getLeaderPayloadVersion());
 
-        notifierActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(notifierActor);
 
         MockRaftActor raftActor = raftActorRef.underlyingActor();
         final String newLeaderId = "new-leader";
@@ -487,7 +485,7 @@ public class RaftActorTest extends AbstractActorTest {
         assertEquals(RaftState.Leader.name(), raftRoleChanged.getOldRole());
         assertEquals(RaftState.Follower.name(), raftRoleChanged.getNewRole());
 
-        notifierActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(notifierActor);
 
         raftActor.handleCommand("any");
 
@@ -496,7 +494,7 @@ public class RaftActorTest extends AbstractActorTest {
         assertEquals(newLeaderId, leaderStateChange.getLeaderId());
         assertEquals(newLeaderVersion, leaderStateChange.getLeaderPayloadVersion());
 
-        notifierActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(notifierActor);
 
         raftActor.handleCommand("any");
 
@@ -507,7 +505,7 @@ public class RaftActorTest extends AbstractActorTest {
 
     @Test
     public void testRaftRoleChangeNotifierWhenRaftActorHasPeers() throws Exception {
-        ActorRef notifierActor = factory.createActor(Props.create(MessageCollectorActor.class));
+        ActorRef notifierActor = factory.createActor(MessageCollectorActor.props());
         MessageCollectorActor.waitUntilReady(notifierActor);
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
@@ -552,8 +550,7 @@ public class RaftActorTest extends AbstractActorTest {
         final String persistenceId = factory.generateActorId("leader-");
         final String follower1Id = factory.generateActorId("follower-");
 
-        ActorRef followerActor1 =
-                factory.createActor(Props.create(MessageCollectorActor.class));
+        ActorRef followerActor1 = factory.createActor(MessageCollectorActor.props());
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
         config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
@@ -642,9 +639,7 @@ public class RaftActorTest extends AbstractActorTest {
         final String persistenceId = factory.generateActorId("follower-");
         final String leaderId = factory.generateActorId("leader-");
 
-
-        ActorRef leaderActor1 =
-                factory.createActor(Props.create(MessageCollectorActor.class));
+        ActorRef leaderActor1 = factory.createActor(MessageCollectorActor.props());
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
         config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
@@ -734,8 +729,8 @@ public class RaftActorTest extends AbstractActorTest {
         final String follower1Id = factory.generateActorId("follower-");
         final String follower2Id = factory.generateActorId("follower-");
 
-        final ActorRef followerActor1 = factory.createActor(Props.create(MessageCollectorActor.class), follower1Id);
-        final ActorRef followerActor2 = factory.createActor(Props.create(MessageCollectorActor.class), follower2Id);
+        final ActorRef followerActor1 = factory.createActor(MessageCollectorActor.props(), follower1Id);
+        final ActorRef followerActor2 = factory.createActor(MessageCollectorActor.props(), follower2Id);
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
         config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
@@ -1242,8 +1237,7 @@ public class RaftActorTest extends AbstractActorTest {
     public void testLeaderTransitioning() throws Exception {
         TEST_LOG.info("testLeaderTransitioning starting");
 
-        TestActorRef<MessageCollectorActor> notifierActor = factory.createTestActor(
-                Props.create(MessageCollectorActor.class));
+        ActorRef notifierActor = factory.createActor(MessageCollectorActor.props());
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
         config.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
@@ -1280,7 +1274,7 @@ public class RaftActorTest extends AbstractActorTest {
         final String leaderId = factory.generateActorId("leader-");
         final String followerId = factory.generateActorId("follower-");
 
-        final ActorRef followerActor = factory.createActor(Props.create(MessageCollectorActor.class));
+        final ActorRef followerActor = factory.createActor(MessageCollectorActor.props());
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
         config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
@@ -1325,7 +1319,7 @@ public class RaftActorTest extends AbstractActorTest {
         final String leaderId = factory.generateActorId("leader-");
         final String followerId = factory.generateActorId("follower-");
 
-        final ActorRef followerActor = factory.createActor(Props.create(MessageCollectorActor.class));
+        final ActorRef followerActor = factory.createActor(MessageCollectorActor.props());
 
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
         config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
index fdfaa04..ccbdb55 100644 (file)
@@ -26,7 +26,6 @@ import static org.mockito.Mockito.verify;
 
 import akka.actor.ActorRef;
 import akka.persistence.SnapshotSelectionCriteria;
-import akka.testkit.TestActorRef;
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Optional;
@@ -77,7 +76,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     private TestActorFactory factory;
 
-    private TestActorRef<MessageCollectorActor> actorRef;
+    private ActorRef actorRef;
 
     @Before
     public void setUp() {
@@ -103,7 +102,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         snapshotManager = new SnapshotManager(mockRaftActorContext, LoggerFactory.getLogger(this.getClass()));
         factory = new TestActorFactory(getSystem());
 
-        actorRef = factory.createTestActor(MessageCollectorActor.props(), factory.generateActorId("test-"));
+        actorRef = factory.createActor(MessageCollectorActor.props(), factory.generateActorId("test-"));
         doReturn(actorRef).when(mockRaftActorContext).getActor();
 
         snapshotManager.setCreateSnapshotConsumer(mockProcedure);
@@ -146,7 +145,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         //
         assertEquals(-1L, captureSnapshot.getReplicatedToAllIndex());
         assertEquals(-1L, captureSnapshot.getReplicatedToAllTerm());
-        actorRef.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(actorRef);
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -177,8 +176,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         assertEquals(-1L, captureSnapshot.getReplicatedToAllIndex());
         assertEquals(-1L, captureSnapshot.getReplicatedToAllTerm());
 
-        actorRef.underlyingActor().clear();
-
+        MessageCollectorActor.clearMessages(actorRef);
     }
 
     @SuppressWarnings({ "unchecked", "rawtypes" })
@@ -207,8 +205,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         //
         assertEquals(-1L, captureSnapshot.getReplicatedToAllIndex());
         assertEquals(-1L, captureSnapshot.getReplicatedToAllTerm());
-        actorRef.underlyingActor().clear();
-
+        MessageCollectorActor.clearMessages(actorRef);
     }
 
     @Test
index 1d4fde1..27fc7c0 100644 (file)
@@ -151,12 +151,11 @@ public class AbstractLeaderElectionScenarioTest {
             dropMessagesToBehavior.clear();
         }
 
-        @Override
         public void clear() {
             behaviorStateChangeLatch = null;
             clearDropMessagesToBehavior();
             messagesReceivedLatches.clear();
-            super.clear();
+            clearMessages(getSelf());
         }
 
         void forwardCapturedMessageToBehavior(final Class<?> msgClass, final ActorRef sender) {
index 94563da..cb84ea9 100644 (file)
@@ -13,8 +13,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 
 import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.testkit.TestActorRef;
 import com.google.protobuf.ByteString;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -49,8 +47,8 @@ public abstract class AbstractRaftActorBehaviorTest<T extends RaftActorBehavior>
 
     protected final TestActorFactory actorFactory = new TestActorFactory(getSystem());
 
-    private final TestActorRef<MessageCollectorActor> behaviorActor = actorFactory.createTestActor(
-            Props.create(MessageCollectorActor.class), actorFactory.generateActorId("behavior"));
+    private final ActorRef behaviorActor = actorFactory.createActor(
+            MessageCollectorActor.props(), actorFactory.generateActorId("behavior"));
 
     RaftActorBehavior behavior;
 
@@ -156,7 +154,7 @@ public abstract class AbstractRaftActorBehaviorTest<T extends RaftActorBehavior>
         handleAppendEntriesAddSameEntryToLogReply(behaviorActor);
     }
 
-    protected void handleAppendEntriesAddSameEntryToLogReply(final TestActorRef<MessageCollectorActor> replyActor) {
+    protected void handleAppendEntriesAddSameEntryToLogReply(final ActorRef replyActor) {
         AppendEntriesReply reply = MessageCollectorActor.getFirstMatching(replyActor, AppendEntriesReply.class);
         Assert.assertNull("Expected no AppendEntriesReply", reply);
     }
index e39a674..6dd5336 100644 (file)
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import akka.actor.ActorRef;
-import akka.actor.Props;
+import akka.dispatch.Dispatchers;
 import akka.testkit.TestActorRef;
 import com.google.common.base.Stopwatch;
 import java.util.ArrayList;
@@ -49,9 +49,10 @@ public class CandidateTest extends AbstractRaftActorBehaviorTest<Candidate> {
     static final Logger LOG = LoggerFactory.getLogger(CandidateTest.class);
 
     private final TestActorRef<MessageCollectorActor> candidateActor = actorFactory.createTestActor(
-            Props.create(MessageCollectorActor.class), actorFactory.generateActorId("candidate"));
+            MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+            actorFactory.generateActorId("candidate"));
 
-    private TestActorRef<MessageCollectorActor>[] peerActors;
+    private ActorRef[] peerActors;
 
     private RaftActorBehavior candidate;
 
@@ -352,12 +353,11 @@ public class CandidateTest extends AbstractRaftActorBehaviorTest<Candidate> {
         return new MockRaftActorContext("candidate", getSystem(), candidateActor);
     }
 
-    @SuppressWarnings("unchecked")
     private Map<String, String> setupPeers(final int count) {
         Map<String, String> peerMap = new HashMap<>();
-        peerActors = new TestActorRef[count];
+        peerActors = new ActorRef[count];
         for (int i = 0; i < count; i++) {
-            peerActors[i] = actorFactory.createTestActor(Props.create(MessageCollectorActor.class),
+            peerActors[i] = actorFactory.createActor(MessageCollectorActor.props(),
                     actorFactory.generateActorId("peer"));
             peerMap.put("peer" + (i + 1), peerActors[i].path().toString());
         }
index 3e6c759..ab82188 100644 (file)
@@ -20,7 +20,6 @@ import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
 import akka.actor.ActorRef;
-import akka.actor.Props;
 import akka.dispatch.Dispatchers;
 import akka.testkit.JavaTestKit;
 import akka.testkit.TestActorRef;
@@ -78,11 +77,11 @@ import scala.concurrent.duration.FiniteDuration;
 
 public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
 
-    private final TestActorRef<MessageCollectorActor> followerActor = actorFactory.createTestActor(
-            Props.create(MessageCollectorActor.class), actorFactory.generateActorId("follower"));
+    private final ActorRef followerActor = actorFactory.createActor(
+            MessageCollectorActor.props(), actorFactory.generateActorId("follower"));
 
-    private final TestActorRef<MessageCollectorActor> leaderActor = actorFactory.createTestActor(
-            Props.create(MessageCollectorActor.class), actorFactory.generateActorId("leader"));
+    private final ActorRef leaderActor = actorFactory.createActor(
+            MessageCollectorActor.props(), actorFactory.generateActorId("leader"));
 
     private Follower follower;
 
@@ -356,7 +355,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
         assertFalse(syncStatus.isInitialSyncDone());
 
         // Clear all the messages
-        followerActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(followerActor);
 
         context.setLastApplied(101);
         context.setCommitIndex(101);
@@ -372,7 +371,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
 
         assertTrue(syncStatus.isInitialSyncDone());
 
-        followerActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(followerActor);
 
         // Sending the same message again should not generate another message
 
@@ -404,7 +403,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
         assertFalse(syncStatus.isInitialSyncDone());
 
         // Clear all the messages
-        followerActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(followerActor);
 
         context.setLastApplied(100);
         setLastLogEntry(context, 1, 100,
@@ -444,7 +443,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
         assertFalse(syncStatus.isInitialSyncDone());
 
         // Clear all the messages
-        followerActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(followerActor);
 
         context.setLastApplied(101);
         context.setCommitIndex(101);
@@ -463,7 +462,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
         assertTrue(syncStatus.isInitialSyncDone());
 
         // Clear all the messages
-        followerActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(followerActor);
 
         context.setLastApplied(100);
         setLastLogEntry(context, 1, 100,
@@ -749,7 +748,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
 
         entries = Arrays.asList(newReplicatedLogEntry(1, 1, "one"), newReplicatedLogEntry(1, 2, "two"));
 
-        leaderActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(leaderActor);
         follower.handleMessage(leaderActor, new AppendEntries(1, "leader", 0, 1, entries, 2, -1, (short)0));
 
         assertEquals("Next index", 3, log.last().getIndex() + 1);
@@ -977,7 +976,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
         assertFalse(syncStatus.isInitialSyncDone());
 
         // Clear all the messages
-        followerActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(followerActor);
 
         context.setLastApplied(101);
         context.setCommitIndex(101);
@@ -1378,7 +1377,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
     }
 
     @Override
-    protected void handleAppendEntriesAddSameEntryToLogReply(final TestActorRef<MessageCollectorActor> replyActor) {
+    protected void handleAppendEntriesAddSameEntryToLogReply(final ActorRef replyActor) {
         AppendEntriesReply reply = MessageCollectorActor.expectFirstMatching(replyActor, AppendEntriesReply.class);
         assertEquals("isSuccess", true, reply.isSuccess());
     }
index dae7c6c..283826a 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.controller.cluster.raft.behaviors;
 import static org.junit.Assert.assertEquals;
 
 import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.testkit.TestActorRef;
 import java.util.HashMap;
 import java.util.Map;
 import org.junit.After;
@@ -25,11 +23,11 @@ import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 
 public class IsolatedLeaderTest extends AbstractLeaderTest<IsolatedLeader> {
 
-    private final TestActorRef<MessageCollectorActor> leaderActor = actorFactory.createTestActor(
-            Props.create(MessageCollectorActor.class), actorFactory.generateActorId("leader"));
+    private final ActorRef leaderActor = actorFactory.createActor(
+            MessageCollectorActor.props(), actorFactory.generateActorId("leader"));
 
-    private final TestActorRef<MessageCollectorActor> senderActor = actorFactory.createTestActor(
-            Props.create(MessageCollectorActor.class), actorFactory.generateActorId("sender"));
+    private final ActorRef senderActor = actorFactory.createActor(
+            MessageCollectorActor.props(), actorFactory.generateActorId("sender"));
 
     private AbstractLeader isolatedLeader;
 
index ae58652..00a2fcd 100644 (file)
@@ -2029,8 +2029,8 @@ public class LeaderTest extends AbstractLeaderTest<Leader> {
         leaderActorContext.setLastApplied(-1);
 
         String nonVotingFollowerId = "nonvoting-follower";
-        TestActorRef<ForwardMessageToBehaviorActor> nonVotingFollowerActor = actorFactory.createTestActor(
-                Props.create(MessageCollectorActor.class), actorFactory.generateActorId(nonVotingFollowerId));
+        ActorRef nonVotingFollowerActor = actorFactory.createActor(
+                MessageCollectorActor.props(), actorFactory.generateActorId(nonVotingFollowerId));
 
         leaderActorContext.addToPeers(nonVotingFollowerId, nonVotingFollowerActor.path().toString(),
                 VotingState.NON_VOTING);
index 271250c..b4f4c5d 100644 (file)
@@ -15,8 +15,7 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import akka.actor.Props;
-import akka.testkit.TestActorRef;
+import akka.actor.ActorRef;
 import org.junit.After;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.AbstractActorTest;
@@ -27,8 +26,8 @@ import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 public class SyncStatusTrackerTest extends AbstractActorTest {
     protected final TestActorFactory actorFactory = new TestActorFactory(getSystem());
 
-    private final TestActorRef<MessageCollectorActor> listener = actorFactory.createTestActor(
-            Props.create(MessageCollectorActor.class), actorFactory.generateActorId("listener"));
+    private final ActorRef listener = actorFactory.createActor(
+            MessageCollectorActor.props(), actorFactory.generateActorId("listener"));
 
     @After
     public void tearDown() {
index 6c6f190..0bd7d5c 100644 (file)
@@ -49,9 +49,8 @@ public class ForwardMessageToBehaviorActor extends MessageCollectorActor {
         return behaviorChanges;
     }
 
-    @Override
     public void clear() {
-        super.clear();
+        clearMessages(getSelf());
         behaviorChanges.clear();
     }
 }
index 32077a2..d234913 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.cluster.raft.utils;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.actor.UntypedActor;
+import akka.dispatch.ControlMessage;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
 import com.google.common.base.Predicate;
@@ -32,7 +33,13 @@ import scala.concurrent.duration.FiniteDuration;
 public class MessageCollectorActor extends UntypedActor {
     private static final String ARE_YOU_READY = "ARE_YOU_READY";
     public static final String GET_ALL_MESSAGES = "messages";
-    private static final String CLEAR_MESSAGES = "clear-messages";
+
+    private static final Object CLEAR_MESSAGES = new ControlMessage() {
+        @Override
+        public String toString() {
+            return "clear-messages";
+        }
+    };
 
     private final List<Object> messages = new ArrayList<>();
 
@@ -42,18 +49,14 @@ public class MessageCollectorActor extends UntypedActor {
         } else if (GET_ALL_MESSAGES.equals(message)) {
             getSender().tell(new ArrayList<>(messages), getSelf());
         } else if (CLEAR_MESSAGES.equals(message)) {
-            clear();
+            messages.clear();
         } else if (message != null) {
             messages.add(message);
         }
     }
 
-    public void clear() {
-        messages.clear();
-    }
-
     @SuppressWarnings({"unchecked", "checkstyle:illegalCatch"})
-    private static List<Object> getAllMessages(final ActorRef actor) {
+    public static List<Object> getAllMessages(final ActorRef actor) {
         FiniteDuration operationDuration = Duration.create(5, TimeUnit.SECONDS);
         Timeout operationTimeout = new Timeout(operationDuration);
         Future<Object> future = Patterns.ask(actor, GET_ALL_MESSAGES, operationTimeout);
@@ -144,7 +147,8 @@ public class MessageCollectorActor extends UntypedActor {
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
         }
 
-        throw new AssertionError("Did not receive message of type " + clazz, lastEx);
+        throw new AssertionError(actor + ": Did not receive message of type " + clazz + ", Actual received was "
+            + getAllMessages(actor), lastEx);
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
index 8152c9e..f6f45b0 100644 (file)
@@ -14,7 +14,6 @@ import static org.mockito.MockitoAnnotations.initMocks;
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
-import akka.testkit.TestActorRef;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import org.junit.After;
@@ -34,7 +33,7 @@ public class AbstractShardManagerTest extends AbstractClusterRefActorTest {
     protected static final MemberName MEMBER_1 = MemberName.forName("member-1");
 
     protected static int ID_COUNTER = 1;
-    protected static TestActorRef<MessageCollectorActor> mockShardActor;
+    protected static ActorRef mockShardActor;
     protected static ShardIdentifier mockShardName;
 
     protected final String shardMrgIDSuffix = "config" + ID_COUNTER++;
@@ -68,11 +67,10 @@ public class AbstractShardManagerTest extends AbstractClusterRefActorTest {
 
         if (mockShardActor == null) {
             mockShardName = ShardIdentifier.create(Shard.DEFAULT_NAME, MEMBER_1, "config");
-            mockShardActor = TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class),
-                    mockShardName.toString());
+            mockShardActor = getSystem().actorOf(MessageCollectorActor.props(), mockShardName.toString());
         }
 
-        mockShardActor.underlyingActor().clear();
+        MessageCollectorActor.clearMessages(mockShardActor);
     }
 
     @After
index d5416a0..7b679da 100644 (file)
@@ -75,8 +75,7 @@ public class DataChangeListenerProxyTest extends AbstractActorTest {
 
     @Test
     public void testOnDataChanged() throws Exception {
-        final Props props = Props.create(MessageCollectorActor.class);
-        final ActorRef actorRef = getSystem().actorOf(props);
+        final ActorRef actorRef = getSystem().actorOf(MessageCollectorActor.props());
 
         DataChangeListenerProxy dataChangeListenerProxy = new DataChangeListenerProxy(
                 getSystem().actorSelection(actorRef.path()));
index 1005c2a..41458f8 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
-import akka.actor.Props;
 import java.util.Arrays;
 import java.util.Collection;
 import org.junit.Assert;
@@ -22,8 +21,7 @@ public class ForwardingDataTreeChangeListenerTest extends AbstractActorTest {
 
     @Test
     public void testOnDataChanged() throws Exception {
-        final Props props = Props.create(MessageCollectorActor.class);
-        final ActorRef actorRef = getSystem().actorOf(props);
+        final ActorRef actorRef = getSystem().actorOf(MessageCollectorActor.props());
 
         ForwardingDataTreeChangeListener forwardingListener = new ForwardingDataTreeChangeListener(
                 getSystem().actorSelection(actorRef.path()));
index 13c42f9..8e391cb 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import akka.actor.ActorRef;
-import akka.actor.Props;
 import akka.testkit.JavaTestKit;
 import akka.testkit.TestActorRef;
 import org.junit.Test;
@@ -33,7 +32,7 @@ public class RoleChangeNotifierTest extends AbstractActorTest {
         new JavaTestKit(getSystem()) {
             {
                 String memberId = "testHandleRegisterRoleChangeListener";
-                ActorRef listenerActor = getSystem().actorOf(Props.create(MessageCollectorActor.class));
+                ActorRef listenerActor = getSystem().actorOf(MessageCollectorActor.props());
 
                 TestActorRef<RoleChangeNotifier> notifierTestActorRef = TestActorRef.create(getSystem(),
                         RoleChangeNotifier.getProps(memberId), memberId);
@@ -56,7 +55,7 @@ public class RoleChangeNotifierTest extends AbstractActorTest {
         new JavaTestKit(getSystem()) {
             {
                 String memberId = "testHandleRegisterRoleChangeListenerWithNotificationSet";
-                ActorRef listenerActor = getSystem().actorOf(Props.create(MessageCollectorActor.class));
+                ActorRef listenerActor = getSystem().actorOf(MessageCollectorActor.props());
                 ActorRef shardActor = getTestActor();
 
                 TestActorRef<RoleChangeNotifier> notifierTestActorRef = TestActorRef.create(getSystem(),
index 54183ae..5869271 100644 (file)
@@ -2076,8 +2076,7 @@ public class ShardTest extends AbstractShardTest {
 
                 waitUntilLeader(shard);
 
-                final TestActorRef<MessageCollectorActor> listener =
-                        TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class));
+                final ActorRef listener = getSystem().actorOf(MessageCollectorActor.props());
 
                 shard.tell(new RegisterRoleChangeListener(), listener);
 
@@ -2324,7 +2323,8 @@ public class ShardTest extends AbstractShardTest {
 
     @Test
     public void testServerRemoved() throws Exception {
-        final TestActorRef<MessageCollectorActor> parent = actorFactory.createTestActor(MessageCollectorActor.props());
+        final TestActorRef<MessageCollectorActor> parent = actorFactory.createTestActor(MessageCollectorActor.props()
+                .withDispatcher(Dispatchers.DefaultDispatcherId()));
 
         final ActorRef shard = parent.underlyingActor().context().actorOf(
                 newShardBuilder().props().withDispatcher(Dispatchers.DefaultDispatcherId()),
index 276f11f..ca104f1 100644 (file)
@@ -257,7 +257,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
         ShardIdentifier localId = newShardId(LOCAL_MEMBER_NAME);
         TestActorRef<TestEntityOwnershipShard> leader = actorFactory.createTestActor(TestEntityOwnershipShard.props(
                 newShardBuilder(leaderId, peerMap(localId.toString()), PEER_MEMBER_1_NAME),
-                actorFactory.createTestActor(MessageCollectorActor.props())), leaderId.toString());
+                actorFactory.createActor(MessageCollectorActor.props())), leaderId.toString());
         final TestEntityOwnershipShard leaderShard = leader.underlyingActor();
 
         TestActorRef<TestEntityOwnershipShard> local = actorFactory.createTestActor(TestEntityOwnershipShard.props(
@@ -871,7 +871,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         TestActorRef<TestEntityOwnershipShard> peer1 = actorFactory.createTestActor(TestEntityOwnershipShard.props(
                 newShardBuilder(peerId1, peerMap(leaderId.toString(), peerId2.toString()), PEER_MEMBER_1_NAME),
-                actorFactory.createTestActor(MessageCollectorActor.props())), peerId1.toString());
+                actorFactory.createActor(MessageCollectorActor.props())), peerId1.toString());
         peer1.underlyingActor().startDroppingMessagesOfType(ElectionTimeout.class);
 
         TestActorRef<TestEntityOwnershipShard> peer2 = actorFactory.createTestActor(TestEntityOwnershipShard.props(
@@ -1263,10 +1263,10 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
     }
 
     private static class TestEntityOwnershipShard extends EntityOwnershipShard {
-        private final TestActorRef<MessageCollectorActor> collectorActor;
+        private final ActorRef collectorActor;
         private final Map<Class<?>, Predicate<?>> dropMessagesOfType = new ConcurrentHashMap<>();
 
-        TestEntityOwnershipShard(final Builder builder, final TestActorRef<MessageCollectorActor> collectorActor) {
+        TestEntityOwnershipShard(final Builder builder, final ActorRef collectorActor) {
             super(builder);
             this.collectorActor = collectorActor;
         }
@@ -1296,7 +1296,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
             dropMessagesOfType.remove(msgClass);
         }
 
-        TestActorRef<MessageCollectorActor> collectorActor() {
+        ActorRef collectorActor() {
             return collectorActor;
         }
 
@@ -1304,7 +1304,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
             return props(builder, null);
         }
 
-        static Props props(final Builder builder, final TestActorRef<MessageCollectorActor> collectorActor) {
+        static Props props(final Builder builder, final ActorRef collectorActor) {
             return Props.create(TestEntityOwnershipShard.class, builder, collectorActor)
                     .withDispatcher(Dispatchers.DefaultDispatcherId());
         }
index b3d6628..a3cf9aa 100644 (file)
@@ -141,10 +141,10 @@ public class ShardManagerTest extends AbstractShardManagerTest {
     private ActorRef newMockShardActor(final ActorSystem system, final String shardName, final String memberName) {
         String name = ShardIdentifier.create(shardName, MemberName.forName(memberName), "config").toString();
         if (system == getSystem()) {
-            return actorFactory.createActor(Props.create(MessageCollectorActor.class), name);
+            return actorFactory.createActor(MessageCollectorActor.props(), name);
         }
 
-        return system.actorOf(Props.create(MessageCollectorActor.class), name);
+        return system.actorOf(MessageCollectorActor.props(), name);
     }
 
     private Props newShardMgrProps() {
@@ -246,9 +246,9 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         };
 
         final ActorRef defaultShardActor = actorFactory.createActor(
-                Props.create(MessageCollectorActor.class), actorFactory.generateActorId("default"));
+                MessageCollectorActor.props(), actorFactory.generateActorId("default"));
         final ActorRef topologyShardActor = actorFactory.createActor(
-                Props.create(MessageCollectorActor.class), actorFactory.generateActorId("topology"));
+                MessageCollectorActor.props(), actorFactory.generateActorId("topology"));
 
         final Map<String, Entry<ActorRef, DatastoreContext>> shardInfoMap = Collections.synchronizedMap(
                 new HashMap<String, Entry<ActorRef, DatastoreContext>>());
index 3c60fb7..960e032 100644 (file)
@@ -349,8 +349,7 @@ public class ActorContextTest extends AbstractActorTest {
     @Test
     public void testFindPrimaryShardAsyncRemotePrimaryFound() throws Exception {
 
-        TestActorRef<MessageCollectorActor> shardManager = TestActorRef.create(getSystem(),
-                Props.create(MessageCollectorActor.class));
+        ActorRef shardManager = getSystem().actorOf(MessageCollectorActor.props());
 
         DatastoreContext dataStoreContext = DatastoreContext.newBuilder()
                 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
@@ -391,8 +390,7 @@ public class ActorContextTest extends AbstractActorTest {
     @Test
     public void testFindPrimaryShardAsyncLocalPrimaryFound() throws Exception {
 
-        TestActorRef<MessageCollectorActor> shardManager = TestActorRef.create(getSystem(),
-                Props.create(MessageCollectorActor.class));
+        ActorRef shardManager = getSystem().actorOf(MessageCollectorActor.props());
 
         DatastoreContext dataStoreContext = DatastoreContext.newBuilder()
                 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
@@ -443,8 +441,7 @@ public class ActorContextTest extends AbstractActorTest {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     private static void testFindPrimaryExceptions(final Object expectedException) throws Exception {
-        TestActorRef<MessageCollectorActor> shardManager =
-            TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class));
+        ActorRef shardManager = getSystem().actorOf(MessageCollectorActor.props());
 
         DatastoreContext dataStoreContext = DatastoreContext.newBuilder()
                 .logicalStoreType(LogicalDatastoreType.CONFIGURATION)
@@ -479,8 +476,8 @@ public class ActorContextTest extends AbstractActorTest {
     public void testBroadcast() {
         new JavaTestKit(getSystem()) {
             {
-                ActorRef shardActorRef1 = getSystem().actorOf(Props.create(MessageCollectorActor.class));
-                ActorRef shardActorRef2 = getSystem().actorOf(Props.create(MessageCollectorActor.class));
+                ActorRef shardActorRef1 = getSystem().actorOf(MessageCollectorActor.props());
+                ActorRef shardActorRef2 = getSystem().actorOf(MessageCollectorActor.props());
 
                 TestActorRef<MockShardManager> shardManagerActorRef = TestActorRef.create(getSystem(),
                         MockShardManager.props());

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.