Make Netty-3 dependency optional
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / test / java / org / opendaylight / controller / cluster / raft / behaviors / PartitionedCandidateOnStartupElectionScenarioTest.java
index f8eab9a38b3839dc3f91a10d1b989ad3ff12ccc7..7b8529a0b176a65c2e623764167ac09b4d0f1824 100644 (file)
@@ -33,7 +33,7 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
     private long candidateElectionTerm;
 
     @Test
-    public void runTest() throws Exception {
+    public void runTest() {
         testLog.info("PartitionedCandidateOnStartupElectionScenarioTest starting");
 
         setupInitialMember1AndMember2Behaviors();
@@ -47,7 +47,7 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
         testLog.info("PartitionedCandidateOnStartupElectionScenarioTest ending");
     }
 
-    private void sendElectionTimeoutToFollowerMember1() throws Exception {
+    private void sendElectionTimeoutToFollowerMember1() {
         testLog.info("sendElectionTimeoutToFollowerMember1 starting");
 
         // At this point we have no leader. Candidate member 3 would continue to start new elections
@@ -96,7 +96,7 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
         testLog.info("sendElectionTimeoutToFollowerMember1 ending");
     }
 
-    private void resolvePartitionAndSendElectionTimeoutsToCandidateMember3() throws Exception {
+    private void resolvePartitionAndSendElectionTimeoutsToCandidateMember3() {
         testLog.info("resolvePartitionAndSendElectionTimeoutsToCandidateMember3 starting");
 
         // Now send a couple more ElectionTimeouts to Candidate member 3 with the partition resolved.
@@ -182,9 +182,8 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
 
         member2Actor.dropMessagesToBehavior(RequestVote.class, numCandidateElections);
 
-        Candidate member3Behavior = new Candidate(member3Context);
-        member3Actor.behavior = member3Behavior;
-        member3Context.setCurrentBehavior(member3Behavior);
+        member3Actor.self().tell(new SetBehavior(new Candidate(member3Context), member3Context),
+                ActorRef.noSender());
 
         // Send several additional ElectionTimeouts to Candidate member 3. Each ElectionTimeout will
         // start a new term so Candidate member 3's current term will be greater than the leader's
@@ -209,7 +208,7 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
         testLog.info("setupPartitionedCandidateMember3AndSendElectionTimeouts ending");
     }
 
-    private void setupInitialMember1AndMember2Behaviors() throws Exception {
+    private void setupInitialMember1AndMember2Behaviors() {
         testLog.info("setupInitialMember1AndMember2Behaviors starting");
 
         // Initialize the ReplicatedLog and election term info for member 1 and 2. The current term
@@ -234,8 +233,8 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
         member2Context.setLastApplied(replicatedLog.lastIndex());
         member2Context.getTermInformation().update(3, "member1");
 
-        member2Actor.behavior = new Follower(member2Context);
-        member2Context.setCurrentBehavior(member2Actor.behavior);
+        member2Actor.self().tell(new SetBehavior(new Follower(member2Context), member2Context),
+                ActorRef.noSender());
 
         // Create member 1's behavior as Leader.
 
@@ -258,6 +257,5 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
         member3Actor.clear();
 
         testLog.info("setupInitialMember1AndMember2Behaviors ending");
-
     }
 }