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/02/23 21:24:28 UTC
[92/94] [abbrv] incubator-geode git commit: Merge remote-tracking
branch 'origin/develop' into feature/GEODE-953
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/internal/process/PidFileJUnitTest.java
index 0000000,5f81c2b..2906b0e
mode 000000,100755..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
@@@ -1,0 -1,274 +1,274 @@@
+ /*
+ * 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.internal.process;
+
+ import static org.junit.Assert.*;
+
+ import java.io.File;
+ import java.io.FileNotFoundException;
+ import java.io.FileWriter;
+ import java.io.IOException;
+ import java.util.concurrent.Callable;
+ import java.util.concurrent.CountDownLatch;
+ import java.util.concurrent.ExecutorService;
+ import java.util.concurrent.Executors;
+ import java.util.concurrent.Future;
+ import java.util.concurrent.TimeUnit;
+ import java.util.concurrent.TimeoutException;
+
+ import org.jmock.Mockery;
+ import org.jmock.lib.legacy.ClassImposteriser;
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Rule;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+ import org.junit.rules.ExpectedException;
+ 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.
+ *
+ * @author Kirk Lund
+ * @since 8.2
+ */
+ @Category(UnitTest.class)
+ public class PidFileJUnitTest {
+
+ @Rule
+ public TemporaryFolder testFolder = new TemporaryFolder();
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Rule
- public ExpectedTimeout timeout = ExpectedTimeout.none();
++ public ExpectedTimeoutRule timeout = ExpectedTimeoutRule.none();
+
+ protected Mockery mockContext;
+ private ExecutorService futures;
+
+ @Before
+ public void before() {
+ mockContext = new Mockery() {{
+ setImposteriser(ClassImposteriser.INSTANCE);
+ }};
+ this.futures = Executors.newFixedThreadPool(2);
+ }
+
+ @After
+ public void after() {
+ mockContext.assertIsSatisfied();
+ assertTrue(this.futures.shutdownNow().isEmpty());
+ }
+
+ @Test
+ public void readsIntFromFile() throws Exception {
+ final File file = testFolder.newFile("my.pid");
+ final String value = "42";
+ writeToFile(file, value);
+
+ final int readValue = new PidFile(file).readPid();
+ assertEquals(Integer.parseInt(value), readValue);
+ }
+
+ @Test
+ public void readingEmptyFileThrowsIllegalArgumentException() throws Exception {
+ final File file = testFolder.newFile("my.pid");
+
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("Invalid pid 'null' found");
+
+ new PidFile(file).readPid();
+ }
+
+ @Test
+ public void readingFileWithNonIntegerThrowsIllegalArgumentException() throws Exception {
+ final File file = testFolder.newFile("my.pid");
+ final String value = "fortytwo";
+ writeToFile(file, value);
+
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("Invalid pid '" + value + "' found");
+
+ new PidFile(file).readPid();
+ }
+
+ @Test
+ public void readingFileWithNegativeIntegerThrowsIllegalArgumentException() throws Exception {
+ final File file = testFolder.newFile("my.pid");
+ final String value = "-42";
+ writeToFile(file, value);
+
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("Invalid pid '" + value + "' found");
+
+ new PidFile(file).readPid();
+ }
+
+ @Test
+ public void readingNullFileThrowsNullPointerException() throws Exception {
+ final File file = null;
+
+ thrown.expect(NullPointerException.class);
+
+ new PidFile(file).readPid();
+ }
+
+ @Test
+ public void timesOutReadingFromEmptyFile() throws Exception {
+ final File file = testFolder.newFile("my.pid");
+
+ timeout.expect(TimeoutException.class);
+ timeout.expectMessage("Invalid pid 'null' found");
+ timeout.expectMinimumDuration(1000);
+ timeout.expectMaximumDuration(10000);
+ timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
+
+ new PidFile(file).readPid(1500, TimeUnit.MILLISECONDS);
+ }
+
+ @Test
+ public void readsIntBeforeTimeout() throws Exception {
+ final int AWAIT_LATCH_TIMEOUT_MILLIS = 10*1000;
+ final int OPEN_LATCH_DELAY_MILLIS = 2*1000;
+ final int FUTURE_GET_TIMEOUT_MILLIS = 2*1000;
+ final int READ_PID_TIMEOUT_MILLIS = 2*OPEN_LATCH_DELAY_MILLIS;
+
+ final File file = testFolder.newFile("my.pid");
+ final FileWriter writer = new FileWriter(file);
+
+ final CountDownLatch writePidLatch = new CountDownLatch(1);
+ final String value = "42";
+
+ // start Future to write the pid later but before timeout
+ Future<Boolean> futureWritePid = this.futures.submit(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ writePidLatch.await(AWAIT_LATCH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ writeToFile(file, value);
+ return true;
+ }
+ });
+
+ // start Future to sleep and release the delay
+ Future<Boolean> futureOpenLatch = this.futures.submit(new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ Thread.sleep(OPEN_LATCH_DELAY_MILLIS);
+ writePidLatch.countDown();
+ return true;
+ }
+ });
+
+ StopWatch stopWatch = new StopWatch(true);
+ final int readValue = new PidFile(file).readPid(READ_PID_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+ assertEquals(Integer.parseInt(value), readValue);
+
+ long duration = stopWatch.elapsedTimeMillis();
+ assertTrue(duration > OPEN_LATCH_DELAY_MILLIS);
+ assertTrue(duration < READ_PID_TIMEOUT_MILLIS);
+
+ assertEquals(0, writePidLatch.getCount());
+ assertTrue(futureOpenLatch.get(FUTURE_GET_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
+ assertTrue(futureWritePid.get(FUTURE_GET_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
+ }
+
+ @Test
+ public void findsCorrectFile() throws Exception {
+ final File directory = testFolder.getRoot();
+
+ final String fileNames[] = new String[] { "other.txt", "my.txt", "a.log", "b.log" };
+ for (String fileName : fileNames) {
+ testFolder.newFile(fileName);
+ }
+
+ final int pidValue = 42;
+ final File file = testFolder.newFile("my.pid");
+ writeToFile(file, String.valueOf(pidValue));
+
+ final File other = testFolder.newFile("other.pid");
+ writeToFile(other, "43");
+
+ final File[] files = directory.listFiles();
+ assertEquals(fileNames.length + 2, files.length);
+
+ PidFile pidFile = new PidFile(directory, file.getName());
+ assertEquals(file, pidFile.getFile());
+
+ int value = pidFile.readPid();
+ assertEquals(pidValue, value);
+ }
+
+ @Test
+ public void missingFileInEmptyDirectoryThrowsFileNotFoundException() throws Exception {
+ final File directory = testFolder.getRoot();
+
+ final String pidFileName = "my.pid";
+
+ thrown.expect(FileNotFoundException.class);
+ thrown.expectMessage("Unable to find PID file '" + pidFileName + "' in directory " + directory);
+
+ new PidFile(directory, pidFileName);
+ }
+
+ @Test
+ public void missingFileThrowsFileNotFoundException() throws Exception {
+ final String pidFileName = "my.pid";
+
+ final File directory = testFolder.getRoot();
+ final File file = new File(directory, pidFileName);
+
+ thrown.expect(FileNotFoundException.class);
+ thrown.expectMessage("Unable to find PID file '" + file + "'");
+
+ new PidFile(file);
+ }
+
+ @Test
+ public void missingFileInFullDirectoryThrowsFileNotFoundException() throws Exception {
+ final File directory = testFolder.getRoot();
+
+ final String fileNames[] = new String[] { "other.txt", "my.txt", "a.log", "b.log" };
+ for (String fileName : fileNames) {
+ testFolder.newFile(fileName);
+ }
+
+ final File other = testFolder.newFile("other.pid");
+ writeToFile(other, "43");
+
+ final File[] files = directory.listFiles();
+ assertEquals(fileNames.length + 1, files.length);
+
+ final String pidFileName = "my.pid";
+
+ thrown.expect(FileNotFoundException.class);
+ thrown.expectMessage("Unable to find PID file '" + pidFileName + "' in directory " + directory);
+
+ new PidFile(directory, pidFileName);
+ }
+
+ private void writeToFile(final File file, String value) throws IOException {
+ final FileWriter writer = new FileWriter(file);
+ writer.write(value);
+ writer.flush();
+ writer.close();
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedDisconnectRule.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedDisconnectRule.java
index 0000000,125fc06..f7a5179
mode 000000,100755..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
@@@ -1,0 -1,121 +1,122 @@@
+ /*
+ * 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.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;
+
++/**
++ * Disconnects all remote DUnit JVMs including the Locator JVM.
++ */
+ @SuppressWarnings("serial")
-public class DistributedDisconnectRule extends DistributedExternalResource {
++public class DistributedDisconnectRule extends DistributedTestFixtureRule {
+
+ private final boolean disconnectBefore;
+ private final boolean disconnectAfter;
+ private final boolean disconnectBeforeClass;
+ private final boolean disconnectAfterClass;
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public DistributedDisconnectRule(final Builder builder) {
+ this(new RemoteInvoker(), builder);
+ }
+
+ 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;
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ if (this.disconnectBefore) {
+ invoker().invokeEverywhere(serializableRunnable());
+ }
+ }
+
+ @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 {
++ protected void afterClass() {
+ 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;
+ }
+
+ public DistributedDisconnectRule build() {
+ return new DistributedDisconnectRule(this);
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedExternalResource.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedExternalResource.java
index 0000000,d3b7319..a7c3598
mode 000000,100755..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
@@@ -1,0 -1,58 +1,41 @@@
+ /*
+ * 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.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;
+
+ public DistributedExternalResource() {
+ this(new RemoteInvoker());
+ }
+
+ public DistributedExternalResource(final RemoteInvoker invoker) {
+ super();
+ this.invoker = invoker;
+ }
+
+ 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/504a222f/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
index 0000000,1711b21..061cb42
mode 000000,100755..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
@@@ -1,0 -1,74 +1,72 @@@
+ /*
+ * 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.dunit.rules;
+
+ import static java.lang.System.getProperties;
+ import static java.lang.System.setProperties;
+
+ 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;
+
+ private final RemoteInvoker invoker;
+
+ public DistributedRestoreSystemProperties() {
+ this(new RemoteInvoker());
+ }
+
+ public DistributedRestoreSystemProperties(final RemoteInvoker invoker) {
+ super();
+ this.invoker = invoker;
+ }
+
+ @Override
+ protected void before() throws Throwable {
+ super.before();
+ this.invoker.remoteInvokeInEveryVMAndLocator(new SerializableRunnable() {
+ @Override
+ public void run() {
+ originalProperties = getProperties();
+ setProperties(new Properties(originalProperties));
+ }
+ });
+ }
+
+ @Override
+ protected void after() {
+ super.after();
+ this.invoker.remoteInvokeInEveryVMAndLocator(new SerializableRunnable() {
+ @Override
+ public void run() {
+ setProperties(originalProperties);
+ originalProperties = null;
+ }
+ });
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedTestFixtureRule.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedTestFixtureRule.java
index 0000000,0000000..86e93f3
new file mode 100755
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedTestFixtureRule.java
@@@ -1,0 -1,0 +1,57 @@@
++/*
++ * 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.dunit.rules;
++
++import com.gemstone.gemfire.test.junit.rules.serializable.SerializableTestFixtureRule;
++
++/**
++ * Distributed version of SerializableTestFixtureRule which affects all
++ * DUnit JVMs including the Locator JVM. TODO: make which JVMs configurable
++ */
++public class DistributedTestFixtureRule extends SerializableTestFixtureRule {
++
++ private final RemoteInvoker invoker;
++
++ public DistributedTestFixtureRule() {
++ this(new RemoteInvoker());
++ }
++
++ public DistributedTestFixtureRule(final RemoteInvoker invoker) {
++ super();
++ this.invoker = invoker;
++ }
++
++ protected RemoteInvoker invoker() {
++ return this.invoker;
++ }
++
++ @Override
++ protected void before() throws Throwable {
++ }
++
++ @Override
++ protected void after() {
++ }
++
++ @Override
++ protected void beforeClass() throws Throwable {
++ }
++
++ @Override
++ protected void afterClass() {
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/RemoteInvoker.java
index 0000000,9e3c5b2..98dbc2f
mode 000000,100755..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
@@@ -1,0 -1,43 +1,49 @@@
+ /*
+ * 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.dunit.rules;
+
+ import static com.gemstone.gemfire.test.dunit.Invoke.invokeInEveryVM;
+ import static com.gemstone.gemfire.test.dunit.Invoke.invokeInLocator;
+
+ 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 {
+ runnable.run();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ invokeInEveryVM(runnable);
+ invokeInLocator(runnable);
+ }
+
+ public void remoteInvokeInEveryVMAndLocator(final SerializableRunnable runnable) {
+ invokeInEveryVM(runnable);
+ invokeInLocator(runnable);
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/build.gradle
----------------------------------------------------------------------
diff --cc geode-junit/build.gradle
index 0000000,112d112..7aa6562
mode 000000,100755..100755
--- a/geode-junit/build.gradle
+++ b/geode-junit/build.gradle
@@@ -1,0 -1,21 +1,22 @@@
+ /*
+ * 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.
+ */
+
+ 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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Repeat.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Repeat.java
index 0000000,5cfa321..01434de
mode 000000,100755..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
@@@ -1,0 -1,43 +1,43 @@@
+ /*
+ * 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;
+
+ import java.lang.annotation.Documented;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ import java.lang.annotation.RetentionPolicy;
+ 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 {
+
+ public static int DEFAULT = 1;
+
+ int value() default DEFAULT;
+
+ String property() default "";
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Retry.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/Retry.java
index 0000000,65f3cf6..6039943
mode 000000,100755..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
@@@ -1,0 -1,38 +1,38 @@@
+ /*
+ * 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;
+
+ import java.lang.annotation.Documented;
+ import java.lang.annotation.ElementType;
+ import java.lang.annotation.Retention;
+ 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)
+ @Target({ ElementType.METHOD })
+ public @interface Retry {
+
+ public static int DEFAULT = 1;
+
+ int value() default DEFAULT;
+
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/ContainerTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/ContainerTest.java
index 0000000,8eec738..dbafa34
mode 000000,100755..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
@@@ -1,0 -1,25 +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.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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/DistributedTest.java
index 0000000,6aa538b..c9253f9
mode 000000,100644..100755
--- 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
@@@ -1,0 -1,25 +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.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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/HydraTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/HydraTest.java
index 0000000,4fe535b..ed21455
mode 000000,100755..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
@@@ -1,0 -1,24 +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.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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/IntegrationTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/IntegrationTest.java
index 0000000,1be6e45..eabc288
mode 000000,100644..100755
--- 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
@@@ -1,0 -1,25 +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.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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/PerformanceTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/PerformanceTest.java
index 0000000,ad952be..7776112
mode 000000,100644..100755
--- 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
@@@ -1,0 -1,25 +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.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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UITest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UITest.java
index 0000000,834931a..5f151cc
mode 000000,100644..100755
--- 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
@@@ -1,0 -1,24 +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.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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UnitTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/UnitTest.java
index 0000000,d5be9e8..2d887c4
mode 000000,100644..100755
--- 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
@@@ -1,0 -1,25 +1,35 @@@
+ /*
+ * 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.categories;
++
+ /**
+ * JUnit Test Category that specifies a test with very narrow and well defined
+ * scope. Any complex dependencies and interactions are stubbed or mocked.
- *
++ *
++ * <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>
++ *
+ * @author Kirk Lund
++ * @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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/WanTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/categories/WanTest.java
index 0000000,9abf15b..357e4ef
mode 000000,100644..100755
--- 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
@@@ -1,0 -1,24 +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.categories;
++
+ /**
+ * Tests Wan Feature.
+ *
+ * @author Kirk Lund
+ */
+ public interface WanTest {
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutRule.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/ExpectedTimeoutRule.java
index 0000000,7b6d345..3b02236
mode 000000,100755..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
@@@ -1,0 -1,180 +1,197 @@@
+ /*
+ * 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 ExpectedTimeoutRule implements TestRule {
+
+ /**
+ * @return a Rule that expects no timeout (identical to behavior without this Rule)
+ */
+ public static ExpectedTimeoutRule none() {
+ return new ExpectedTimeoutRule();
+ }
+
+ private ExpectedException delegate;
+ private boolean expectsThrowable;
+ private long minDuration;
+ private long maxDuration;
+ private TimeUnit timeUnit;
+
+ private ExpectedTimeoutRule() {
+ this.delegate = ExpectedException.none();
+ }
+
+ public ExpectedTimeoutRule expectMinimumDuration(final long minDuration) {
+ this.minDuration = minDuration;
+ return this;
+ }
+ public ExpectedTimeoutRule expectMaximumDuration(final long maxDuration) {
+ this.maxDuration = maxDuration;
+ return this;
+ }
+ public ExpectedTimeoutRule expectTimeUnit(final TimeUnit timeUnit) {
+ this.timeUnit = timeUnit;
+ return this;
+ }
+
++ /**
++ * This method does nothing.
++ *
++ * @deprecated AssertionErrors are handled by default
++ */
++ @Deprecated
+ public ExpectedTimeoutRule handleAssertionErrors() {
+ this.delegate.handleAssertionErrors();
+ return this;
+ }
-
++
++ /**
++ * This method does nothing.
++ *
++ * @deprecated AssumptionViolatedExceptions are handled by default
++ */
++ @Deprecated
+ 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);
+ }
+
+ /**
+ * 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);
+ 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;
++ /**
++ * 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));
+ }
+ }
+
+ 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;
++ 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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RuleList.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RuleList.java
index 0000000,0000000..0431083
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/RuleList.java
@@@ -1,0 -1,0 +1,97 @@@
++/*
++ * 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 {
++ *
++ * \@Rule
++ * public RuleList rules = new RuleList().add(new FirstRule()
++ * .add(new SecondRule()
++ * .add(new ThirdRule();
++ * </pre>
++ *
++ * @author Kirk Lund
++ */
++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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/TestFixtureRule.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/TestFixtureRule.java
index 0000000,0000000..7468c1f
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/TestFixtureRule.java
@@@ -1,0 -1,0 +1,143 @@@
++/*
++ * 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;
++
++/**
++ * An abstract base class for test rules that combine {@code ClassRule} and
++ * method {@code Rule} test fixture lifecycle callbacks. Subclasses may
++ * override any or all of these methods:
++ * <p><ul>
++ * <li>{@link #beforeClass()}
++ * <li>{@link #afterClass()}
++ * <li>{@link #before()}
++ * <li>{@link #after()}
++ * </ul>
++ *
++ * <p>The rule variable does not have to be static in order to implement
++ * {@link #beforeClass()} and {@link #afterClass()}.
++ *
++ * <p>Example:
++ *
++ * <pre>
++ * public class SomeTest {
++ *
++ * \@Rule
++ * public TestFixtureRule testFixtureRule = new TestFixtureRule() {
++ * \@Override
++ * protected void beforeClass() throws Throwable {
++ * // setup executed once before all tests in SomeTest
++ * }
++ * \@Override
++ * protected void afterClass() {
++ * // teardown executed once after all tests in SomeTest
++ * }
++ * \@Override
++ * protected void before() throws Throwable {
++ * // setup executed before each test in SomeTest
++ * }
++ * \@Override
++ * protected void after() {
++ * // teardown executed after each test in SomeTest
++ * }
++ * }
++ * }
++ * </pre>
++ */
++public class TestFixtureRule implements TestRule {
++
++ @Override
++ public Statement apply(final Statement base, final Description description) {
++ if (description.isSuite()) {
++ return createClassStatement(base);
++ } else if (description.isTest()) {
++ return createMethodStatement(base);
++ }
++ return base;
++ }
++
++ /**
++ * Returns new <code>Statement</code> for invoking <code>beforeClass</code>
++ * and <code>afterClass</code>.
++ */
++ protected Statement createClassStatement(final Statement base) {
++ return new Statement() {
++ @Override
++ public void evaluate() throws Throwable {
++ beforeClass();
++ try {
++ base.evaluate();
++ } finally {
++ afterClass();
++ }
++ }
++ };
++ }
++
++ /**
++ * Returns new <code>Statement</code> for invoking <code>before</code>
++ * and <code>after</code>.
++ */
++ protected Statement createMethodStatement(final Statement base) {
++ return new Statement() {
++ @Override
++ public void evaluate() throws Throwable {
++ before();
++ try {
++ base.evaluate();
++ } finally {
++ after();
++ }
++ }
++ };
++ }
++
++ /**
++ * Override to perform custom setup during <code>beforeClass</code> which
++ * is invoked prior to {@link #before()} and all test methods.
++ *
++ * @throws Throwable if setup fails
++ */
++ protected void beforeClass() throws Throwable {
++ }
++
++ /**
++ * Override to perform custom tearDown during <code>afterClass</code> which
++ * is invoked following {@link #after()} and all test methods.
++ */
++ protected void afterClass() {
++ }
++
++ /**
++ * Override to perform custom setup before each test method.
++ *
++ * @throws Throwable if setup fails
++ */
++ protected void before() throws Throwable {
++ // do nothing
++ }
++
++ /**
++ * Override to perform custom tearDown during after each test method.
++ */
++ protected void after() {
++ // do nothing
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldSerializationUtils.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldSerializationUtils.java
index 0000000,0000000..97e9265
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldSerializationUtils.java
@@@ -1,0 -1,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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTemporaryFolder.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTemporaryFolder.java
index 0000000,0000000..3dd5ebd
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTemporaryFolder.java
@@@ -1,0 -1,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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTestName.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTestName.java
index 0000000,0000000..f30ed10
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTestName.java
@@@ -1,0 -1,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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTimeout.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTimeout.java
index 0000000,0000000..fab28ed
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/FieldsOfTimeout.java
@@@ -1,0 -1,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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResource.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResource.java
index 0000000,0000000..772891f
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResource.java
@@@ -1,0 -1,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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleList.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleList.java
index 0000000,0000000..3ae3079
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleList.java
@@@ -1,0 -1,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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolder.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolder.java
index 0000000,0000000..390cdc7
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolder.java
@@@ -1,0 -1,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/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestFixtureRule.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestFixtureRule.java
index 0000000,0000000..182b370
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestFixtureRule.java
@@@ -1,0 -1,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 com.gemstone.gemfire.test.junit.rules.TestFixtureRule;
++
++/**
++ * Serializable version of {@link TestFixtureRule}.
++ */
++public abstract class SerializableTestFixtureRule extends TestFixtureRule implements SerializableTestRule {
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestName.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestName.java
index 0000000,0000000..cb87882
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestName.java
@@@ -1,0 -1,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;
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestRule.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestRule.java
index 0000000,0000000..9d06bc6
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestRule.java
@@@ -1,0 -1,0 +1,28 @@@
++/*
++ * 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.io.Serializable;
++
++import org.junit.rules.TestRule;
++
++/**
++ * Specifies that a {@link org.junit.rules.TestRule TestRule} is
++ * {@code Serializable}.
++ */
++public interface SerializableTestRule extends Serializable, TestRule {
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcher.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcher.java
index 0000000,0000000..d325b09
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcher.java
@@@ -1,0 -1,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;
++
++import org.junit.rules.TestWatcher;
++
++/**
++ * Serializable subclass of {@link org.junit.rules.TestWatcher TestWatcher}.
++ * There are no instance variables to be serialized.
++ */
++public abstract class SerializableTestWatcher extends TestWatcher implements SerializableTestRule {
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeout.java
----------------------------------------------------------------------
diff --cc geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeout.java
index 0000000,0000000..f3a4ba7
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/main/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeout.java
@@@ -1,0 -1,0 +1,104 @@@
++/*
++ * 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.FieldsOfTimeout.*;
++
++import org.junit.rules.Timeout;
++
++import java.io.InvalidObjectException;
++import java.io.ObjectInputStream;
++import java.io.Serializable;
++import java.util.concurrent.TimeUnit;
++
++/**
++ * Serializable subclass of {@link org.junit.rules.Timeout Timeout}. All
++ * instance variables of {@code Timeout} are serialized by reflection.
++ */
++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);
++ }
++
++ private void readObject(final ObjectInputStream stream) throws InvalidObjectException {
++ throw new InvalidObjectException("SerializationProxy required");
++ }
++
++ private Object writeReplace() {
++ return new SerializationProxy(this);
++ }
++
++ /**
++ * Builder for {@code SerializableTimeout}.
++ */
++ public static class Builder extends Timeout.Builder {
++
++ protected Builder() {
++ super();
++ }
++
++ @Override
++ public Builder withTimeout(final long timeout, final TimeUnit unit) {
++ super.withTimeout(timeout, unit);
++ return this;
++ }
++
++ @Override
++ public Builder withLookingForStuckThread(final boolean enable) {
++ super.withLookingForStuckThread(enable);
++ return this;
++ }
++
++ @Override
++ public SerializableTimeout build() {
++ return new SerializableTimeout(this);
++ }
++ }
++
++ /**
++ * Serialization proxy for {@code SerializableTimeout}.
++ */
++ private static class SerializationProxy implements Serializable {
++
++ private final long timeout;
++ private final TimeUnit timeUnit;
++ private final boolean lookForStuckThread;
++
++ SerializationProxy(final SerializableTimeout instance) {
++ this.timeout = (long) readField(Timeout.class, instance, FIELD_TIMEOUT);
++ this.timeUnit =(TimeUnit) readField(Timeout.class, instance, FIELD_TIME_UNIT);
++ this.lookForStuckThread =(boolean) readField(Timeout.class, instance, FIELD_LOOK_FOR_STUCK_THREAD);
++ }
++
++ private Object readResolve() {
++ return new SerializableTimeout.Builder()
++ .withTimeout(this.timeout, this.timeUnit)
++ .withLookingForStuckThread(this.lookForStuckThread)
++ .build();
++ }
++ }
++}