You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by go...@apache.org on 2018/08/24 00:49:30 UTC
[geode] branch develop updated: GEODE-5627: ConcurrencyRule passes
when not used. (#2370)
This is an automated email from the ASF dual-hosted git repository.
gosullivan pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new cfa7ca5 GEODE-5627: ConcurrencyRule passes when not used. (#2370)
cfa7ca5 is described below
commit cfa7ca5da13a07ca99562b3bfdf32efe1c1414e7
Author: Galen O'Sullivan <go...@pivotal.io>
AuthorDate: Thu Aug 23 17:49:23 2018 -0700
GEODE-5627: ConcurrencyRule passes when not used. (#2370)
Before this, if ConcurrencyRule was used for a test it failed because
`allthreadsExecuted` was `false`.
Also delegate to the non-default constructor with the default
constructor.
---
.../java/org/apache/geode/test/junit/rules/ConcurrencyRule.java | 8 ++------
.../org/apache/geode/test/junit/rules/ConcurrencyRuleTest.java | 7 +++++++
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java
index d17096b..17579d6 100644
--- a/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java
+++ b/geode-junit/src/main/java/org/apache/geode/test/junit/rules/ConcurrencyRule.java
@@ -88,11 +88,7 @@ public class ConcurrencyRule extends SerializableExternalResource {
* A default constructor that sets the timeout to a default of 30 seconds
*/
public ConcurrencyRule() {
- toInvoke = new ArrayList<>();
- futures = new ArrayList<>();
- timeout = Duration.ofSeconds(300);
- errorCollector = new ProtectedErrorCollector();
- allThreadsExecuted.set(false);
+ this(Duration.ofSeconds(300));
}
/**
@@ -106,7 +102,7 @@ public class ConcurrencyRule extends SerializableExternalResource {
futures = new ArrayList<>();
this.timeout = timeout;
errorCollector = new ProtectedErrorCollector();
- allThreadsExecuted.set(false);
+ allThreadsExecuted.set(true);
}
@Override
diff --git a/geode-junit/src/test/java/org/apache/geode/test/junit/rules/ConcurrencyRuleTest.java b/geode-junit/src/test/java/org/apache/geode/test/junit/rules/ConcurrencyRuleTest.java
index 9607bff..b1d6cef 100644
--- a/geode-junit/src/test/java/org/apache/geode/test/junit/rules/ConcurrencyRuleTest.java
+++ b/geode-junit/src/test/java/org/apache/geode/test/junit/rules/ConcurrencyRuleTest.java
@@ -442,6 +442,13 @@ public class ConcurrencyRuleTest {
concurrencyRule.clear(); // so that this test's after succeeds
}
+ /**
+ * There was an issue where the rule would fail a test if it had never been used. This is an issue
+ * for test classes like this one, where the rule is used for some tests and not for others.
+ */
+ @Test
+ public void afterSucceedsIfRuleWasNotUsed() {}
+
@SuppressWarnings("unused")
private enum Execution {
EXECUTE_IN_SERIES(concurrencyRule -> {