You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ag...@apache.org on 2016/05/03 23:45:39 UTC
[25/60] [abbrv] incubator-geode git commit: GEODE-710: Replaced
thread.sleep with Awaitility
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 <nn...@pivotal.io>
Authored: Wed Apr 20 14:07:39 2016 -0700
Committer: Dan Smith <up...@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());