curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [7/9] curator git commit: refined the tests
Date Mon, 07 Sep 2015 12:57:26 GMT
refined the tests


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/49b267d1
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/49b267d1
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/49b267d1

Branch: refs/heads/CURATOR-3.0
Commit: 49b267d185bddb7d2be073731ebc6a8352ed6efb
Parents: c117b08
Author: randgalt <randgalt@apache.org>
Authored: Tue Sep 1 06:32:52 2015 -0700
Committer: randgalt <randgalt@apache.org>
Committed: Tue Sep 1 06:32:52 2015 -0700

----------------------------------------------------------------------
 .../framework/recipes/leader/TestLeaderSelector.java   | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/49b267d1/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
index e5b9717..cd76bc1 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java
@@ -37,6 +37,7 @@ import org.apache.curator.utils.CloseableUtils;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 import org.testng.internal.annotations.Sets;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.ArrayBlockingQueue;
@@ -103,8 +104,10 @@ public class TestLeaderSelector extends BaseClassForTests
             Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS),
ConnectionState.CONNECTED.name());
             Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS),
"leader");
             server.close();
-            Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS),
ConnectionState.SUSPENDED.name());
-            Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS),
"release");
+            List<String> next = Lists.newArrayList();
+            next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
+            next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
+            Assert.assertTrue(next.equals(Arrays.asList(ConnectionState.SUSPENDED.name(),
"release")) || next.equals(Arrays.asList("release", ConnectionState.SUSPENDED.name())), next.toString());
             Assert.assertEquals(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS),
ConnectionState.LOST.name());
 
             selector.close();
@@ -130,8 +133,10 @@ public class TestLeaderSelector extends BaseClassForTests
             Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS),
"leader");
             server.stop();
             Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS),
ConnectionState.SUSPENDED.name());
-            Assert.assertEquals(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS),
ConnectionState.LOST.name());
-            Assert.assertEquals(changes.poll(timing.forWaiting().milliseconds(), TimeUnit.MILLISECONDS),
"release");
+            next = Lists.newArrayList();
+            next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
+            next.add(changes.poll(timing.forSessionSleep().milliseconds(), TimeUnit.MILLISECONDS));
+            Assert.assertTrue(next.equals(Arrays.asList(ConnectionState.LOST.name(), "release"))
|| next.equals(Arrays.asList("release", ConnectionState.LOST.name())), next.toString());
         }
         finally
         {


Mime
View raw message