curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From randg...@apache.org
Subject [16/29] git commit: More tightening of tests
Date Fri, 23 May 2014 15:07:17 GMT
More tightening of tests


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

Branch: refs/heads/CURATOR-105
Commit: 78cf189c7afdd68bd4ccd468f0df61412aaf6fa8
Parents: 460a9b3
Author: randgalt <randgalt@apache.org>
Authored: Thu May 15 15:28:17 2014 -0500
Committer: randgalt <randgalt@apache.org>
Committed: Thu May 15 15:28:17 2014 -0500

----------------------------------------------------------------------
 .../recipes/locks/TestInterProcessSemaphore.java     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/78cf189c/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
index 559b012..798cb3e 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessSemaphore.java
@@ -473,11 +473,11 @@ public class TestInterProcessSemaphore extends BaseClassForTests
         final int MAX_LEASES = 3;
         Timing timing = new Timing();
 
+        List<Lease> leases = Lists.newArrayList();
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
timing.session(), timing.connection(), new RetryOneTime(1));
         client.start();
         try
         {
-            List<Lease> leases = Lists.newArrayList();
             for ( int i = 0; i < MAX_LEASES; ++i )
             {
                 InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test",
MAX_LEASES);
@@ -495,7 +495,11 @@ public class TestInterProcessSemaphore extends BaseClassForTests
         }
         finally
         {
-            client.close();
+            for ( Lease l : leases )
+            {
+                CloseableUtils.closeQuietly(l);
+            }
+            CloseableUtils.closeQuietly(client);
         }
     }
 
@@ -506,19 +510,24 @@ public class TestInterProcessSemaphore extends BaseClassForTests
 
         Timing timing = new Timing();
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(),
timing.session(), timing.connection(), new RetryOneTime(1));
+        List<Lease> leases = Lists.newArrayList();
         client.start();
         try
         {
             InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test",
LEASES);
             for ( int i = 0; i < LEASES; ++i )
             {
-                semaphore.acquire();
+                leases.add(semaphore.acquire());
             }
 
             Assert.assertEquals(semaphore.getParticipantNodes().size(), LEASES);
         }
         finally
         {
+            for ( Lease l : leases )
+            {
+                CloseableUtils.closeQuietly(l);
+            }
             CloseableUtils.closeQuietly(client);
         }
     }


Mime
View raw message