You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/03/01 01:09:50 UTC
[5/7] incubator-geode git commit: GEODE-953: Cleanup geode-junit
GEODE-953: Cleanup geode-junit
* cleanup geode-junit usage of JUnit Rules to ensure JUnit code is always extended rather than copied
* change CRLF to LF
* remove @author tags
* fix all javadocs
* fix formatting
* add new tests
* remove ExpectedTimeout and ExpectedTimeoutTest (they were dupes of ExpectedTimeoutRule and ExpectedTimeoutRuleTest)
* use serialization by reflection for serializable subclasses of JUnit rules that lack sufficient ability to subclass
* repackage rule tests to same package as rules
* repackage serializable rules into serializable sub-package
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/5342935d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/5342935d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/5342935d
Branch: refs/heads/feature/GEODE-949-2
Commit: 5342935d301a4026b289637885e9236414feeb78
Parents: 1e31fa6
Author: Kirk Lund <kl...@pivotal.io>
Authored: Mon Feb 29 13:06:11 2016 -0800
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Mon Feb 29 13:06:11 2016 -0800
----------------------------------------------------------------------
.../internal/process/PidFileJUnitTest.java | 4 +-
.../dunit/rules/DistributedDisconnectRule.java | 44 +-
.../rules/DistributedExternalResource.java | 27 +-
.../DistributedRestoreSystemProperties.java | 5 +-
.../gemfire/test/dunit/rules/RemoteInvoker.java | 10 +-
geode-junit/build.gradle | 1 +
.../gemfire/test/junit/ConditionalIgnore.java | 1 -
.../gemfire/test/junit/IgnoreCondition.java | 1 -
.../gemfire/test/junit/IgnoreUntil.java | 1 -
.../com/gemstone/gemfire/test/junit/Repeat.java | 3 +-
.../com/gemstone/gemfire/test/junit/Retry.java | 4 +-
.../test/junit/categories/ContainerTest.java | 3 +-
.../test/junit/categories/DistributedTest.java | 3 +-
.../categories/DistributedTransactionsTest.java | 3 +-
.../test/junit/categories/HydraTest.java | 3 +-
.../test/junit/categories/IntegrationTest.java | 3 +-
.../test/junit/categories/PerformanceTest.java | 3 +-
.../gemfire/test/junit/categories/UITest.java | 3 +-
.../gemfire/test/junit/categories/UnitTest.java | 13 +-
.../gemfire/test/junit/categories/WanTest.java | 5 +-
.../test/junit/rules/ConditionalIgnoreRule.java | 1 -
.../test/junit/rules/ExpectedTimeout.java | 180 --------
.../test/junit/rules/ExpectedTimeoutRule.java | 42 +-
.../test/junit/rules/IgnoreUntilRule.java | 1 -
.../gemfire/test/junit/rules/RepeatRule.java | 3 +-
.../gemfire/test/junit/rules/RetryRule.java | 1 -
.../gemfire/test/junit/rules/RuleList.java | 95 +++++
.../rules/SerializableExternalResource.java | 107 -----
.../test/junit/rules/SerializableRuleChain.java | 119 ------
.../rules/SerializableTemporaryFolder.java | 70 ----
.../test/junit/rules/SerializableTestName.java | 54 ---
.../test/junit/rules/SerializableTestRule.java | 33 --
.../junit/rules/SerializableTestWatcher.java | 29 --
.../test/junit/rules/SerializableTimeout.java | 119 ------
.../serializable/FieldSerializationUtils.java | 48 +++
.../serializable/FieldsOfTemporaryFolder.java | 26 ++
.../rules/serializable/FieldsOfTestName.java | 24 ++
.../rules/serializable/FieldsOfTimeout.java | 26 ++
.../SerializableExternalResource.java | 25 ++
.../serializable/SerializableRuleList.java | 78 ++++
.../SerializableTemporaryFolder.java | 70 ++++
.../serializable/SerializableTestName.java | 65 +++
.../serializable/SerializableTestRule.java | 28 ++
.../serializable/SerializableTestWatcher.java | 26 ++
.../rules/serializable/SerializableTimeout.java | 104 +++++
.../junit/support/DefaultIgnoreCondition.java | 3 +-
.../IgnoreConditionEvaluationException.java | 1 -
.../junit/rules/ExpectedTimeoutJUnitTest.java | 204 ---------
.../junit/rules/ExpectedTimeoutRuleTest.java | 246 +++++++++++
.../test/junit/rules/IgnoreUntilRuleTest.java | 145 +++++++
.../test/junit/rules/RepeatRuleTest.java | 411 +++++++++++++++++++
.../rules/RetryRuleGlobalWithErrorTest.java | 326 +++++++++++++++
.../rules/RetryRuleGlobalWithExceptionTest.java | 332 +++++++++++++++
.../rules/RetryRuleLocalWithErrorTest.java | 265 ++++++++++++
.../rules/RetryRuleLocalWithExceptionTest.java | 276 +++++++++++++
.../gemfire/test/junit/rules/RuleListTest.java | 206 ++++++++++
.../gemfire/test/junit/rules/TestRunner.java | 35 ++
.../examples/RepeatingTestCasesExampleTest.java | 15 +-
.../rules/examples/RetryRuleExampleTest.java | 20 +-
.../rules/examples/RuleAndClassRuleTest.java | 147 +++++++
.../SerializableExternalResourceTest.java | 79 ++++
.../serializable/SerializableRuleListTest.java | 89 ++++
.../SerializableTemporaryFolderTest.java | 90 ++++
.../serializable/SerializableTestNameTest.java | 84 ++++
.../SerializableTestWatcherTest.java | 79 ++++
.../serializable/SerializableTimeoutTest.java | 106 +++++
.../rules/tests/ExpectedTimeoutRuleTest.java | 214 ----------
.../junit/rules/tests/IgnoreUntilRuleTest.java | 121 ------
.../junit/rules/tests/JUnitRuleTestSuite.java | 33 --
.../test/junit/rules/tests/RepeatRuleTest.java | 304 --------------
.../tests/RetryRuleGlobalWithErrorTest.java | 250 -----------
.../tests/RetryRuleGlobalWithExceptionTest.java | 254 ------------
.../tests/RetryRuleLocalWithErrorTest.java | 207 ----------
.../tests/RetryRuleLocalWithExceptionTest.java | 213 ----------
.../junit/rules/tests/RuleAndClassRuleTest.java | 138 -------
.../test/junit/rules/tests/TestRunner.java | 37 --
76 files changed, 3620 insertions(+), 2824 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
index 5f81c2b..2906b0e 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
@@ -42,7 +42,7 @@ import org.junit.rules.TemporaryFolder;
import com.gemstone.gemfire.internal.util.StopWatch;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.ExpectedTimeout;
+import com.gemstone.gemfire.test.junit.rules.ExpectedTimeoutRule;
/**
* Unit tests the PidFile class.
@@ -60,7 +60,7 @@ public class PidFileJUnitTest {
public ExpectedException thrown = ExpectedException.none();
@Rule
- public ExpectedTimeout timeout = ExpectedTimeout.none();
+ public ExpectedTimeoutRule timeout = ExpectedTimeoutRule.none();
protected Mockery mockContext;
private ExecutorService futures;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedDisconnectRule.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedDisconnectRule.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedDisconnectRule.java
index 125fc06..47e5175 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedDisconnectRule.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedDisconnectRule.java
@@ -16,18 +16,18 @@
*/
package com.gemstone.gemfire.test.dunit.rules;
-// TODO: import static com.gemstone.gemfire.test.dunit.DistributedTestRule.*;
+// TODO:uncomment: import static com.gemstone.gemfire.test.dunit.DistributedTestRule.*;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-@SuppressWarnings("serial")
+/**
+ * Disconnects all remote DUnit JVMs including the Locator JVM.
+ */
public class DistributedDisconnectRule extends DistributedExternalResource {
private final boolean disconnectBefore;
private final boolean disconnectAfter;
- private final boolean disconnectBeforeClass;
- private final boolean disconnectAfterClass;
-
+
public static Builder builder() {
return new Builder();
}
@@ -38,8 +38,6 @@ public class DistributedDisconnectRule extends DistributedExternalResource {
public DistributedDisconnectRule(final RemoteInvoker invoker, final Builder builder) {
super(invoker);
- this.disconnectBeforeClass = builder.disconnectBeforeClass;
- this.disconnectAfterClass = builder.disconnectAfterClass;
this.disconnectBefore = builder.disconnectBefore;
this.disconnectAfter = builder.disconnectAfter;
}
@@ -52,63 +50,35 @@ public class DistributedDisconnectRule extends DistributedExternalResource {
}
@Override
- protected void after() throws Throwable {
+ protected void after() {
if (this.disconnectAfter) {
invoker().invokeEverywhere(serializableRunnable());
}
}
- @Override
- protected void beforeClass() throws Throwable {
- if (this.disconnectBeforeClass) {
- invoker().invokeEverywhere(serializableRunnable());
- }
- }
-
- @Override
- protected void afterClass() throws Throwable {
- if (this.disconnectAfterClass) {
- invoker().invokeEverywhere(serializableRunnable());
- }
- }
-
private static SerializableRunnable serializableRunnable() {
return new SerializableRunnable() {
@Override
public void run() {
- // TODO: disconnectFromDS();
+ // TODO:uncomment: disconnectFromDS();
}
};
}
/**
* Builds an instance of DistributedDisconnectRule
- *
- * @author Kirk Lund
*/
public static class Builder {
- private boolean disconnectBeforeClass;
- private boolean disconnectAfterClass;
private boolean disconnectBefore;
private boolean disconnectAfter;
public Builder() {}
- public Builder disconnectBeforeClass(final boolean disconnectBeforeClass) {
- this.disconnectBeforeClass = disconnectBeforeClass;
- return this;
- }
-
public Builder disconnectBefore(final boolean disconnectBefore) {
this.disconnectBefore = disconnectBefore;
return this;
}
- public Builder disconnectAfterClass(final boolean disconnectAfterClass) {
- this.disconnectAfterClass = disconnectAfterClass;
- return this;
- }
-
public Builder disconnectAfter(final boolean disconnectAfter) {
this.disconnectAfter = disconnectAfter;
return this;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedExternalResource.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedExternalResource.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedExternalResource.java
index d3b7319..a7c3598 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedExternalResource.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedExternalResource.java
@@ -16,9 +16,12 @@
*/
package com.gemstone.gemfire.test.dunit.rules;
-import com.gemstone.gemfire.test.junit.rules.SerializableExternalResource;
+import com.gemstone.gemfire.test.junit.rules.serializable.SerializableExternalResource;
-@SuppressWarnings("serial")
+/**
+ * Distributed version of SerializableExternalResource which affects all remote
+ * DUnit JVMs including the Locator JVM.
+ */
public class DistributedExternalResource extends SerializableExternalResource {
private final RemoteInvoker invoker;
@@ -35,24 +38,4 @@ public class DistributedExternalResource extends SerializableExternalResource {
protected RemoteInvoker invoker() {
return this.invoker;
}
-
- @Override
- protected void before() throws Throwable {
- // do nothing
- }
-
- @Override
- protected void after() throws Throwable {
- // do nothing
- }
-
- @Override
- protected void beforeClass() throws Throwable {
- // do nothing
- }
-
- @Override
- protected void afterClass() throws Throwable {
- // do nothing
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
index 1711b21..7f95fad 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
@@ -24,15 +24,12 @@ import java.util.Properties;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.junit.rules.SerializableTestRule;
+import com.gemstone.gemfire.test.junit.rules.serializable.SerializableTestRule;
/**
* Distributed version of RestoreSystemProperties which affects all DUnit
* JVMs including the Locator JVM.
- *
- * @author Kirk Lund
*/
-@SuppressWarnings("serial")
public class DistributedRestoreSystemProperties extends RestoreSystemProperties implements SerializableTestRule {
private static volatile Properties originalProperties;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
index 9e3c5b2..98dbc2f 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
@@ -23,8 +23,14 @@ import java.io.Serializable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-@SuppressWarnings("serial")
-public class RemoteInvoker implements Serializable {
+/**
+ * Provides remote invocation support to a {@code TestRule}. These methods
+ * will invoke a SerializableRunnable in all remote DUnit JVMs including the
+ * Locator JVM.
+ */
+class RemoteInvoker implements Serializable {
+
+ private static final long serialVersionUID = -1759722991299584649L;
public void invokeEverywhere(final SerializableRunnable runnable) {
try {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/build.gradle
----------------------------------------------------------------------
diff --git a/geode-junit/build.gradle b/geode-junit/build.gradle
index 112d112..7aa6562 100755
--- a/geode-junit/build.gradle
+++ b/geode-junit/build.gradle
@@ -16,6 +16,7 @@
*/
dependencies {
+ testCompile 'commons-lang:commons-lang:' + project.'commons-lang.version'
compile 'junit:junit:' + project.'junit.version'
compile 'org.hamcrest:hamcrest-all:' + project.'hamcrest-all.version'
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/ConditionalIgnore.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/ConditionalIgnore.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/ConditionalIgnore.java
index b409cb1..5e037c7 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/ConditionalIgnore.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/ConditionalIgnore.java
@@ -29,7 +29,6 @@ import com.gemstone.gemfire.test.junit.support.DefaultIgnoreCondition;
* conditionally ignore the test case for a fixed amount of time, or based on a predetermined condition provided by
* the IgnoreCondition interface.
*
- * @author John Blum
* @see java.lang.annotation.Annotation
* @see com.gemstone.gemfire.test.junit.IgnoreCondition
* @see com.gemstone.gemfire.test.junit.support.DefaultIgnoreCondition
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreCondition.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreCondition.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreCondition.java
index 0caa959..15e507e 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreCondition.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreCondition.java
@@ -21,7 +21,6 @@ import org.junit.runner.Description;
/**
* The IgnoreCondition class...
*
- * @author John Blum
* @see org.junit.runner.Description
*/
@SuppressWarnings("unused")
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreUntil.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreUntil.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreUntil.java
index 5910d10..e60e92f 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreUntil.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/IgnoreUntil.java
@@ -29,7 +29,6 @@ import com.gemstone.gemfire.test.junit.support.DefaultIgnoreCondition;
* conditionally ignore the test case for a fixed amount of time, or based on a predetermined condition provided by
* the IgnoreCondition interface.
*
- * @author John Blum
* @see java.lang.annotation.Annotation
* @see com.gemstone.gemfire.test.junit.IgnoreCondition
* @see com.gemstone.gemfire.test.junit.support.DefaultIgnoreCondition
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Repeat.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Repeat.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Repeat.java
index 5cfa321..fc5c441 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Repeat.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Repeat.java
@@ -26,12 +26,11 @@ import java.lang.annotation.Target;
* The Repeat class is a Java Annotation enabling an annotated test suite class test case method to be repeated
* a specified number of iterations.
*
- * @author John Blum
* @see java.lang.annotation.Annotation
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD })
+@Target(ElementType.METHOD)
@SuppressWarnings("unused")
public @interface Repeat {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Retry.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Retry.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Retry.java
index 65f3cf6..6039943 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Retry.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Retry.java
@@ -23,8 +23,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Java Annotation used to annotate a test suite class test case method in order to
- * retry it in case of failure up to the specified maximum attempts.
+ * Java Annotation used to annotate a test method in order to retry failures
+ * up to the specified maximum attempts. Default maximum attempts is one retry.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/ContainerTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/ContainerTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/ContainerTest.java
index 8eec738..7d593b5 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/ContainerTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/ContainerTest.java
@@ -15,11 +15,10 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
* JUnit Test Category that specifies a test executes within a container
* environment such as an OSGi server.
- *
- * @author Kirk Lund
*/
public interface ContainerTest {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTest.java
old mode 100644
new mode 100755
index 6aa538b..b4ec17c
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTest.java
@@ -15,11 +15,10 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
* JUnit Test Category that specifies a test involving multiple members of a
* distributed system.
- *
- * @author Kirk Lund
*/
public interface DistributedTest {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTransactionsTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTransactionsTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTransactionsTest.java
old mode 100644
new mode 100755
index 1892ddd..d9cb447
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTransactionsTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTransactionsTest.java
@@ -17,9 +17,8 @@
package com.gemstone.gemfire.test.junit.categories;
/**
- * Unit test category that specifies tests for distributed transactions
+ * JUnit Test Category that specifies tests for distributed transactions
* functionality
- * @author shirishd
*/
public interface DistributedTransactionsTest {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/HydraTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/HydraTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/HydraTest.java
index 4fe535b..7293ed7 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/HydraTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/HydraTest.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
* JUnit Test Category that specifies a hydra test.
- *
- * @author Kirk Lund
*/
public interface HydraTest {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/IntegrationTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/IntegrationTest.java
old mode 100644
new mode 100755
index 1be6e45..d2f8e04
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/IntegrationTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/IntegrationTest.java
@@ -15,11 +15,10 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
* JUnit Test Category that specifies a test involving inter-operation of
* components or subsystems.
- *
- * @author Kirk Lund
*/
public interface IntegrationTest {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/PerformanceTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/PerformanceTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/PerformanceTest.java
old mode 100644
new mode 100755
index ad952be..5785395
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/PerformanceTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/PerformanceTest.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
* JUnit Test Category that specifies a test that measures performance.
- *
- * @author Kirk Lund
*/
public interface PerformanceTest {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UITest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UITest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UITest.java
old mode 100644
new mode 100755
index 834931a..822272e
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UITest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UITest.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
* JUnit Test Category that specifies a test involving a browser present to test the UI
- *
- * @author Jinmei Liao
*/
public interface UITest {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UnitTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UnitTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UnitTest.java
old mode 100644
new mode 100755
index d5be9e8..3b81dd6
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UnitTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UnitTest.java
@@ -15,11 +15,20 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
* JUnit Test Category that specifies a test with very narrow and well defined
* scope. Any complex dependencies and interactions are stubbed or mocked.
- *
- * @author Kirk Lund
+ *
+ * <p><ul>A {@code UnitTest} should <bold>not<bold> do any of the following:
+ * <li>communicate with a database
+ * <li>communicate across the network
+ * <li>access the file system
+ * <li>prevent the running of other unit tests in parallel
+ * <li>require anything special in the environment (such as editing config files or running an external process)
+ * </ul>
+ *
+ * @see <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=126923">A Set of Unit Testing Rules by Michael Feathers</a>
*/
public interface UnitTest {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/WanTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/WanTest.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/WanTest.java
old mode 100644
new mode 100755
index 9abf15b..6f75e87
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/WanTest.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/WanTest.java
@@ -15,10 +15,9 @@
* limitations under the License.
*/
package com.gemstone.gemfire.test.junit.categories;
+
/**
- * Tests Wan Feature.
- *
- * @author Kirk Lund
+ * JUnit Test Category that specifies a test that involves Wan feature.
*/
public interface WanTest {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
index 80898b5..6c354d2 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
@@ -33,7 +33,6 @@ import com.gemstone.gemfire.test.junit.support.IgnoreConditionEvaluationExceptio
/**
* The ConditionalIgnoreRule class...
*
- * @author John Blum
* @see org.junit.rules.TestRule
* @see org.junit.runner.Description
* @see org.junit.runners.model.Statement
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java
deleted file mode 100755
index 2f53811..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeout.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import static org.junit.Assert.assertThat;
-
-import java.util.concurrent.TimeUnit;
-
-import org.hamcrest.Matcher;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Expect an Exception within a specified timeout.
- *
- * @author Kirk Lund
- * @since 8.2
- */
-public class ExpectedTimeout implements TestRule {
-
- /**
- * @return a Rule that expects no timeout (identical to behavior without this Rule)
- */
- public static ExpectedTimeout none() {
- return new ExpectedTimeout();
- }
-
- private ExpectedException delegate;
- private boolean expectsThrowable;
- private long minDuration;
- private long maxDuration;
- private TimeUnit timeUnit;
-
- private ExpectedTimeout() {
- this.delegate = ExpectedException.none();
- }
-
- public ExpectedTimeout expectMinimumDuration(final long minDuration) {
- this.minDuration = minDuration;
- return this;
- }
- public ExpectedTimeout expectMaximumDuration(final long maxDuration) {
- this.maxDuration = maxDuration;
- return this;
- }
- public ExpectedTimeout expectTimeUnit(final TimeUnit timeUnit) {
- this.timeUnit = timeUnit;
- return this;
- }
-
- public ExpectedTimeout handleAssertionErrors() {
- this.delegate.handleAssertionErrors();
- return this;
- }
-
- public ExpectedTimeout handleAssumptionViolatedExceptions() {
- this.delegate.handleAssumptionViolatedExceptions();
- return this;
- }
-
- /**
- * Adds {@code matcher} to the list of requirements for any thrown
- * exception.
- */
- public void expect(final Matcher<?> matcher) {
- this.delegate.expect(matcher);
- }
-
- /**
- * Adds to the list of requirements for any thrown exception that it should
- * be an instance of {@code type}
- */
- public void expect(final Class<? extends Throwable> type) {
- this.delegate.expect(type);
- this.expectsThrowable = true;
- }
-
- /**
- * Adds to the list of requirements for any thrown exception that it should
- * <em>contain</em> string {@code substring}
- */
- public void expectMessage(final String substring) {
- this.delegate.expectMessage(substring);
- }
-
- /**
- * Adds {@code matcher} to the list of requirements for the message returned
- * from any thrown exception.
- */
- public void expectMessage(final Matcher<String> matcher) {
- this.delegate.expectMessage(matcher);
- }
-
- /**
- * Adds {@code matcher} to the list of requirements for the cause of
- * any thrown exception.
- */
- public void expectCause(final Matcher<? extends Throwable> expectedCause) {
- this.delegate.expectCause(expectedCause);
- }
-
- public boolean expectsTimeout() {
- return minDuration > 0 || maxDuration > 0;
- }
-
- public boolean expectsThrowable() {
- return expectsThrowable = true;
- }
-
- @Override
- public Statement apply(final Statement base, final Description description) {
- Statement next = delegate.apply(base, description);
- return new ExpectedTimeoutStatement(next);
- }
-
- private void handleTime(final Long duration) {
- if (expectsTimeout()) {
- assertThat(timeUnit.convert(duration, TimeUnit.NANOSECONDS), new TimeMatcher(timeUnit, minDuration, maxDuration));
- }
- }
-
- private static class TimeMatcher extends org.hamcrest.TypeSafeMatcher<Long> {
-
- private final TimeUnit timeUnit;
- private final long minDuration;
- private final long maxDuration;
-
- public TimeMatcher(final TimeUnit timeUnit, final long minDuration, final long maxDuration) {
- this.timeUnit = timeUnit;
- this.minDuration = minDuration;
- this.maxDuration = maxDuration;
- }
-
- @Override
- public boolean matchesSafely(final Long duration) {
- return duration >= this.minDuration && duration <= this.maxDuration;
- }
-
- @Override
- public void describeTo(final org.hamcrest.Description description) {
- description.appendText("expects duration to be greater than or equal to ")
- .appendValue(this.minDuration)
- .appendText(" and less than or equal to ")
- .appendValue(this.maxDuration)
- .appendText(" ")
- .appendValue(this.timeUnit);
- }
- }
-
- private class ExpectedTimeoutStatement extends Statement {
- private final Statement next;
-
- public ExpectedTimeoutStatement(final Statement base) {
- next = base;
- }
-
- @Override
- public void evaluate() throws Throwable {
- long start = System.nanoTime();
- next.evaluate();
- handleTime(System.nanoTime() - start);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutRule.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutRule.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutRule.java
index 7b6d345..c7a98b8 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutRule.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutRule.java
@@ -28,9 +28,6 @@ import org.junit.runners.model.Statement;
/**
* Expect an Exception within a specified timeout.
- *
- * @author Kirk Lund
- * @since 8.2
*/
public class ExpectedTimeoutRule implements TestRule {
@@ -64,19 +61,8 @@ public class ExpectedTimeoutRule implements TestRule {
return this;
}
- public ExpectedTimeoutRule handleAssertionErrors() {
- this.delegate.handleAssertionErrors();
- return this;
- }
-
- public ExpectedTimeoutRule handleAssumptionViolatedExceptions() {
- this.delegate.handleAssumptionViolatedExceptions();
- return this;
- }
-
/**
- * Adds {@code matcher} to the list of requirements for any thrown
- * exception.
+ * Adds {@code matcher} to the list of requirements for any thrown exception.
*/
public void expect(final Matcher<?> matcher) {
this.delegate.expect(matcher);
@@ -84,7 +70,7 @@ public class ExpectedTimeoutRule implements TestRule {
/**
* Adds to the list of requirements for any thrown exception that it should
- * be an instance of {@code type}
+ * be an instance of {@code type}.
*/
public void expect(final Class<? extends Throwable> type) {
this.delegate.expect(type);
@@ -115,23 +101,29 @@ public class ExpectedTimeoutRule implements TestRule {
this.delegate.expectCause(expectedCause);
}
- public boolean expectsTimeout() {
- return minDuration > 0 || maxDuration > 0;
+ /**
+ * Returns true if a timeout is expected.
+ */
+ protected boolean expectsTimeout() {
+ return this.minDuration > 0 || this.maxDuration > 0;
}
-
- public boolean expectsThrowable() {
- return expectsThrowable = true;
+
+ /**
+ * Returns true if a Throwable is expected.
+ */
+ protected boolean expectsThrowable() {
+ return this.expectsThrowable;
}
@Override
public Statement apply(final Statement base, final Description description) {
- Statement next = delegate.apply(base, description);
+ Statement next = this.delegate.apply(base, description);
return new ExpectedTimeoutStatement(next);
}
private void handleTime(final Long duration) {
if (expectsTimeout()) {
- assertThat(timeUnit.convert(duration, TimeUnit.NANOSECONDS), new TimeMatcher(timeUnit, minDuration, maxDuration));
+ assertThat(this.timeUnit.convert(duration, TimeUnit.NANOSECONDS), new TimeMatcher(this.timeUnit, this.minDuration, this.maxDuration));
}
}
@@ -167,13 +159,13 @@ public class ExpectedTimeoutRule implements TestRule {
private final Statement next;
public ExpectedTimeoutStatement(final Statement base) {
- next = base;
+ this.next = base;
}
@Override
public void evaluate() throws Throwable {
long start = System.nanoTime();
- next.evaluate();
+ this.next.evaluate();
handleTime(System.nanoTime() - start);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
index bf4ec3f..f6ba368 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
@@ -33,7 +33,6 @@ import com.gemstone.gemfire.test.junit.support.IgnoreConditionEvaluationExceptio
/**
* The IgnoreUntilRule class...
*
- * @author John Blum
* @see org.junit.rules.TestRule
* @see org.junit.runner.Description
* @see org.junit.runners.model.Statement
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
index 7bfe538..8a45979 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
@@ -24,10 +24,9 @@ import org.junit.runners.model.Statement;
import com.gemstone.gemfire.test.junit.Repeat;
/**
- * The RepeatRule class is a JUnit TestRule that enables an appropriately @Repeat annotated test case method
+ * The RepeatRule class is a JUnit TestRule that enables an appropriately {@literal @}Repeat annotated test case method
* to be repeated a specified number of times.
*
- * @author John Blum
* @see org.junit.rules.TestRule
* @see org.junit.runner.Description
* @see org.junit.runners.model.Statement
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
index c885aec..8535fa5 100755
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
@@ -57,7 +57,6 @@ import com.gemstone.gemfire.test.junit.Retry;
* This version of RetryRule will retry a test that fails because of any kind
* of Throwable.
*/
-@SuppressWarnings("serial")
public class RetryRule implements TestRule, Serializable {
/**
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RuleList.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RuleList.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RuleList.java
new file mode 100755
index 0000000..f353d5e
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RuleList.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * The {@code RuleList} rule enables ordering of TestRules.
+ *
+ * <p>Example:
+ *
+ * <pre>
+ * public class SomeTest {
+ *
+ * {@literal @}Rule
+ * public RuleList rules = new RuleList().add(new FirstRule()
+ * .add(new SecondRule()
+ * .add(new ThirdRule();
+ * </pre>
+ */
+public class RuleList implements TestRule {
+
+ private final List<TestRule> rules = new ArrayList<>();
+
+ /**
+ * Creates an empty {@code RuleList}.
+ */
+ public RuleList() {
+ }
+
+ /**
+ * Creates a {@code RuleList} containing a single {@link TestRule}.
+ *
+ * @param rule the first rule of the {@code RuleList}
+ */
+ public RuleList(final TestRule rule) {
+ this.rules.add(rule);
+ }
+
+ /**
+ * Creates a new {@code RuleList} containing the specified {@link TestRule}s.
+ *
+ * @param rules the list of {@code TestRule}s to add
+ */
+ protected RuleList(final List<TestRule> rules) {
+ this.rules.addAll(rules);
+ }
+
+ /**
+ * Adds a new {@code TestRule} to the end of the current {@code RuleList}.
+ *
+ * @param rule the rule to add.
+ * @return the {@code RuleList} with a new TestRule added
+ */
+ public RuleList add(final TestRule rule) {
+ this.rules.add(rule);
+ return this;
+ }
+
+ @Override
+ public Statement apply(Statement base, final Description description) {
+ for (TestRule each : this.rules) {
+ base = each.apply(base, description);
+ }
+ return base;
+ }
+
+ /**
+ * Returns a reference to the actual list of {@code TestRule}s. For use by
+ * subclasses and tests.
+ */
+ protected List<TestRule> rules() {
+ return this.rules;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java
deleted file mode 100755
index 37d8eb5..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Serializable version of ExternalResource JUnit Rule. JUnit lifecycle is not
- * executed in remote JVMs. The <tt>after()</tt> callback has a throws-clause
- * that matches <tt>before()</tt>.
- *
- * Implementation copied from <tt>org.junit.rules.ExternalResource</tt>.
- *
- * @author Kirk Lund
- */
-@SuppressWarnings("serial")
-public abstract class SerializableExternalResource implements SerializableTestRule {
-
- @Override
- public Statement apply(final Statement base, final Description description) {
- if (description.isTest()) {
- return statement(base);
- } else if (description.isSuite()) {
- return statementClass(base);
- }
- return base;
- }
-
- private Statement statement(final Statement base) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- before();
- try {
- base.evaluate();
- } finally {
- after();
- }
- }
- };
- }
-
- private Statement statementClass(final Statement base) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- beforeClass();
- try {
- base.evaluate();
- } finally {
- afterClass();
- }
- }
- };
- }
-
- /**
- * Override to set up your specific external resource.
- *
- * @throws Throwable if setup fails (which will disable {@code after}
- */
- protected void before() throws Throwable {
- // do nothing
- }
-
- /**
- * Override to tear down your specific external resource.
- *
- * @throws Throwable if teardown fails (which will disable {@code after}
- */
- protected void after() throws Throwable {
- // do nothing
- }
-
- /**
- * Override to set up your specific external resource.
- *
- * @throws Throwable if setup fails (which will disable {@code after}
- */
- protected void beforeClass() throws Throwable {
- // do nothing
- }
-
- /**
- * Override to tear down your specific external resource.
- *
- * @throws Throwable if teardown fails (which will disable {@code after}
- */
- protected void afterClass() throws Throwable {
- // do nothing
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableRuleChain.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableRuleChain.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableRuleChain.java
deleted file mode 100755
index 936345e..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableRuleChain.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-/**
- * Serializable version of TemporaryFolder JUnit Rule. JUnit lifecycle is not
- * executed in remote JVMs.
- *
- * Implementation copied from <tt>org.junit.rules.RuleChain</tt>.
- *
- * The SerializableRuleChain rule allows ordering of TestRules. You create a
- * {@code RuleChain} with {@link #outerRule(TestRule)} and subsequent calls of
- * {@link #around(TestRule)}:
- *
- * <pre>
- * public static class UseRuleChain {
- * @Rule
- * public RuleChain chain= RuleChain
- * .outerRule(new LoggingRule("outer rule")
- * .around(new LoggingRule("middle rule")
- * .around(new LoggingRule("inner rule");
- *
- * @Test
- * public void example() {
- * assertTrue(true);
- * }
- * }
- * </pre>
- *
- * writes the log
- *
- * <pre>
- * starting outer rule
- * starting middle rule
- * starting inner rule
- * finished inner rule
- * finished middle rule
- * finished outer rule
- * </pre>
- *
- * @author Kirk Lund
- */
-@SuppressWarnings("serial")
-public class SerializableRuleChain implements SerializableTestRule {
- private static final SerializableRuleChain EMPTY_CHAIN = new SerializableRuleChain(Collections.<TestRule>emptyList());
-
- private transient List<TestRule> rulesStartingWithInnerMost;
-
- /**
- * Returns a {@code SerializableRuleChain} without a {@link TestRule}. This method may
- * be the starting point of a {@code SerializableRuleChain}.
- *
- * @return a {@code SerializableRuleChain} without a {@link TestRule}.
- */
- public static SerializableRuleChain emptyRuleChain() {
- return EMPTY_CHAIN;
- }
-
- /**
- * Returns a {@code SerializableRuleChain} with a single {@link TestRule}. This method
- * is the usual starting point of a {@code SerializableRuleChain}.
- *
- * @param outerRule the outer rule of the {@code SerializableRuleChain}.
- * @return a {@code SerializableRuleChain} with a single {@link TestRule}.
- */
- public static SerializableRuleChain outerRule(TestRule outerRule) {
- return emptyRuleChain().around(outerRule);
- }
-
- private SerializableRuleChain(List<TestRule> rules) {
- this.rulesStartingWithInnerMost = rules;
- }
-
- /**
- * Create a new {@code SerializableRuleChain}, which encloses the {@code nextRule} with
- * the rules of the current {@code SerializableRuleChain}.
- *
- * @param enclosedRule the rule to enclose.
- * @return a new {@code SerializableRuleChain}.
- */
- public SerializableRuleChain around(TestRule enclosedRule) {
- List<TestRule> rulesOfNewChain = new ArrayList<TestRule>();
- rulesOfNewChain.add(enclosedRule);
- rulesOfNewChain.addAll(rulesStartingWithInnerMost);
- return new SerializableRuleChain(rulesOfNewChain);
- }
-
- /**
- * {@inheritDoc}
- */
- public Statement apply(Statement base, Description description) {
- for (TestRule each : rulesStartingWithInnerMost) {
- base = each.apply(base, description);
- }
- return base;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTemporaryFolder.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTemporaryFolder.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTemporaryFolder.java
deleted file mode 100755
index 0e796b3..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTemporaryFolder.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import java.io.File;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
-
-import org.junit.rules.TemporaryFolder;
-
-/**
- * Serializable version of TemporaryFolder JUnit Rule. JUnit lifecycle is not
- * executed in remote JVMs.
- *
- * @author Kirk Lund
- */
-@SuppressWarnings("serial")
-public class SerializableTemporaryFolder extends TemporaryFolder implements SerializableTestRule {
-
- private void writeObject(final ObjectOutputStream out) throws Exception {
- writeParentFolder(out);
- writeFolder(out);
- }
-
- private void readObject(final ObjectInputStream in) throws Exception {
- readParentFolder(in);
- readFolder(in);
- }
-
- private void readParentFolder(final ObjectInputStream in) throws Exception {
- final Field parentFolderField = TemporaryFolder.class.getDeclaredField("parentFolder");
- parentFolderField.setAccessible(true);
- parentFolderField.set(this, (File) in.readObject());
- }
-
- private void readFolder(final ObjectInputStream in) throws Exception {
- final Field folderField = TemporaryFolder.class.getDeclaredField("folder");
- folderField.setAccessible(true);
- folderField.set(this, (File) in.readObject());
- }
-
- private void writeParentFolder(final ObjectOutputStream out) throws Exception {
- final Field parentFolderField = TemporaryFolder.class.getDeclaredField("parentFolder");
- parentFolderField.setAccessible(true);
- final File parentFolderFieldValue = (File) parentFolderField.get(this);
- out.writeObject(parentFolderFieldValue);
- }
-
- private void writeFolder(final ObjectOutputStream out) throws Exception {
- final Field folderField = TemporaryFolder.class.getDeclaredField("folder");
- folderField.setAccessible(true);
- final File folderFieldValue = (File) folderField.get(this);
- out.writeObject(folderFieldValue);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestName.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestName.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestName.java
deleted file mode 100755
index 1fd255f..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestName.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
-
-import org.junit.rules.TestName;
-
-/**
- * Serializable version of TestName JUnit Rule. JUnit lifecycle is not
- * executed in remote JVMs.
- *
- * @author Kirk Lund
- */
-@SuppressWarnings("serial")
-public class SerializableTestName extends TestName implements SerializableTestRule {
-
- private void writeObject(final ObjectOutputStream out) throws Exception {
- writeName(out);
- }
-
- private void readObject(final ObjectInputStream in) throws Exception {
- readName(in);
- }
-
- private void writeName(final ObjectOutputStream out) throws Exception {
- final Field nameField = TestName.class.getDeclaredField("name");
- nameField.setAccessible(true);
- final String nameValue = (String) nameField.get(this);
- out.writeObject(nameValue);
- }
-
- private void readName(final ObjectInputStream in) throws Exception {
- Field nameField = TestName.class.getDeclaredField("name");
- nameField.setAccessible(true);
- nameField.set(this, (String) in.readObject());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestRule.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestRule.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestRule.java
deleted file mode 100755
index 354c38a..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestRule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import java.io.Serializable;
-
-import org.junit.rules.TestRule;
-
-/**
- * Serializable version of JUnit TestRule. JUnit lifecycle is not
- * executed in remote JVMs.
- *
- * The simplest way to satisfy this interface is to apply <tt>transient</tt>
- * to every instance field.
- *
- * @author Kirk Lund
- */
-public interface SerializableTestRule extends Serializable, TestRule {
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestWatcher.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestWatcher.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestWatcher.java
deleted file mode 100755
index 5bcf686..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTestWatcher.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import org.junit.rules.TestWatcher;
-
-/**
- * Serializable version of TestWatcher JUnit Rule. JUnit lifecycle is not
- * executed in remote JVMs.
- *
- * @author Kirk Lund
- */
-@SuppressWarnings("serial")
-public class SerializableTestWatcher extends TestWatcher implements SerializableTestRule {
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTimeout.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTimeout.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTimeout.java
deleted file mode 100755
index 3136a1c..0000000
--- a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/SerializableTimeout.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-import org.junit.rules.Timeout;
-
-/**
- * Serializable version of Timeout JUnit Rule. JUnit lifecycle is not
- * executed in remote JVMs.
- *
- * @author Kirk Lund
- */
-@SuppressWarnings("serial")
-public class SerializableTimeout extends Timeout implements SerializableTestRule {
-
- public static Builder builder() {
- return new Builder();
- }
-
- public SerializableTimeout(final long timeout, final TimeUnit timeUnit) {
- super(timeout, timeUnit);
- }
-
- protected SerializableTimeout(final Builder builder) {
- super(builder);
- }
-
- public static class Builder extends Timeout.Builder {
-
- protected Builder() {
- super();
- }
-
- @Override
- public SerializableTimeout build() {
- return new SerializableTimeout(this);
- }
- }
-
- private void writeObject(final ObjectOutputStream out) throws Exception {
- writeTimeout(out);
- writeTimeUnit(out);
- writeLookForStuckThread(out);
- }
-
- private void readObject(final ObjectInputStream in) throws Exception {
- readTimeout(in);
- readTimeUnit(in);
- readLookForStuckThread(in);
- }
-
- private void writeTimeout(final ObjectOutputStream out) throws Exception {
- final Field timeoutField = TestName.class.getDeclaredField("timeout");
- timeoutField.setAccessible(true);
- final Long timeoutValue = (Long) timeoutField.get(this);
- out.writeLong(timeoutValue);
- }
-
- private void writeTimeUnit(final ObjectOutputStream out) throws Exception {
- final Field timeoutField = TestName.class.getDeclaredField("timeUnit");
- timeoutField.setAccessible(true);
- final TimeUnit timeoutValue = (TimeUnit) timeoutField.get(this);
- out.writeObject(timeoutValue);
- }
-
- private void writeLookForStuckThread(final ObjectOutputStream out) throws Exception {
- try {
- final Field lookForStuckThreadField = TemporaryFolder.class.getDeclaredField("lookForStuckThread");
- lookForStuckThreadField.setAccessible(true);
- final Boolean lookForStuckThreadValue = (Boolean) lookForStuckThreadField.get(this);
- out.writeBoolean(lookForStuckThreadValue);
- } catch (NoSuchFieldException e) {
- out.writeBoolean(false);
- }
- }
-
- private void readTimeout(final ObjectInputStream in) throws Exception {
- Field timeoutField = TestName.class.getDeclaredField("timeout");
- timeoutField.setAccessible(true);
- timeoutField.set(this, (Long) in.readObject());
- }
-
- private void readTimeUnit(final ObjectInputStream in) throws Exception {
- Field timeUnitField = TestName.class.getDeclaredField("timeUnit");
- timeUnitField.setAccessible(true);
- timeUnitField.set(this, (TimeUnit) in.readObject());
- }
-
- private void readLookForStuckThread(final ObjectInputStream in) throws Exception {
- try {
- final Field lookForStuckThreadField = TemporaryFolder.class.getDeclaredField("lookForStuckThread");
- lookForStuckThreadField.setAccessible(true);
- lookForStuckThreadField.set(this, (Boolean) in.readObject());
- } catch (NoSuchFieldException e) {
- final boolean value = (Boolean) in.readObject();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldSerializationUtils.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldSerializationUtils.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldSerializationUtils.java
new file mode 100755
index 0000000..97e9265
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldSerializationUtils.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+import java.lang.reflect.Field;
+
+/**
+ * Provides support for serialization of private fields by reflection.
+ */
+public class FieldSerializationUtils {
+
+ protected FieldSerializationUtils() {
+ }
+
+ public static Object readField(final Class targetClass, final Object targetInstance, final String fieldName) {
+ try {
+ Field assureDeletionField = targetClass.getDeclaredField(fieldName);
+ assureDeletionField.setAccessible(true);
+ return assureDeletionField.get(targetInstance);
+ } catch (IllegalAccessException | NoSuchFieldException e) {
+ throw new Error(e);
+ }
+ }
+
+ public static void writeField(final Class targetClass, final Object targetInstance, final String fieldName, final Object value) {
+ try {
+ Field folderField = targetClass.getDeclaredField(fieldName);
+ folderField.setAccessible(true);
+ folderField.set(targetInstance, value);
+ } catch (IllegalAccessException | NoSuchFieldException e) {
+ throw new Error(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTemporaryFolder.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTemporaryFolder.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTemporaryFolder.java
new file mode 100755
index 0000000..3dd5ebd
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTemporaryFolder.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+/**
+ * Names of member fields in {@link org.junit.rules.TemporaryFolder}.
+ */
+interface FieldsOfTemporaryFolder {
+ static final String FIELD_PARENT_FOLDER = "parentFolder"; // java.io.File
+ static final String FIELD_ASSURE_DELETION = "assureDeletion"; // boolean (since JUnit 4.13)
+ static final String FIELD_FOLDER = "folder"; // java.io.File
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTestName.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTestName.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTestName.java
new file mode 100755
index 0000000..f30ed10
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTestName.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+/**
+ * Names of member fields in {@link org.junit.rules.TestName}.
+ */
+interface FieldsOfTestName {
+ static final String FIELD_NAME = "name"; // String
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTimeout.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTimeout.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTimeout.java
new file mode 100755
index 0000000..fab28ed
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTimeout.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+/**
+ * Names of member fields in {@link org.junit.rules.Timeout}.
+ */
+interface FieldsOfTimeout {
+ static final String FIELD_TIMEOUT = "timeout"; // long
+ static final String FIELD_TIME_UNIT = "timeUnit"; // java.util.concurrent.TimeUnit
+ static final String FIELD_LOOK_FOR_STUCK_THREAD = "lookForStuckThread"; // boolean
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResource.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResource.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResource.java
new file mode 100755
index 0000000..772891f
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResource.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+import org.junit.rules.ExternalResource;
+
+/**
+ * Serializable subclass of {@link org.junit.rules.ExternalResource ExternalResource}.
+ */
+public abstract class SerializableExternalResource extends ExternalResource implements SerializableTestRule {
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleList.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleList.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleList.java
new file mode 100755
index 0000000..3ae3079
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleList.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+import com.gemstone.gemfire.test.junit.rules.RuleList;
+import org.junit.rules.TestRule;
+
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Serializable version of {@link RuleList}.
+ */
+public class SerializableRuleList extends RuleList implements SerializableTestRule {
+
+ public SerializableRuleList() {
+ super();
+ }
+
+ public SerializableRuleList(final TestRule rule) {
+ super(rule);
+ }
+
+ protected SerializableRuleList(final List<TestRule> rules) {
+ super(rules);
+ }
+
+ @Override
+ public SerializableRuleList add(final TestRule rule) {
+ super.add(rule);
+ return this;
+ }
+
+ @Override
+ protected List<TestRule> rules() {
+ return super.rules();
+ }
+
+ private void readObject(final ObjectInputStream stream) throws InvalidObjectException {
+ throw new InvalidObjectException("SerializationProxy required");
+ }
+
+ private Object writeReplace() {
+ return new SerializationProxy(this);
+ }
+
+ /**
+ * Serialization proxy for {@code SerializableRuleList}.
+ */
+ private static class SerializationProxy implements Serializable {
+
+ private final List<TestRule> rules;
+
+ SerializationProxy(final SerializableRuleList instance) {
+ this.rules = instance.rules();
+ }
+
+ private Object readResolve() {
+ return new SerializableRuleList(this.rules);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolder.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolder.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolder.java
new file mode 100755
index 0000000..390cdc7
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolder.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+import static com.gemstone.gemfire.test.junit.rules.serializable.FieldSerializationUtils.*;
+import static com.gemstone.gemfire.test.junit.rules.serializable.FieldsOfTemporaryFolder.*;
+
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+/**
+ * Serializable subclass of {@link org.junit.rules.TemporaryFolder TemporaryFolder}.
+ * Instance variables of TemporaryFolder are serialized by reflection.
+ */
+public class SerializableTemporaryFolder extends TemporaryFolder implements SerializableTestRule {
+
+ public SerializableTemporaryFolder() {
+ super();
+ }
+
+ public SerializableTemporaryFolder(final File parentFolder) {
+ super(parentFolder);
+ }
+
+ private void readObject(final ObjectInputStream stream) throws InvalidObjectException {
+ throw new InvalidObjectException("SerializationProxy required");
+ }
+
+ private Object writeReplace() {
+ return new SerializationProxy(this);
+ }
+
+ /**
+ * Serialization proxy for {@code SerializableTemporaryFolder}.
+ */
+ private static class SerializationProxy implements Serializable {
+
+ private final File parentFolder;
+ private final File folder;
+
+ SerializationProxy(final SerializableTemporaryFolder instance) {
+ this.parentFolder = (File) readField(TemporaryFolder.class, instance, FIELD_PARENT_FOLDER);
+ this.folder =(File) readField(TemporaryFolder.class, instance, FIELD_FOLDER);
+ }
+
+ private Object readResolve() {
+ SerializableTemporaryFolder instance = new SerializableTemporaryFolder(this.parentFolder);
+ writeField(TemporaryFolder.class, instance, FIELD_FOLDER, this.folder);
+ return instance;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestName.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestName.java b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestName.java
new file mode 100755
index 0000000..cb87882
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestName.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.test.junit.rules.serializable;
+
+import static com.gemstone.gemfire.test.junit.rules.serializable.FieldSerializationUtils.*;
+import static com.gemstone.gemfire.test.junit.rules.serializable.FieldsOfTestName.*;
+
+import org.junit.rules.TestName;
+import org.junit.runner.Description;
+
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+
+/**
+ * Serializable subclass of {@link org.junit.rules.TestName TestName}. All
+ * instance variables of {@code TestName} are serialized by reflection.
+ */
+public class SerializableTestName extends TestName implements SerializableTestRule {
+
+ @Override
+ protected void starting(final Description description) {
+ super.starting(description);
+ }
+
+ private void readObject(final ObjectInputStream stream) throws InvalidObjectException {
+ throw new InvalidObjectException("SerializationProxy required");
+ }
+
+ private Object writeReplace() {
+ return new SerializationProxy(this);
+ }
+
+ /**
+ * Serialization proxy for {@code SerializableTestName}.
+ */
+ private static class SerializationProxy implements Serializable {
+
+ private final String name;
+
+ SerializationProxy(final SerializableTestName instance) {
+ this.name = (String) readField(TestName.class, instance, FIELD_NAME);
+ }
+
+ private Object readResolve() {
+ SerializableTestName instance = new SerializableTestName();
+ writeField(TestName.class, instance, FIELD_NAME, this.name);
+ return instance;
+ }
+ }
+}