You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ca...@apache.org on 2015/08/25 06:09:04 UTC

[44/50] curator git commit: testRequeuingWithLock was too dependent on timing. Created a better way to test the condition

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/CURATOR-167
Commit: 2a39a45d48dd9e581276ee22dbe6e036063122b4
Parents: e8aff9a
Author: randgalt <ra...@apache.org>
Authored: Fri Aug 21 12:33:59 2015 -0500
Committer: randgalt <ra...@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