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:26 UTC
[90/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-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RepeatingTestCasesExampleTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RepeatingTestCasesExampleTest.java
index 0000000,5ee647b..443bb8f
mode 000000,100755..100755
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RepeatingTestCasesExampleTest.java
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RepeatingTestCasesExampleTest.java
@@@ -1,0 -1,94 +1,98 @@@
+ /*
+ * 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.examples;
+
+ import static org.hamcrest.CoreMatchers.*;
+ import static org.junit.Assert.assertThat;
+
+ import java.util.concurrent.atomic.AtomicInteger;
+
+ import org.junit.AfterClass;
+ import org.junit.BeforeClass;
+ import org.junit.Rule;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+
+ import com.gemstone.gemfire.test.junit.Repeat;
+ import com.gemstone.gemfire.test.junit.categories.UnitTest;
+ import com.gemstone.gemfire.test.junit.rules.RepeatRule;
+
+ /**
+ * The RepeatingTestCasesExampleTest class is a test suite of test cases testing the contract and functionality
+ * of the JUnit @Repeat annotation on a test suite class test case methods.
+ *
+ * @author John Blum
+ * @see org.junit.Test
+ * @see com.gemstone.gemfire.test.junit.Repeat
+ * @see com.gemstone.gemfire.test.junit.rules.RepeatRule
+ */
+ @Category(UnitTest.class)
+ public class RepeatingTestCasesExampleTest {
+
- private static AtomicInteger repeatOnceCounter = new AtomicInteger(0);
- private static AtomicInteger repeatOnlyOnceCounter = new AtomicInteger(0);
- private static AtomicInteger repeatTenTimesCounter = new AtomicInteger(0);
- private static AtomicInteger repeatTwiceCounter = new AtomicInteger(0);
++ private static final AtomicInteger repeatOnceCounter = new AtomicInteger(0);
++ private static final AtomicInteger repeatOnlyOnceCounter = new AtomicInteger(0);
++ private static final AtomicInteger repeatTenTimesCounter = new AtomicInteger(0);
++ private static final AtomicInteger repeatTwiceCounter = new AtomicInteger(0);
+
+ @Rule
+ public RepeatRule repeatRule = new RepeatRule();
+
+ @BeforeClass
+ public static void setupBeforeClass() {
+ System.setProperty("tdd.example.test.case.two.repetitions", "2");
++ repeatOnceCounter.set(0);
++ repeatOnlyOnceCounter.set(0);
++ repeatTenTimesCounter.set(0);
++ repeatTwiceCounter.set(0);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ assertThat(repeatOnceCounter.get(), is(equalTo(1)));
+ assertThat(repeatOnlyOnceCounter.get(), is(equalTo(1)));
+ assertThat(repeatTenTimesCounter.get(), is(equalTo(10)));
+ assertThat(repeatTwiceCounter.get(), is(equalTo(2)));
+ }
+
+ @Test
+ @Repeat
+ public void repeatOnce() {
+ repeatOnceCounter.incrementAndGet();
+ assertThat(repeatOnceCounter.get() <= 1, is(true));
+ }
+
+ @Test
+ @Repeat(property = "tdd.example.test.case.with.non-existing.system.property")
+ public void repeatOnlyOnce() {
+ repeatOnlyOnceCounter.incrementAndGet();
+ assertThat(repeatOnlyOnceCounter.get() <= 1, is(true));
+ }
+
+ @Test
+ @Repeat(10)
+ public void repeatTenTimes() {
+ repeatTenTimesCounter.incrementAndGet();
+ assertThat(repeatTenTimesCounter.get() <= 10, is(true));
+ }
+
+ @Test
+ @Repeat(property = "tdd.example.test.case.two.repetitions")
+ public void repeatTwiceCounter() {
+ repeatTwiceCounter.incrementAndGet();
+ assertThat(repeatTwiceCounter.get() <= 2, is(true));
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleTest.java
index 0000000,f6d70a2..3561169
mode 000000,100755..100755
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleTest.java
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleTest.java
@@@ -1,0 -1,43 +1,51 @@@
+ /*
+ * 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.examples;
+
+ import static org.assertj.core.api.Assertions.*;
+
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import com.gemstone.gemfire.test.junit.rules.RetryRule;
++import org.junit.BeforeClass;
+ import org.junit.Rule;
+ import org.junit.Test;
+ import org.junit.experimental.categories.Category;
+
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.RetryRule;
-
++/**
++ * Example usage of {@link RetryRule} with global scope.
++ */
+ @Category(UnitTest.class)
+ public class RetryRuleExampleTest {
+
- @Rule
- public final transient RetryRule retry = new RetryRule(2);
-
+ private static int count = 0;
+
++ @Rule
++ public RetryRule retry = new RetryRule(2);
++
++ @BeforeClass
++ public static void beforeClass() {
++ count = 0;
++ }
++
+ @Test
+ public void unreliableTestWithRaceConditions() {
+ count++;
+ if (count < 2) {
+ assertThat(count).isEqualTo(2); // doomed to fail
+ }
+ }
+ }
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RuleAndClassRuleTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RuleAndClassRuleTest.java
index 0000000,0000000..0b79c70
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RuleAndClassRuleTest.java
@@@ -1,0 -1,0 +1,147 @@@
++/*
++ * 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.examples;
++
++import static org.assertj.core.api.Assertions.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import com.gemstone.gemfire.test.junit.rules.TestRunner;
++import org.junit.ClassRule;
++import org.junit.Rule;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++import org.junit.rules.TestRule;
++import org.junit.runner.Description;
++import org.junit.runner.Result;
++import org.junit.runners.model.Statement;
++
++/**
++ * Example usage of a rule as both a method \@Rule and a \@ClassRule.
++ */
++@Category(UnitTest.class)
++public class RuleAndClassRuleTest {
++
++ @Test
++ public void usingRuleAsRuleAndClassRuleShouldInvokeBeforeClass() {
++ Result result = TestRunner.runTest(UsingRuleAsRuleAndClassRule.class);
++
++ assertThat(result.wasSuccessful()).isTrue();
++ assertThat(UsingRuleAsRuleAndClassRule.staticRule.beforeClassInvoked).isEqualTo(true);
++ }
++
++ @Test
++ public void usingRuleAsRuleAndClassRuleShouldInvokeAfterClass() {
++ Result result = TestRunner.runTest(UsingRuleAsRuleAndClassRule.class);
++
++ assertThat(result.wasSuccessful()).isTrue();
++ assertThat(UsingRuleAsRuleAndClassRule.staticRule.afterClassInvoked).isEqualTo(true);
++ }
++
++ @Test
++ public void usingRuleAsRuleAndClassRuleShouldInvokeBefore() {
++ Result result = TestRunner.runTest(UsingRuleAsRuleAndClassRule.class);
++
++ assertThat(result.wasSuccessful()).isTrue();
++ assertThat(UsingRuleAsRuleAndClassRule.staticRule.beforeInvoked).isEqualTo(true);
++ }
++
++ @Test
++ public void usingRuleAsRuleAndClassRuleShouldInvokeAfter() {
++ Result result = TestRunner.runTest(UsingRuleAsRuleAndClassRule.class);
++
++ assertThat(result.wasSuccessful()).isTrue();
++ assertThat(UsingRuleAsRuleAndClassRule.staticRule.afterInvoked).isEqualTo(true);
++ }
++
++ /**
++ * Implementation of TestRule that records the callbacks invoked on it. Used
++ * by {@link UsingRuleAsRuleAndClassRule}.
++ */
++ public static class SpyRule implements TestRule {
++ boolean beforeClassInvoked = false;
++ boolean afterClassInvoked = false;
++ boolean beforeInvoked = false;
++ boolean afterInvoked = false;
++
++ @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();
++ }
++ }
++ };
++ }
++
++ private void beforeClass() {
++ this.beforeClassInvoked = true;
++ }
++
++ private void afterClass() {
++ this.afterClassInvoked = true;
++ }
++
++ private void before() {
++ this.beforeInvoked = true;
++ }
++
++ private void after() {
++ this.afterInvoked = true;
++ }
++ }
++
++ /**
++ * Used by the tests in {@link RuleAndClassRuleTest}.
++ */
++ public static class UsingRuleAsRuleAndClassRule {
++ @ClassRule
++ public static SpyRule staticRule = new SpyRule();
++ @Rule
++ public SpyRule rule = staticRule;
++ @Test
++ public void doTest() throws Exception {
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResourceTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResourceTest.java
index 0000000,0000000..068328b
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResourceTest.java
@@@ -1,0 -1,0 +1,81 @@@
++/*
++ * 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 org.assertj.core.api.Assertions.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import org.apache.commons.lang.SerializationUtils;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++import org.junit.rules.ExternalResource;
++
++import java.io.Serializable;
++import java.lang.reflect.Field;
++
++/**
++ * Unit tests for {@link SerializableExternalResource}.
++ */
++@Category(UnitTest.class)
++public class SerializableExternalResourceTest {
++
++ @Test
++ public void hasZeroFields() throws Exception {
++ Field[] fields = ExternalResource.class.getDeclaredFields();
++ /*for (Field field : fields) {
++ System.out.println("Field: " + field);
++ }*/
++ assertThat(fields.length).isEqualTo(0);
++ }
++
++ @Test
++ public void isSerializable() throws Exception {
++ assertThat(SerializableExternalResource.class).isInstanceOf(Serializable.class);
++ }
++
++ @Test
++ public void canBeSerialized() throws Throwable {
++ FakeSerializableExternalResource instance = new FakeSerializableExternalResource().value(1);
++
++ FakeSerializableExternalResource cloned = (FakeSerializableExternalResource) SerializationUtils.clone(instance);
++
++ assertThat(instance.value()).isEqualTo(1);
++ assertThat(cloned.value()).isEqualTo(1);
++
++ instance.value(2);
++
++ assertThat(instance.value()).isEqualTo(2);
++ assertThat(cloned.value()).isEqualTo(1);
++ }
++
++ /**
++ * Fake SerializableExternalResource with a simple int field.
++ */
++ private static class FakeSerializableExternalResource extends SerializableExternalResource {
++
++ private int value = -1;
++
++ public FakeSerializableExternalResource value(final int value) {
++ this.value = value;
++ return this;
++ }
++
++ public int value() {
++ return this.value;
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleListTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleListTest.java
index 0000000,0000000..ebd4b91
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleListTest.java
@@@ -1,0 -1,0 +1,89 @@@
++/*
++ * 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 org.assertj.core.api.Assertions.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import org.apache.commons.lang.SerializationUtils;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++import org.junit.runner.Description;
++import org.junit.runners.model.Statement;
++
++import java.io.Serializable;
++
++/**
++ * Unit tests for {@link SerializableRuleList}.
++ */
++@Category(UnitTest.class)
++public class SerializableRuleListTest {
++
++ @Test
++ public void isSerializable() throws Exception {
++ assertThat(SerializableRuleList.class).isInstanceOf(Serializable.class);
++ }
++
++ @Test
++ public void canBeSerialized() throws Exception {
++ String value = "foo";
++ FakeSerializableTestRule fakeRule = new FakeSerializableTestRule().value(value);
++ SerializableRuleList instance = new SerializableRuleList().add(fakeRule);
++
++ SerializableRuleList cloned = (SerializableRuleList) SerializationUtils.clone(instance);
++
++ assertThat(cloned.rules().size()).isEqualTo(1);
++ assertThat(cloned.rules().get(0)).isInstanceOf(FakeSerializableTestRule.class).isEqualTo(fakeRule);
++ }
++
++ /**
++ * Fake SerializableTestRule with a string field and overriding equals.
++ */
++ private static class FakeSerializableTestRule implements SerializableTestRule {
++
++ private String value = null;
++
++ public FakeSerializableTestRule value(final String value) {
++ this.value = value;
++ return this;
++ }
++
++ public String value() {
++ return this.value;
++ }
++
++ @Override
++ public Statement apply(final Statement base, final Description description) {
++ return new Statement() {
++ @Override
++ public void evaluate() throws Throwable {
++ base.evaluate();
++ }
++ };
++ }
++
++ @Override
++ public boolean equals(Object o) {
++ if (this == o) return true;
++ if (o == null || getClass() != o.getClass()) return false;
++
++ FakeSerializableTestRule that = (FakeSerializableTestRule) o;
++
++ return this.value != null ? this.value.equals(that.value()) : that.value() == null;
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolderTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolderTest.java
index 0000000,0000000..de5b6ce
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolderTest.java
@@@ -1,0 -1,0 +1,92 @@@
++/*
++ * 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 static org.assertj.core.api.Assertions.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import org.apache.commons.lang.SerializationUtils;
++import org.junit.Rule;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++import org.junit.rules.TemporaryFolder;
++
++import java.io.File;
++import java.io.Serializable;
++import java.lang.reflect.Field;
++
++/**
++ * Unit tests for {@link SerializableTemporaryFolder}.
++ */
++@Category(UnitTest.class)
++public class SerializableTemporaryFolderTest {
++
++ @Rule
++ public TemporaryFolder temporaryFolder = new TemporaryFolder();
++
++ @Test
++ public void hasTwoFields() throws Exception {
++ Field[] fields = TemporaryFolder.class.getDeclaredFields();
++ /*for (Field field : fields) {
++ System.out.println("Field: " + field);
++ }*/
++ assertThat(fields.length).isEqualTo(2);
++ }
++
++ @Test
++ public void fieldParentFolderShouldExist() throws Exception {
++ Field field = TemporaryFolder.class.getDeclaredField(FIELD_PARENT_FOLDER);
++ assertThat(field.getType()).isEqualTo(File.class);
++ }
++
++ @Test
++ public void fieldFolderShouldExist() throws Exception {
++ Field field = TemporaryFolder.class.getDeclaredField(FIELD_FOLDER);
++ assertThat(field.getType()).isEqualTo(File.class);
++ }
++
++ @Test
++ public void fieldsCanBeRead() throws Exception {
++ File parentFolder = this.temporaryFolder.getRoot();
++
++ SerializableTemporaryFolder instance = new SerializableTemporaryFolder(parentFolder);
++ instance.create();
++
++ assertThat(readField(TemporaryFolder.class, instance, FIELD_PARENT_FOLDER)).isEqualTo(parentFolder);
++ assertThat(readField(TemporaryFolder.class, instance, FIELD_FOLDER)).isEqualTo(instance.getRoot());
++ }
++
++ @Test
++ public void isSerializable() throws Exception {
++ assertThat(SerializableTemporaryFolder.class).isInstanceOf(Serializable.class);
++ }
++
++ @Test
++ public void canBeSerialized() throws Exception {
++ File parentFolder = this.temporaryFolder.getRoot();
++
++ SerializableTemporaryFolder instance = new SerializableTemporaryFolder(parentFolder);
++ instance.create();
++
++ SerializableTemporaryFolder cloned = (SerializableTemporaryFolder)SerializationUtils.clone(instance);
++
++ assertThat(readField(TemporaryFolder.class, cloned, FIELD_PARENT_FOLDER)).isEqualTo(parentFolder);
++ assertThat(readField(TemporaryFolder.class, cloned, FIELD_FOLDER)).isEqualTo(cloned.getRoot());
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestFixtureRuleTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestFixtureRuleTest.java
index 0000000,0000000..cf09e05
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestFixtureRuleTest.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 org.assertj.core.api.Assertions.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import org.apache.commons.lang.SerializationUtils;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++
++import java.io.Serializable;
++
++/**
++ * Unit tests for {@link SerializableTestFixtureRule}.
++ */
++@Category(UnitTest.class)
++public class SerializableTestFixtureRuleTest {
++
++ @Test
++ public void isSerializable() throws Exception {
++ assertThat(SerializableTestFixtureRule.class).isInstanceOf(Serializable.class);
++ }
++
++ @Test
++ public void canBeSerialized() throws Throwable {
++ FakeSerializableTestFixtureRule instance = new FakeSerializableTestFixtureRule().value(1);
++
++ FakeSerializableTestFixtureRule cloned = (FakeSerializableTestFixtureRule) SerializationUtils.clone(instance);
++
++ assertThat(instance.value()).isEqualTo(1);
++ assertThat(cloned.value()).isEqualTo(1);
++
++ instance.value(2);
++
++ assertThat(instance.value()).isEqualTo(2);
++ assertThat(cloned.value()).isEqualTo(1);
++ }
++
++ /**
++ * Fake SerializableExternalResource with a simple int field.
++ */
++ private static class FakeSerializableTestFixtureRule extends SerializableTestFixtureRule {
++
++ private int value = -1;
++
++ public FakeSerializableTestFixtureRule value(final int value) {
++ this.value = value;
++ return this;
++ }
++
++ public int value() {
++ return this.value;
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestNameTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestNameTest.java
index 0000000,0000000..3c3b274
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestNameTest.java
@@@ -1,0 -1,0 +1,86 @@@
++/*
++ * 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.FieldsOfTestName.*;
++import static org.assertj.core.api.Assertions.*;
++import static org.mockito.Mockito.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import org.apache.commons.lang.SerializationUtils;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++import org.junit.rules.TestName;
++import org.junit.runner.Description;
++
++import java.io.Serializable;
++import java.lang.reflect.Field;
++
++/**
++ * Unit tests for {@link SerializableTestName}.
++ */
++@Category(UnitTest.class)
++public class SerializableTestNameTest {
++
++ @Test
++ public void hasOneFields() throws Exception {
++ Field[] fields = TestName.class.getDeclaredFields();
++ /*for (Field field : fields) {
++ System.out.println("Field: " + field);
++ }*/
++ assertThat(fields.length).isEqualTo(1);
++ }
++
++ @Test
++ public void fieldNameShouldExist() throws Exception {
++ Field field = TestName.class.getDeclaredField(FIELD_NAME);
++ assertThat(field.getType()).isEqualTo(String.class);
++ }
++
++ @Test
++ public void fieldsCanBeRead() throws Exception {
++ String name = "foo";
++ Description mockDescription = mock(Description.class);
++ when(mockDescription.getMethodName()).thenReturn(name);
++
++ SerializableTestName instance = new SerializableTestName();
++ instance.starting(mockDescription);
++
++ assertThat(instance.getMethodName()).isEqualTo(name);
++ }
++
++ @Test
++ public void isSerializable() throws Exception {
++ assertThat(SerializableTestName.class).isInstanceOf(Serializable.class);
++ }
++
++ @Test
++ public void canBeSerialized() throws Exception {
++ String name = "bar";
++ Description mockDescription = mock(Description.class);
++ when(mockDescription.getMethodName()).thenReturn(name);
++
++ SerializableTestName instance = new SerializableTestName();
++ instance.starting(mockDescription);
++
++ assertThat(instance.getMethodName()).isEqualTo(name);
++
++ SerializableTestName cloned = (SerializableTestName) SerializationUtils.clone(instance);
++
++ assertThat(cloned.getMethodName()).isEqualTo(name);
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcherTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcherTest.java
index 0000000,0000000..bda7fc5
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcherTest.java
@@@ -1,0 -1,0 +1,81 @@@
++/*
++ * 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 org.assertj.core.api.Assertions.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import org.apache.commons.lang.SerializationUtils;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++import org.junit.rules.TestWatcher;
++
++import java.io.Serializable;
++import java.lang.reflect.Field;
++
++/**
++ * Unit tests for {@link SerializableTestWatcher}.
++ */
++@Category(UnitTest.class)
++public class SerializableTestWatcherTest {
++
++ @Test
++ public void hasZeroFields() throws Exception {
++ Field[] fields = TestWatcher.class.getDeclaredFields();
++ /*for (Field field : fields) {
++ System.out.println("Field: " + field);
++ }*/
++ assertThat(fields.length).isEqualTo(0);
++ }
++
++ @Test
++ public void isSerializable() throws Exception {
++ assertThat(SerializableTestWatcher.class).isInstanceOf(Serializable.class);
++ }
++
++ @Test
++ public void canBeSerialized() throws Exception {
++ FakeSerializableTestWatcher instance = new FakeSerializableTestWatcher().value(1);
++
++ FakeSerializableTestWatcher cloned = (FakeSerializableTestWatcher) SerializationUtils.clone(instance);
++
++ assertThat(instance.value()).isEqualTo(1);
++ assertThat(cloned.value()).isEqualTo(1);
++
++ instance.value(2);
++
++ assertThat(instance.value()).isEqualTo(2);
++ assertThat(cloned.value()).isEqualTo(1);
++ }
++
++ /**
++ * Fake SerializableTestWatcher with a simple int field.
++ */
++ private static class FakeSerializableTestWatcher extends SerializableTestWatcher {
++
++ private int value = -1;
++
++ private FakeSerializableTestWatcher value(final int value) {
++ this.value = value;
++ return this;
++ }
++
++ private int value() {
++ return this.value;
++ }
++ }
++}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/504a222f/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeoutTest.java
----------------------------------------------------------------------
diff --cc geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeoutTest.java
index 0000000,0000000..543676f
new file mode 100755
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeoutTest.java
@@@ -1,0 -1,0 +1,108 @@@
++/*
++ * 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 static org.assertj.core.api.Assertions.*;
++
++import com.gemstone.gemfire.test.junit.categories.UnitTest;
++import org.apache.commons.lang.SerializationUtils;
++import org.junit.Test;
++import org.junit.experimental.categories.Category;
++import org.junit.rules.Timeout;
++
++import java.io.Serializable;
++import java.lang.reflect.Field;
++import java.util.concurrent.TimeUnit;
++
++/**
++ * Unit tests for {@link SerializableTimeout}.
++ */
++@Category(UnitTest.class)
++public class SerializableTimeoutTest {
++
++ @Test
++ public void hasThreeFields() throws Exception {
++ Field[] fields = Timeout.class.getDeclaredFields();
++ /*for (Field field : fields) {
++ System.out.println("Field: " + field);
++ }*/
++ assertThat(fields.length).isEqualTo(3);
++ }
++
++ @Test
++ public void fieldTimeoutShouldExist() throws Exception {
++ Field field = Timeout.class.getDeclaredField(FIELD_TIMEOUT);
++ assertThat(field.getType()).isEqualTo(Long.TYPE);
++ }
++
++ @Test
++ public void fieldTimeUnitShouldExist() throws Exception {
++ Field field = Timeout.class.getDeclaredField(FIELD_TIME_UNIT);
++ assertThat(field.getType()).isEqualTo(TimeUnit.class);
++ }
++
++ @Test
++ public void fieldLookForStuckThreadShouldExist() throws Exception {
++ Field field = Timeout.class.getDeclaredField(FIELD_LOOK_FOR_STUCK_THREAD);
++ assertThat(field.getType()).isEqualTo(Boolean.TYPE);
++ }
++
++ @Test
++ public void fieldsCanBeRead() throws Exception {
++ long timeout = 1000;
++ TimeUnit timeUnit = TimeUnit.MILLISECONDS;
++ boolean lookingForStuckThread = false;
++
++ SerializableTimeout instance = SerializableTimeout.builder()
++ .withTimeout(timeout, timeUnit)
++ .withLookingForStuckThread(lookingForStuckThread)
++ .build();
++
++ assertThat(readField(Timeout.class, instance, FIELD_TIMEOUT)).isEqualTo(timeout);
++ assertThat(readField(Timeout.class, instance, FIELD_TIME_UNIT)).isEqualTo(timeUnit);
++ assertThat(readField(Timeout.class, instance, FIELD_LOOK_FOR_STUCK_THREAD)).isEqualTo(lookingForStuckThread);
++ }
++
++ @Test
++ public void isSerializable() throws Exception {
++ assertThat(SerializableTimeout.class).isInstanceOf(Serializable.class);
++ }
++
++ @Test
++ public void canBeSerialized() throws Exception {
++ long timeout = 2;
++ TimeUnit timeUnit = TimeUnit.SECONDS;
++ boolean lookingForStuckThread = true;
++
++ SerializableTimeout instance = SerializableTimeout.builder()
++ .withTimeout(timeout, timeUnit)
++ .withLookingForStuckThread(lookingForStuckThread)
++ .build();
++
++ assertThat(readField(Timeout.class, instance, FIELD_TIMEOUT)).isEqualTo(timeout);
++ assertThat(readField(Timeout.class, instance, FIELD_TIME_UNIT)).isEqualTo(timeUnit);
++ assertThat(readField(Timeout.class, instance, FIELD_LOOK_FOR_STUCK_THREAD)).isEqualTo(lookingForStuckThread);
++
++ SerializableTimeout cloned = (SerializableTimeout) SerializationUtils.clone(instance);
++
++ assertThat(readField(Timeout.class, cloned, FIELD_TIMEOUT)).isEqualTo(timeout);
++ assertThat(readField(Timeout.class, cloned, FIELD_TIME_UNIT)).isEqualTo(timeUnit);
++ assertThat(readField(Timeout.class, cloned, FIELD_LOOK_FOR_STUCK_THREAD)).isEqualTo(lookingForStuckThread);
++ }
++}