Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8333618558 for ; Thu, 31 Mar 2016 22:44:33 +0000 (UTC) Received: (qmail 68868 invoked by uid 500); 31 Mar 2016 22:44:33 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 68835 invoked by uid 500); 31 Mar 2016 22:44:33 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 68826 invoked by uid 99); 31 Mar 2016 22:44:33 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Mar 2016 22:44:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id E8555C1CD7 for ; Thu, 31 Mar 2016 22:44:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.216 X-Spam-Level: X-Spam-Status: No, score=-4.216 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.996] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id fqVZgzGzvJgN for ; Thu, 31 Mar 2016 22:44:32 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with SMTP id C31A95F571 for ; Thu, 31 Mar 2016 22:44:31 +0000 (UTC) Received: (qmail 68807 invoked by uid 99); 31 Mar 2016 22:44:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 31 Mar 2016 22:44:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CCCABE03A9; Thu, 31 Mar 2016 22:44:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dschneider@apache.org To: commits@geode.incubator.apache.org Date: Thu, 31 Mar 2016 22:45:32 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [65/71] [abbrv] incubator-geode git commit: GEODE-1152: improve javadocs with guidelines for Awaitility GEODE-1152: improve javadocs with guidelines for Awaitility Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7708c3f9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7708c3f9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7708c3f9 Branch: refs/heads/feature/GEODE-915 Commit: 7708c3f94c44736c7d3b21a7b4c9bbf0fd64c815 Parents: 51acabc Author: Kirk Lund Authored: Wed Mar 30 17:31:23 2016 -0700 Committer: Kirk Lund Committed: Thu Mar 31 10:31:46 2016 -0700 ---------------------------------------------------------------------- .../com/gemstone/gemfire/test/dunit/Wait.java | 70 +++++++++++++++++++- .../gemfire/test/dunit/WaitCriterion.java | 12 +++- 2 files changed, 78 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7708c3f9/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java index 3e218df..b73a25c 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/Wait.java @@ -28,7 +28,7 @@ import com.gemstone.gemfire.internal.logging.LogService; * Wait provides static utility methods to wait for some * asynchronous action with intermittent polling. * - * These methods can be used directly: Wait.waitForCriterion(...), + * These methods can be used directly: Wait.waitForCriterion(...), * however, they are intended to be referenced through static import: * *
@@ -38,8 +38,74 @@ import com.gemstone.gemfire.internal.logging.LogService;
  * 
* * Extracted from DistributedTestCase. - * + * + *

Deprecated in favor of using {@link com.jayway.awaitility.Awaitility}. + * + *

Examples of using Awaitility:

+ *
+ * import static com.jayway.awaitility.Awaitility.*;
+ * import static com.jayway.awaitility.Duration.*; // optional
+ * import static java.util.concurrent.TimeUnit.*; // optional
+ *
+ * await().atMost(2, SECONDS).until(() -> isDone());
+ *
+ * Host.getHost(0).getVM(0).invoke(() -> await().atMost(1, MINUTES).until(() -> isDone()));
+ *
+ * Host.getHost(0).getVM(0).invoke(() -> await("waiting for 4 members").atMost(5, SECONDS).until(() -> getMemberCount(), is(4)));
+ *
+ * await().atMost(5, SECONDS).untilCall(getValue(), equalTo(5));
+ *
+ * volatile boolean done = false;
+ * await().atMost(2, SECONDS).untilCall(Boolean.class, equalTo(this.done));
+ *
+ * AtomicBoolean closed = new AtomicBoolean();
+ * await().atMost(5, SECONDS).untilTrue(closed);
+ *
+ * AtomicBoolean running = new AtomicBoolean();
+ * await().atMost(30, SECONDS).untilFalse(running);
+ *
+ * List members = new ArrayList();
+ * await().untilCall(to(members).size(), greaterThan(2));
+ * 
+ * + *

NOTE: By default, the pollDelay is equal to the pollInterval which defaults to + * ONE_HUNDRED_MILLISECONDS. You may want to add pollDelay(ZERO) to force + * Awaitility to check your condition before waiting the pollInterval. + * + *

Example of detailed conversion to Awaitility:

+ * From:
+ *
+ * public boolean waitForClose() {
+ *   WaitCriterion ev = new WaitCriterion() {
+ *     public boolean done() {
+ *       return isClosed();
+ *     }
+ *     public String description() {
+ *       return "resource never closed";
+ *     }
+ *   };
+ *   Wait.waitForCriterion(ev, 2000, 200, true);
+ *   return true;
+ * }
+ *
+ * To:
+ *
+ * import static com.jayway.awaitility.Awaitility.*;
+ * import static com.jayway.awaitility.Duration.*;
+ * import static java.util.concurrent.TimeUnit.*;
+ *
+ * await("resource never closed").atMost(2, SECONDS).untilCall(() -> isClosed());
+ *
+ * Or:
+ *
+ * await("resource never closed").atMost(2, SECONDS).pollDelay(ZERO).pollInterval(200, MILLISECONDS).untilCall(() -> isClosed());
+ * 
+ * * @deprecated Use {@link com.jayway.awaitility.Awaitility} instead. + * + * @see com.jayway.awaitility.Awaitility + * @see com.jayway.awaitility.Duration + * @see com.jayway.awaitility.core.ConditionFactory */ @Deprecated public class Wait { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7708c3f9/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java index 7575f8c..e62d354 100755 --- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/WaitCriterion.java @@ -20,9 +20,17 @@ package com.gemstone.gemfire.test.dunit; * Defines an asynchronous criterion to wait for by invoking a method in * {@link Wait}. * - * Extracted from DistributedTestCase. - * + *

Extracted from DistributedTestCase. + * + *

See javadocs on {@link Wait} for examples and guidelines for converting + * to Awaitility. + * * @deprecated Use {@link com.jayway.awaitility.Awaitility} instead. + * + * @see Wait + * @see com.jayway.awaitility.Awaitility + * @see com.jayway.awaitility.Duration + * @see com.jayway.awaitility.core.ConditionFactory */ public interface WaitCriterion {