geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aging...@apache.org
Subject [25/60] [abbrv] incubator-geode git commit: GEODE-710: Replaced thread.sleep with Awaitility
Date Tue, 03 May 2016 21:45:39 GMT
GEODE-710: Replaced thread.sleep with Awaitility

* Replaced thread.sleep with awaitility.
* Place an awaitility to wait for the isCancelled flag to be true before
checking the counter values.

This closes #134


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/20117a80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/20117a80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/20117a80

Branch: refs/heads/feature/GEODE-1209
Commit: 20117a80387095194b80ddf9c8dc6c2cdba8c91a
Parents: 55d8b9f
Author: nabarun <nnag@pivotal.io>
Authored: Wed Apr 20 14:07:39 2016 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Apr 27 16:01:04 2016 -0700

----------------------------------------------------------------------
 ...ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/20117a80/geode-core/src/test/java/com/gemstone/gemfire/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
index 8cddfa6..5aaa124 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/ScheduledThreadPoolExecutorWithKeepAliveJUnitTest.java
@@ -35,6 +35,7 @@ import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.test.junit.categories.FlakyTest;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+import com.jayway.awaitility.Awaitility;
 
 @Category(IntegrationTest.class)
 public class ScheduledThreadPoolExecutorWithKeepAliveJUnitTest {
@@ -190,9 +191,12 @@ public class ScheduledThreadPoolExecutorWithKeepAliveJUnitTest {
       }
     };
     ScheduledFuture f = ex.scheduleAtFixedRate(run, 0, 1, TimeUnit.SECONDS);
-    Thread.sleep(5000);
-    f.cancel(true);
-    assertTrue("Task was not executed repeatedly", counter.get() > 1);
+    Awaitility.await().atMost(30,TimeUnit.SECONDS).until(() -> assertEquals("Task was
not executed repeatedly"
+      ,true, counter.get() > 1));
+    Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> assertEquals("The task
could not be cancelled"
+      ,true, f.cancel(true)));
+    Awaitility.await().atMost(30,TimeUnit.SECONDS).until(() -> assertEquals("Task was
not cancelled within 30 sec"
+      ,true,f.isCancelled()));
     int oldValue = counter.get();
     Thread.sleep(5000);
     assertEquals("Task was not cancelled", oldValue, counter.get());


Mime
View raw message