Fix failure of testCloseCandidateRegistrationInQuickSuccession 11/29811/2
authorMoiz Raja <moraja@cisco.com>
Fri, 13 Nov 2015 21:32:13 +0000 (13:32 -0800)
committerMoiz Raja <moraja@cisco.com>
Tue, 17 Nov 2015 15:19:50 +0000 (07:19 -0800)
Moved checking of whether the ownershipchange event occurred with
hasOwner=false to the loop so that we pass the test only when all
listeners receive that event with hasOwner=false

Change-Id: I463272822e6a39f310fef5996b541e1d06c79548
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java

index 2167bd2..ecae2fa 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.cluster.datastore.entityownership;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.AdditionalMatchers.or;
 import static org.mockito.Mockito.atMost;
@@ -350,17 +349,16 @@ public class DistributedEntityOwnershipIntegrationTest {
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
             if(!leaderEntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
                     !follower1EntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
-                    !follower2EntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner()) {
+                    !follower2EntityOwnershipService.getOwnershipState(ENTITY1).get().hasOwner() &&
+                    leaderChangeCaptor.getAllValues().size() > 0 && !leaderChangeCaptor.getValue().hasOwner() &&
+                    leaderChangeCaptor.getAllValues().size() > 0 && !follower1ChangeCaptor.getValue().hasOwner() &&
+                    leaderChangeCaptor.getAllValues().size() > 0 && !follower2ChangeCaptor.getValue().hasOwner()) {
                 passed = true;
                 break;
             }
         }
 
         assertTrue("No ownership change message was sent with hasOwner=false", passed);
-
-        assertFalse(leaderChangeCaptor.getAllValues().get(leaderChangeCaptor.getAllValues().size()-1).hasOwner());
-        assertFalse(follower1ChangeCaptor.getAllValues().get(follower1ChangeCaptor.getAllValues().size()-1).hasOwner());
-        assertFalse(follower2ChangeCaptor.getAllValues().get(follower2ChangeCaptor.getAllValues().size()-1).hasOwner());
     }
 
     /**