curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject curator git commit: testRequeuingWithLock was too dependent on timing. Created a better way to test the condition
Date Fri, 21 Aug 2015 17:34:33 GMT
Repository: curator
Updated Branches:
  refs/heads/master e8aff9a60 -> 2a39a45d4


testRequeuingWithLock was too dependent on timing. Created a better way to test the condition


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

Branch: refs/heads/master
Commit: 2a39a45d48dd9e581276ee22dbe6e036063122b4
Parents: e8aff9a
Author: randgalt <randgalt@apache.org>
Authored: Fri Aug 21 12:33:59 2015 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Fri Aug 21 12:33:59 2015 -0500

----------------------------------------------------------------------
 .../framework/recipes/queue/DistributedIdQueue.java  | 15 +++++++++++++++
 .../recipes/queue/TestDistributedIdQueue.java        |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/2a39a45d/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedIdQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedIdQueue.java
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedIdQueue.java
index a83fa36..dbd8e6e 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedIdQueue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/queue/DistributedIdQueue.java
@@ -18,6 +18,7 @@
  */
 package org.apache.curator.framework.recipes.queue;
 
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.listen.ListenerContainer;
@@ -183,6 +184,20 @@ public class DistributedIdQueue<T> implements QueueBase<T>
         return count;
     }
 
+    @VisibleForTesting
+    boolean debugIsQueued(String id) throws Exception
+    {
+        for ( String name : queue.getChildren() )
+        {
+            if ( parseId(name).id.equals(id) )
+            {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private void internalSortChildren(List<String> children)
     {
         Collections.sort

http://git-wip-us.apache.org/repos/asf/curator/blob/2a39a45d/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
index 858086b..24f74a1 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/queue/TestDistributedIdQueue.java
@@ -162,7 +162,7 @@ public class TestDistributedIdQueue extends BaseClassForTests
 
             Thread.sleep(1000);
 
-            Assert.assertEquals(queue.remove("id"), 1);
+            Assert.assertTrue(queue.debugIsQueued("id"));
 
         }
         finally


Mime
View raw message