You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/03/01 01:09:48 UTC
[3/7] incubator-geode git commit: GEODE-953: Cleanup geode-junit
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RepeatingTestCasesExampleTest.java
----------------------------------------------------------------------
diff --git 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
index 5ee647b..7fdf696 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
@@ -33,9 +33,8 @@ 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.
+ * of the JUnit {@literal @}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
@@ -43,10 +42,10 @@ import 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();
@@ -54,6 +53,10 @@ public class RepeatingTestCasesExampleTest {
@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
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleTest.java
----------------------------------------------------------------------
diff --git 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
index f6d70a2..3561169 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
@@ -18,21 +18,29 @@ 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++;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RuleAndClassRuleTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RuleAndClassRuleTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RuleAndClassRuleTest.java
new file mode 100755
index 0000000..4e69ec3
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RuleAndClassRuleTest.java
@@ -0,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 {@literal @}Rule and a {@literal @}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/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResourceTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResourceTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResourceTest.java
new file mode 100755
index 0000000..aa7ea40
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableExternalResourceTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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;
+import java.util.Arrays;
+
+/**
+ * Unit tests for {@link SerializableExternalResource}.
+ */
+@Category(UnitTest.class)
+public class SerializableExternalResourceTest {
+
+ @Test
+ public void hasZeroFields() throws Exception {
+ Field[] fields = ExternalResource.class.getDeclaredFields();
+ assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).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/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleListTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleListTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleListTest.java
new file mode 100755
index 0000000..ebd4b91
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableRuleListTest.java
@@ -0,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/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolderTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolderTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolderTest.java
new file mode 100755
index 0000000..b52787e
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTemporaryFolderTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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;
+import java.util.Arrays;
+
+/**
+ * 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();
+ assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).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/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestNameTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestNameTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestNameTest.java
new file mode 100755
index 0000000..9485816
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestNameTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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;
+import java.util.Arrays;
+
+/**
+ * Unit tests for {@link SerializableTestName}.
+ */
+@Category(UnitTest.class)
+public class SerializableTestNameTest {
+
+ @Test
+ public void hasOneFields() throws Exception {
+ Field[] fields = TestName.class.getDeclaredFields();
+ assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).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/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcherTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcherTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcherTest.java
new file mode 100755
index 0000000..1e8c1c4
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTestWatcherTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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;
+import java.util.Arrays;
+
+/**
+ * Unit tests for {@link SerializableTestWatcher}.
+ */
+@Category(UnitTest.class)
+public class SerializableTestWatcherTest {
+
+ @Test
+ public void hasZeroFields() throws Exception {
+ Field[] fields = TestWatcher.class.getDeclaredFields();
+ assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).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/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeoutTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeoutTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeoutTest.java
new file mode 100755
index 0000000..c266c63
--- /dev/null
+++ b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/serializable/SerializableTimeoutTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.Arrays;
+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();
+ assertThat(fields.length).as("Fields: " + Arrays.asList(fields)).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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleTest.java
deleted file mode 100755
index b67d1eb..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.ExpectedTimeoutRule;
-
-/**
- * Unit tests for ExpectedTimeout JUnit Rule.
- *
- * @author Kirk Lund
- * @since 8.2
- */
-@Category(UnitTest.class)
-public class ExpectedTimeoutRuleTest {
-
- @Test
- public void passesUnused() {
- Result result = runTest(PassingTestShouldPassWhenUnused.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- }
-
- @Test
- public void failsWithoutExpectedException() {
- Result result = runTest(FailsWithoutExpectedException.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage("Expected test to throw an instance of " + TimeoutException.class.getName());
- }
-
- @Test
- public void failsWithoutExpectedTimeoutException() {
- Result result = runTest(FailsWithoutExpectedTimeoutException.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWithoutExpectedTimeoutException.message + "\")");
- }
-
- @Test
- public void failsWithExpectedTimeoutButWrongError() {
- Result result = runTest(FailsWithExpectedTimeoutButWrongError.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- String expectedMessage =
- "\n" +
- "Expected: (an instance of java.util.concurrent.TimeoutException and exception with message a string containing \"this is a message for FailsWithExpectedTimeoutButWrongError\")" +
- "\n" +
- " " +
- "but: an instance of java.util.concurrent.TimeoutException <java.lang.NullPointerException> is a java.lang.NullPointerException";
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessageContaining(expectedMessage);
- }
-
- @Test
- public void passesWithExpectedTimeoutAndTimeoutException() {
- Result result = runTest(PassesWithExpectedTimeoutAndTimeoutException.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- }
-
- @Test
- public void failsWhenTimeoutIsEarly() {
- Result result = runTest(FailsWhenTimeoutIsEarly.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWhenTimeoutIsEarly.message + "\")");
- }
-
- @Test
- public void failsWhenTimeoutIsLate() {
- Result result = runTest(FailsWhenTimeoutIsLate.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWhenTimeoutIsLate.message + "\")");
- }
-
- public static class AbstractExpectedTimeoutRuleTest {
- @Rule
- public ExpectedTimeoutRule timeout = ExpectedTimeoutRule.none();
- }
-
- public static class PassingTestShouldPassWhenUnused extends AbstractExpectedTimeoutRuleTest {
- @Test
- public void passesUnused() throws Exception {
- }
- }
-
- public static class FailsWithoutExpectedException extends AbstractExpectedTimeoutRuleTest {
- @Test
- public void failsWithoutExpectedException() throws Exception {
- timeout.expect(TimeoutException.class);
- }
- }
-
- public static class FailsWithoutExpectedTimeoutException extends AbstractExpectedTimeoutRuleTest {
- public static final String message = "this is a message for FailsWithoutExpectedTimeoutException";
- @Test
- public void failsWithoutExpectedTimeoutAndTimeoutException() throws Exception {
- timeout.expect(TimeoutException.class);
- timeout.expectMessage(message);
- timeout.expectMinimumDuration(10);
- timeout.expectMaximumDuration(1000);
- timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
- Thread.sleep(100);
- }
- }
-
- public static class FailsWithExpectedTimeoutButWrongError extends AbstractExpectedTimeoutRuleTest {
- public static final String message = "this is a message for FailsWithExpectedTimeoutButWrongError";
- @Test
- public void failsWithExpectedTimeoutButWrongError() throws Exception {
- timeout.expect(TimeoutException.class);
- timeout.expectMessage(message);
- timeout.expectMinimumDuration(10);
- timeout.expectMaximumDuration(1000);
- timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
- Thread.sleep(100);
- throw new NullPointerException();
- }
- }
-
- public static class PassesWithExpectedTimeoutAndTimeoutException extends AbstractExpectedTimeoutRuleTest {
- public static final String message = "this is a message for PassesWithExpectedTimeoutAndTimeoutException";
- public static final Class<TimeoutException> exceptionClass = TimeoutException.class;
- @Test
- public void passesWithExpectedTimeoutAndTimeoutException() throws Exception {
- timeout.expect(exceptionClass);
- timeout.expectMessage(message);
- timeout.expectMinimumDuration(10);
- timeout.expectMaximumDuration(1000);
- timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
- Thread.sleep(100);
- throw new TimeoutException(message);
- }
- }
-
- public static class FailsWhenTimeoutIsEarly extends AbstractExpectedTimeoutRuleTest {
- public static final String message = "this is a message for FailsWhenTimeoutIsEarly";
- @Test
- public void failsWhenTimeoutIsEarly() throws Exception {
- timeout.expect(TimeoutException.class);
- timeout.expectMessage(message);
- timeout.expectMinimumDuration(1000);
- timeout.expectMaximumDuration(2000);
- timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
- Thread.sleep(10);
- }
- }
-
- public static class FailsWhenTimeoutIsLate extends AbstractExpectedTimeoutRuleTest {
- public static final String message = "this is a message for FailsWhenTimeoutIsLate";
- @Test
- public void failsWhenTimeoutIsLate() throws Exception {
- timeout.expect(TimeoutException.class);
- timeout.expectMessage(message);
- timeout.expectMinimumDuration(10);
- timeout.expectMaximumDuration(20);
- timeout.expectTimeUnit(TimeUnit.MILLISECONDS);
- Thread.sleep(100);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleTest.java
deleted file mode 100755
index a984d1d..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.List;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.IgnoreUntil;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.IgnoreUntilRule;
-
-/**
- * Unit tests for IgnoreUntil JUnit Rule
- *
- * @author Kirk Lund
- */
-@Category(UnitTest.class)
-public class IgnoreUntilRuleTest {
-
- private static final String ASSERTION_ERROR_MESSAGE = "failing test";
-
- @Test
- public void shouldIgnoreWhenUntilIsInFuture() {
- Result result = runTest(ShouldIgnoreWhenUntilIsInFuture.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(ShouldIgnoreWhenUntilIsInFuture.count).isEqualTo(0);
- }
-
- @Test
- public void shouldExecuteWhenUntilIsInPast() {
- Result result = runTest(ShouldExecuteWhenUntilIsInPast.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
- assertThat(ShouldExecuteWhenUntilIsInPast.count).isEqualTo(1);
- }
-
- @Test
- public void shouldExecuteWhenUntilIsDefault() {
- Result result = runTest(ShouldExecuteWhenUntilIsDefault.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
- assertThat(ShouldExecuteWhenUntilIsDefault.count).isEqualTo(1);
- }
-
- public static class ShouldIgnoreWhenUntilIsInFuture {
- private static int count;
-
- @Rule
- public final IgnoreUntilRule ignoreUntilRule = new IgnoreUntilRule();
-
- @Test
- @IgnoreUntil(value = "description", until = "3000-01-01")
- public void doTest() throws Exception {
- count++;
- fail(ASSERTION_ERROR_MESSAGE);
- }
- }
-
- public static class ShouldExecuteWhenUntilIsInPast {
- private static int count;
-
- @Rule
- public final IgnoreUntilRule ignoreUntilRule = new IgnoreUntilRule();
-
- @Test
- @IgnoreUntil(value = "description", until = "1980-01-01")
- public void doTest() throws Exception {
- count++;
- fail(ASSERTION_ERROR_MESSAGE);
- }
- }
-
- public static class ShouldExecuteWhenUntilIsDefault {
- private static int count;
-
- @Rule
- public final IgnoreUntilRule ignoreUntilRule = new IgnoreUntilRule();
-
- @Test
- @IgnoreUntil(value = "description")
- public void doTest() throws Exception {
- count++;
- fail(ASSERTION_ERROR_MESSAGE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java
deleted file mode 100755
index 4c9e315..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- ExpectedTimeoutRuleTest.class,
- IgnoreUntilRuleTest.class,
- RepeatRuleTest.class,
- RetryRuleGlobalWithErrorTest.class,
- RetryRuleGlobalWithExceptionTest.class,
- RetryRuleLocalWithErrorTest.class,
- RetryRuleLocalWithExceptionTest.class,
-})
-public class JUnitRuleTestSuite {
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleTest.java
deleted file mode 100755
index 2d37de4..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleTest.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.List;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.Repeat;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.RepeatRule;
-
-/**
- * Unit tests for Repeat JUnit Rule.
- *
- * @author Kirk Lund
- */
-@Category(UnitTest.class)
-public class RepeatRuleTest {
-
- private static final String ASSERTION_ERROR_MESSAGE = "failing test";
-
- @Test
- public void failingTestShouldFailOneTimeWhenRepeatIsUnused() {
- Result result = runTest(FailingTestShouldFailOneTimeWhenRepeatIsUnused.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsUnused.count).isEqualTo(1);
- }
-
- @Test
- public void passingTestShouldPassOneTimeWhenRepeatIsUnused() {
- Result result = runTest(PassingTestShouldPassOneTimeWhenRepeatIsUnused.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassingTestShouldPassOneTimeWhenRepeatIsUnused.count).isEqualTo(1);
- }
-
- @Test
- public void zeroValueShouldThrowIllegalArgumentException() {
- Result result = runTest(ZeroValueShouldThrowIllegalArgumentException.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(IllegalArgumentException.class).hasMessage("Repeat value must be a positive integer");
- assertThat(ZeroValueShouldThrowIllegalArgumentException.count).isEqualTo(0);
- }
-
- @Test
- public void negativeValueShouldThrowIllegalArgumentException() {
- Result result = runTest(NegativeValueShouldThrowIllegalArgumentException.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(IllegalArgumentException.class).hasMessage("Repeat value must be a positive integer");
- assertThat(NegativeValueShouldThrowIllegalArgumentException.count).isEqualTo(0);
- }
-
- @Test
- public void failingTestShouldFailOneTimeWhenRepeatIsOne() {
- Result result = runTest(FailingTestShouldFailOneTimeWhenRepeatIsOne.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsOne.count).isEqualTo(1);
- }
-
- @Test
- public void passingTestShouldPassOneTimeWhenRepeatIsOne() {
- Result result = runTest(PassingTestShouldPassOneTimeWhenRepeatIsOne.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassingTestShouldPassOneTimeWhenRepeatIsOne.count).isEqualTo(1);
- }
-
- @Test
- public void failingTestShouldFailOneTimeWhenRepeatIsTwo() {
- Result result = runTest(FailingTestShouldFailOneTimeWhenRepeatIsTwo.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsTwo.count).isEqualTo(1);
- }
-
- @Test
- public void passingTestShouldPassTwoTimesWhenRepeatIsTwo() {
- Result result = runTest(PassingTestShouldPassTwoTimesWhenRepeatIsTwo.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassingTestShouldPassTwoTimesWhenRepeatIsTwo.count).isEqualTo(2);
- }
-
- @Test
- public void failingTestShouldFailOneTimeWhenRepeatIsThree() {
- Result result = runTest(FailingTestShouldFailOneTimeWhenRepeatIsThree.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsThree.count).isEqualTo(1);
- }
-
- @Test
- public void passingTestShouldPassThreeTimesWhenRepeatIsThree() {
- Result result = runTest(PassingTestShouldPassThreeTimesWhenRepeatIsThree.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassingTestShouldPassThreeTimesWhenRepeatIsThree.count).isEqualTo(3);
- }
-
- public static class FailingTestShouldFailOneTimeWhenRepeatIsUnused {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- public void doTest() throws Exception {
- count++;
- fail(ASSERTION_ERROR_MESSAGE);
- }
- }
-
- public static class PassingTestShouldPassOneTimeWhenRepeatIsUnused {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- public void doTest() throws Exception {
- count++;
- }
- }
-
- public static class ZeroValueShouldThrowIllegalArgumentException {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(0)
- public void doTest() throws Exception {
- count++;
- }
- }
-
- public static class NegativeValueShouldThrowIllegalArgumentException {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(-1)
- public void doTest() throws Exception {
- count++;
- }
- }
-
- public static class PassingTestShouldBeSkippedWhenRepeatIsZero {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(0)
- public void doTest() throws Exception {
- count++;
- }
- }
-
- public static class FailingTestShouldFailOneTimeWhenRepeatIsOne {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(1)
- public void doTest() throws Exception {
- count++;
- fail(ASSERTION_ERROR_MESSAGE);
- }
- }
-
- public static class PassingTestShouldPassOneTimeWhenRepeatIsOne {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(1)
- public void doTest() throws Exception {
- count++;
- }
- }
-
- public static class FailingTestShouldFailOneTimeWhenRepeatIsTwo {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(2)
- public void doTest() throws Exception {
- count++;
- fail(ASSERTION_ERROR_MESSAGE);
- }
- }
-
- public static class PassingTestShouldPassTwoTimesWhenRepeatIsTwo {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(2)
- public void doTest() throws Exception {
- count++;
- }
- }
-
- public static class FailingTestShouldFailOneTimeWhenRepeatIsThree {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(3)
- public void doTest() throws Exception {
- count++;
- fail(ASSERTION_ERROR_MESSAGE);
- }
- }
-
- public static class PassingTestShouldPassThreeTimesWhenRepeatIsThree {
- protected static int count = 0;
-
- @Rule
- public RepeatRule repeat = new RepeatRule();
-
- @Test
- @Repeat(3)
- public void doTest() throws Exception {
- count++;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorTest.java
deleted file mode 100755
index 78bc410..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.Retry;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.RetryRule;
-
-/**
- * Unit tests for Retry JUnit Rule involving global scope (ie Rule affects all
- * tests in the test case) with failures due to an Exception.
- *
- * @author Kirk Lund
- */
-@Category(UnitTest.class)
-public class RetryRuleGlobalWithErrorTest {
-
- @Test
- public void zeroIsIllegal() {
- Result result = runTest(ZeroIsIllegal.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(IllegalArgumentException.class).hasMessage(ZeroIsIllegal.message);
- assertThat(ZeroIsIllegal.count).isEqualTo(0);
- }
-
- @Test
- public void failsWithOne() {
- Result result = runTest(FailsWithOne.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsWithOne.message);
- assertThat(FailsWithOne.count).isEqualTo(1);
- }
-
- @Test
- public void passesWithOne() {
- Result result = runTest(PassesWithOne.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesWithOne.count).isEqualTo(1);
- }
-
- @Test
- public void passesWithUnused() {
- Result result = runTest(PassesWhenUnused.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesWhenUnused.count).isEqualTo(1);
- }
-
- @Test
- public void failsOnSecondAttempt() {
- Result result = runTest(FailsOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnSecondAttempt.message);
- assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void passesOnSecondAttempt() {
- Result result = runTest(PassesOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void failsOnThirdAttempt() {
- Result result = runTest(FailsOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnThirdAttempt.message);
- assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
- }
-
- @Test
- public void passesOnThirdAttempt() {
- Result result = runTest(PassesOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
- }
-
- public static class ZeroIsIllegal {
- protected static int count;
- protected static final String message = "Retry count must be greater than zero";
-
- @Rule
- public RetryRule retryRule = new RetryRule(0);
-
- @Test
- public void zeroIsIllegal() throws Exception {
- count++;
- }
- }
-
- public static class FailsWithOne {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(1);
-
- @Test
- public void failsWithOne() throws Exception {
- count++;
- message = "Failing " + count;
- fail(message);
- }
- }
-
- public static class PassesWithOne {
- protected static int count;
-
- @Rule
- public RetryRule retryRule = new RetryRule(1);
-
- @Test
- public void passesWithOne() throws Exception {
- count++;
- }
- }
-
- public static class PassesWhenUnused {
- protected static int count;
-
- @Rule
- public RetryRule retryRule = new RetryRule(2);
-
- @Test
- public void passesWithUnused() throws Exception {
- count++;
- }
- }
-
- public static class FailsOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(2);
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() {
- count++;
- message = "Failing " + count;
- fail(message);
- }
- }
-
- public static class PassesOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(2);
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() {
- count++;
- if (count < 2) {
- message = "Failing " + count;
- fail(message);
- }
- }
- }
-
- public static class FailsOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(3);
-
- @Test
- @Retry(3)
- public void failsOnThirdAttempt() {
- count++;
- message = "Failing " + count;
- fail(message);
- }
- }
-
- public static class PassesOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(3);
-
- @Test
- public void failsOnThirdAttempt() {
- count++;
- if (count < 3) {
- message = "Failing " + count;
- fail(message);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionTest.java
deleted file mode 100755
index 114eeb4..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionTest.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.List;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.Retry;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.RetryRule;
-
-/**
- * Unit tests for Retry JUnit Rule involving global scope (ie Rule affects all
- * tests in the test case) with failures due to an Exception.
- *
- * @author Kirk Lund
- */
-@Category(UnitTest.class)
-public class RetryRuleGlobalWithExceptionTest {
-
- @Test
- public void zeroIsIllegal() {
- Result result = runTest(ZeroIsIllegal.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(IllegalArgumentException.class).hasMessage(ZeroIsIllegal.message);
- assertThat(ZeroIsIllegal.count).isEqualTo(0);
- }
-
- @Test
- public void failsWithOne() {
- Result result = runTest(FailsWithOne.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsWithOne.message);
- assertThat(FailsWithOne.count).isEqualTo(1);
- }
-
- @Test
- public void passesWithOne() {
- Result result = runTest(PassesWithOne.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- }
-
- @Test
- public void passesWithUnused() {
- Result result = runTest(PassesWhenUnused.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- }
-
- @Test
- public void failsOnSecondAttempt() {
- Result result = runTest(FailsOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnSecondAttempt.message);
- assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void passesOnSecondAttempt() {
- Result result = runTest(PassesOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void failsOnThirdAttempt() {
- Result result = runTest(FailsOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnThirdAttempt.message);
- assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
- }
-
- @Test
- public void passesOnThirdAttempt() {
- Result result = runTest(PassesOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
- }
-
- public static class CustomException extends Exception {
- private static final long serialVersionUID = 1L;
- public CustomException(final String message) {
- super(message);
- }
- }
-
- public static class ZeroIsIllegal {
- protected static int count;
- protected static final String message = "Retry count must be greater than zero";
-
- @Rule
- public RetryRule retryRule = new RetryRule(0);
-
- @Test
- public void zeroIsIllegal() throws Exception {
- count++;
- }
- }
-
- public static class FailsWithOne {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(1);
-
- @Test
- public void failsWithOne() throws Exception {
- count++;
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
-
- public static class PassesWithOne {
- protected static int count;
-
- @Rule
- public RetryRule retryRule = new RetryRule(1);
-
- @Test
- public void passesWithOne() throws Exception {
- count++;
- }
- }
-
- public static class PassesWhenUnused {
- protected static int count;
-
- @Rule
- public RetryRule retryRule = new RetryRule(2);
-
- @Test
- public void passesWithUnused() throws Exception {
- count++;
- }
- }
-
- public static class FailsOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(2);
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() throws Exception {
- count++;
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
-
- public static class PassesOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(2);
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() throws Exception {
- count++;
- if (count < 2) {
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
- }
-
- public static class FailsOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(3);
-
- @Test
- @Retry(3)
- public void failsOnThirdAttempt() throws Exception {
- count++;
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
-
- public static class PassesOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule(3);
-
- @Test
- public void failsOnThirdAttempt() throws Exception {
- count++;
- if (count < 3) {
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorTest.java
deleted file mode 100755
index af5a853..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.Retry;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.RetryRule;
-
-/**
- * Unit tests for Retry JUnit Rule involving local scope (ie Rule affects
- * test methods annotated with @Retry) with failures due to an Error.
- *
- * @author Kirk Lund
- */
-@Category(UnitTest.class)
-public class RetryRuleLocalWithErrorTest {
-
- @Test
- public void failsUnused() {
- Result result = runTest(FailsUnused.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsUnused.message);
- assertThat(FailsUnused.count).isEqualTo(1);
- }
-
- @Test
- public void passesUnused() {
- Result result = runTest(PassesUnused.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesUnused.count).isEqualTo(1);
- }
-
- @Test
- public void failsOnSecondAttempt() {
- Result result = runTest(FailsOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnSecondAttempt.message);
- assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void passesOnSecondAttempt() {
- Result result = runTest(PassesOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void failsOnThirdAttempt() {
- Result result = runTest(FailsOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnThirdAttempt.message);
- assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
- }
-
- @Test
- public void passesOnThirdAttempt() {
- Result result = runTest(PassesOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
- }
-
- public static class FailsUnused {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- public void failsUnused() throws Exception {
- count++;
- message = "Failing " + count;
- fail(message);
- }
- }
-
- public static class PassesUnused {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- public void passesUnused() throws Exception {
- count++;
- }
- }
-
- public static class FailsOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() {
- count++;
- message = "Failing " + count;
- fail(message);
- }
- }
-
- public static class PassesOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() {
- count++;
- if (count < 2) {
- message = "Failing " + count;
- fail(message);
- }
- }
- }
-
- public static class FailsOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(3)
- public void failsOnThirdAttempt() {
- count++;
-
- message = "Failing " + count;
- fail(message);
- }
- }
-
- public static class PassesOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(3)
- public void failsOnThirdAttempt() {
- count++;
-
- if (count < 3) {
- message = "Failing " + count;
- fail(message);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5342935d/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionTest.java
----------------------------------------------------------------------
diff --git a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionTest.java b/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionTest.java
deleted file mode 100755
index 1b16a7a..0000000
--- a/geode-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionTest.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.gemstone.gemfire.test.junit.rules.tests;
-
-import static com.gemstone.gemfire.test.junit.rules.tests.TestRunner.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.List;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.Result;
-import org.junit.runner.notification.Failure;
-
-import com.gemstone.gemfire.test.junit.Retry;
-import com.gemstone.gemfire.test.junit.categories.UnitTest;
-import com.gemstone.gemfire.test.junit.rules.RetryRule;
-
-/**
- * Unit tests for Retry JUnit Rule involving local scope (ie Rule affects
- * test methods annotated with @Retry) with failures due to an Exception.
- *
- * @author Kirk Lund
- */
-@Category(UnitTest.class)
-public class RetryRuleLocalWithExceptionTest {
-
- @Test
- public void failsUnused() {
- Result result = runTest(FailsUnused.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsUnused.message);
- assertThat(FailsUnused.count).isEqualTo(1);
- }
-
- @Test
- public void passesUnused() {
- Result result = runTest(PassesUnused.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesUnused.count).isEqualTo(1);
- }
-
- @Test
- public void failsOnSecondAttempt() {
- Result result = runTest(FailsOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnSecondAttempt.message);
- assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void passesOnSecondAttempt() {
- Result result = runTest(PassesOnSecondAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
- }
-
- @Test
- public void failsOnThirdAttempt() {
- Result result = runTest(FailsOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isFalse();
-
- List<Failure> failures = result.getFailures();
- assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
-
- Failure failure = failures.get(0);
- assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnThirdAttempt.message);
- assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
- }
-
- @Test
- public void passesOnThirdAttempt() {
- Result result = runTest(PassesOnThirdAttempt.class);
-
- assertThat(result.wasSuccessful()).isTrue();
- assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
- }
-
- public static class CustomException extends Exception {
- private static final long serialVersionUID = 1L;
- public CustomException(final String message) {
- super(message);
- }
- }
-
- public static class FailsUnused {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- public void failsUnused() throws Exception {
- count++;
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
-
- public static class PassesUnused {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- public void passesUnused() throws Exception {
- count++;
- }
- }
-
- public static class FailsOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() throws Exception {
- count++;
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
-
- public static class PassesOnSecondAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(2)
- public void failsOnSecondAttempt() throws Exception {
- count++;
- if (count < 2) {
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
- }
-
- public static class FailsOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(3)
- public void failsOnThirdAttempt() throws Exception {
- count++;
-
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
-
- public static class PassesOnThirdAttempt {
- protected static int count;
- protected static String message;
-
- @Rule
- public RetryRule retryRule = new RetryRule();
-
- @Test
- @Retry(3)
- public void failsOnThirdAttempt() throws Exception {
- count++;
-
- if (count < 3) {
- message = "Failing " + count;
- throw new CustomException(message);
- }
- }
- }
-}