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 2015/08/28 00:30:16 UTC
incubator-geode git commit: Standardize on AssertJ assertions
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-217 43aefeb0e -> 7c27657a0
Standardize on AssertJ assertions
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7c27657a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7c27657a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7c27657a
Branch: refs/heads/feature/GEODE-217
Commit: 7c27657a04f0550f6440375e959df2e8660b7c68
Parents: 43aefeb
Author: Kirk Lund <kl...@pivotal.io>
Authored: Thu Aug 27 13:34:33 2015 -0700
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Thu Aug 27 13:34:33 2015 -0700
----------------------------------------------------------------------
.../distributed/HostedLocatorsDUnitTest.java | 47 +++++++-----
.../gemfire/test/dunit/DUnitTestRule.java | 40 +++++++++++
.../DistributedRestoreSystemProperties.java | 2 +
.../tests/LogPerTestClassTwoDUnitTest.java | 1 -
.../test/junit/rules/ConditionalIgnoreRule.java | 5 +-
.../test/junit/rules/IgnoreUntilRule.java | 5 +-
.../gemfire/test/junit/rules/RepeatRule.java | 8 +--
.../gemfire/test/junit/rules/RetryRule.java | 6 +-
.../rules/SerializableExternalResource.java | 1 +
.../examples/RetryRuleExampleJUnitTest.java | 5 +-
.../tests/ExpectedTimeoutRuleJUnitTest.java | 50 +++++++------
.../rules/tests/IgnoreUntilRuleJUnitTest.java | 27 +++----
.../junit/rules/tests/JUnitRuleTestSuite.java | 1 +
.../junit/rules/tests/RepeatRuleJUnitTest.java | 76 +++++++++-----------
.../RetryRuleGlobalWithErrorJUnitTest.java | 59 +++++++--------
.../RetryRuleGlobalWithExceptionJUnitTest.java | 57 +++++++--------
.../tests/RetryRuleLocalWithErrorJUnitTest.java | 47 +++++-------
.../RetryRuleLocalWithExceptionJUnitTest.java | 47 +++++-------
.../IgnoreConditionEvaluationException.java | 2 +-
19 files changed, 247 insertions(+), 239 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
index 8f5c943..779888b 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/HostedLocatorsDUnitTest.java
@@ -1,10 +1,12 @@
package com.gemstone.gemfire.distributed;
+import static com.gemstone.gemfire.test.dunit.DUnitTestRule.*;
import static com.jayway.awaitility.Awaitility.*;
import static java.util.concurrent.TimeUnit.*;
import static org.junit.Assert.*;
import java.io.File;
+import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
@@ -16,6 +18,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.rules.RuleChain;
import com.gemstone.gemfire.distributed.AbstractLauncher.Status;
import com.gemstone.gemfire.distributed.LocatorLauncher.Builder;
@@ -27,8 +30,7 @@ import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedM
import com.gemstone.gemfire.internal.AvailablePortHelper;
import com.gemstone.gemfire.internal.SocketCreator;
import com.gemstone.gemfire.internal.util.StopWatch;
-
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.DUnitTestRule;
import com.gemstone.gemfire.test.dunit.Host;
import com.gemstone.gemfire.test.dunit.SerializableCallable;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
@@ -42,28 +44,38 @@ import com.gemstone.gemfire.test.junit.categories.MembershipTest;
* @author Kirk Lund
* @since 8.0
*/
-@SuppressWarnings("serial")
@Category({ DistributedTest.class, MembershipTest.class })
-public class HostedLocatorsDUnitTest extends DistributedTestCase {
+@SuppressWarnings("serial")
+public class HostedLocatorsDUnitTest implements Serializable {
- //protected static final int TIMEOUT_MILLISECONDS = 5 * 60 * 1000; // 5 minutes
+ protected static final int TIMEOUT_MINUTES = 5;
protected transient volatile int locatorPort;
protected transient volatile LocatorLauncher launcher;
- @Rule
- public final DistributedRestoreSystemProperties restoreSystemProperties = new DistributedRestoreSystemProperties();
-
- @Before
- public void setUp() throws Exception {
- disconnectAllFromDS();
- }
+// @Rule
+// public transient RuleChain chain = RuleChain
+// .outerRule(new DUnitTestRule())
+// .around(new DistributedRestoreSystemProperties());
- @After
- public void tearDown() throws Exception {
- disconnectAllFromDS();
- }
+ @Rule
+ public final DUnitTestRule dunitTestRule = DUnitTestRule.builder()
+ .disconnectBefore(true)
+ .disconnectAfter(true)
+ .chainRule(new DistributedRestoreSystemProperties())
+ .build();
+
+// @Before
+// public void before() {
+// disconnectAllFromDS();
+// }
+//
+// @After
+// public void after() {
+// disconnectAllFromDS();
+// }
+
@Test
public void getAllHostedLocators() throws Exception {
final InternalDistributedSystem system = getSystem();
@@ -96,8 +108,7 @@ public class HostedLocatorsDUnitTest extends DistributedTestCase {
launcher = builder.build();
assertEquals(Status.ONLINE, launcher.start().getStatus());
- //was: waitForLocatorToStart(launcher, TIMEOUT_MILLISECONDS, 10, true); --> Awaitility
- with().pollInterval(10, MILLISECONDS).await().atMost(5, MINUTES).until( isLocatorStarted() );
+ with().pollInterval(10, MILLISECONDS).await().atMost(TIMEOUT_MINUTES, MINUTES).until( isLocatorStarted() );
return null;
} finally {
System.clearProperty("gemfire.locators");
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitTestRule.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitTestRule.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitTestRule.java
index 72bfa13..ac2e4c0 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitTestRule.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DUnitTestRule.java
@@ -6,7 +6,9 @@ import static com.gemstone.gemfire.test.dunit.Invoke.invokeInLocator;
import static org.junit.Assert.assertEquals;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -54,6 +56,9 @@ public class DUnitTestRule implements TestRule, Serializable {
private volatile String className;
private volatile String methodName;
+ private final boolean disconnectBefore;
+ private final boolean disconnectAfter;
+
private static class StaticContext {
private static volatile boolean logPerTestClass;
private static volatile boolean logPerTestMethod;
@@ -73,10 +78,17 @@ public class DUnitTestRule implements TestRule, Serializable {
protected DUnitTestRule(final Builder builder) {
StaticContext.logPerTestClass = builder.logPerTestClass;
StaticContext.logPerTestMethod = builder.logPerTestMethod;
+ this.disconnectBefore = builder.disconnectBefore;
+ this.disconnectAfter = builder.disconnectAfter;
+ if (!builder.ruleChain.isEmpty()) {
+
+ }
}
public DUnitTestRule() {
StaticContext.logPerTestClass = Boolean.getBoolean(LOG_PER_TEST_CLASS_PROPERTY);
+ this.disconnectBefore = false;
+ this.disconnectAfter = false;
}
@Override
@@ -107,12 +119,22 @@ public class DUnitTestRule implements TestRule, Serializable {
}
protected void before() throws Throwable {
+ System.out.println("KIRK DUnitTestRule before");
DUnitLauncher.launchIfNeeded();
setUpDistributedTestCase();
+
+ if (this.disconnectBefore) {
+ disconnectAllFromDS();
+ }
}
protected void after() throws Throwable {
+ System.out.println("KIRK DUnitTestRule after");
+ if (this.disconnectAfter) {
+ disconnectAllFromDS();
+ }
+
tearDownDistributedTestCase();
}
@@ -593,6 +615,9 @@ public class DUnitTestRule implements TestRule, Serializable {
public static class Builder {
private boolean logPerTestMethod;
private boolean logPerTestClass;
+ private boolean disconnectBefore;
+ private boolean disconnectAfter;
+ private List<TestRule> ruleChain = new ArrayList<TestRule>();
protected Builder() {}
@@ -616,6 +641,21 @@ public class DUnitTestRule implements TestRule, Serializable {
return this;
}
+ public Builder disconnectBefore(final boolean disconnectBefore) {
+ this.disconnectBefore = disconnectBefore;
+ return this;
+ }
+
+ public Builder disconnectAfter(final boolean disconnectAfter) {
+ this.disconnectAfter = disconnectAfter;
+ return this;
+ }
+
+ public Builder chainRule(final TestRule enclosedRule) {
+ this.ruleChain.add(enclosedRule);
+ return this;
+ }
+
public DUnitTestRule build() {
return new DUnitTestRule(this);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
index ca022b9..cea3dcd 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/rules/DistributedRestoreSystemProperties.java
@@ -36,6 +36,7 @@ public class DistributedRestoreSystemProperties extends RestoreSystemProperties
@Override
protected void before() throws Throwable {
+ System.out.println("KIRK DistributedRestoreSystemProperties before");
super.before();
this.invoker.remoteInvokeInEveryVMAndLocator(new SerializableRunnable() {
@Override
@@ -48,6 +49,7 @@ public class DistributedRestoreSystemProperties extends RestoreSystemProperties
@Override
protected void after() {
+ System.out.println("KIRK DistributedRestoreSystemProperties after");
super.after();
this.invoker.remoteInvokeInEveryVMAndLocator(new SerializableRunnable() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/LogPerTestClassTwoDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/LogPerTestClassTwoDUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/LogPerTestClassTwoDUnitTest.java
index c28e452..30fe24e 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/LogPerTestClassTwoDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/tests/LogPerTestClassTwoDUnitTest.java
@@ -1,6 +1,5 @@
package com.gemstone.gemfire.test.dunit.tests;
-
import static com.gemstone.gemfire.test.dunit.DUnitTestRule.*;
import static org.assertj.core.api.Assertions.*;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
index 9d73e32..d36c80e 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/ConditionalIgnoreRule.java
@@ -1,5 +1,6 @@
package com.gemstone.gemfire.test.junit.rules;
+import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -23,8 +24,8 @@ import com.gemstone.gemfire.test.junit.support.IgnoreConditionEvaluationExceptio
* @see com.gemstone.gemfire.test.junit.ConditionalIgnore
* @see com.gemstone.gemfire.test.junit.IgnoreCondition
*/
-@SuppressWarnings("unused")
-public class ConditionalIgnoreRule implements TestRule {
+@SuppressWarnings({ "serial", "unused" })
+public class ConditionalIgnoreRule implements TestRule, Serializable {
protected static final String DATE_FORMAT_PATTERN = "yyyy-MM-dd";
protected static final String DEFAULT_MESSAGE = "Ignoring test case (%1$s) of test class (%2$s)!";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
index 0f4b99d..c13d3ba 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/IgnoreUntilRule.java
@@ -1,5 +1,6 @@
package com.gemstone.gemfire.test.junit.rules;
+import java.io.Serializable;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -23,8 +24,8 @@ import com.gemstone.gemfire.test.junit.support.IgnoreConditionEvaluationExceptio
* @see com.gemstone.gemfire.test.junit.IgnoreUntil
* @see com.gemstone.gemfire.test.junit.IgnoreCondition
*/
-@SuppressWarnings("unused")
-public class IgnoreUntilRule implements TestRule {
+@SuppressWarnings({ "serial", "unused" })
+public class IgnoreUntilRule implements TestRule, Serializable {
protected static final String DATE_FORMAT_PATTERN = "yyyy-MM-dd";
protected static final String DEFAULT_MESSAGE = "Ignoring test case (%1$s) of test class (%2$s)!";
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
index 8da22c4..d3ac16c 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RepeatRule.java
@@ -1,5 +1,7 @@
package com.gemstone.gemfire.test.junit.rules;
+import java.io.Serializable;
+
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -8,16 +10,14 @@ import com.gemstone.gemfire.test.junit.Repeat;
/**
* The RepeatRule class is a JUnit TestRule that enables an appropriately @Repeat annotated test case method
* to be repeated a specified number of times.
- *
- * TODO: disallow 0 because @Retry(0) is equivalent to @Ignore apparently
*
* @author John Blum
* @see org.junit.rules.TestRule
* @see org.junit.runner.Description
* @see org.junit.runners.model.Statement
*/
-@SuppressWarnings("unused")
-public class RepeatRule implements TestRule {
+@SuppressWarnings({ "serial", "unused" })
+public class RepeatRule implements TestRule, Serializable {
protected static final int DEFAULT_REPETITIONS = 1;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
index 0de55ac..2484611 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/RetryRule.java
@@ -1,5 +1,7 @@
package com.gemstone.gemfire.test.junit.rules;
+import java.io.Serializable;
+
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -39,7 +41,9 @@ import com.gemstone.gemfire.test.junit.Retry;
* This version of RetryRule will retry a test that fails because of any kind
* of Throwable.
*/
-public class RetryRule implements TestRule {
+@SuppressWarnings("serial")
+public class RetryRule implements TestRule, Serializable {
+
/**
* Enables printing of failures to System.err even if test passes on a retry
*/
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java
index 5cc439c..7cfbc96 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/SerializableExternalResource.java
@@ -15,6 +15,7 @@ import org.junit.runners.model.Statement;
*/
@SuppressWarnings("serial")
public abstract class SerializableExternalResource implements Serializable, TestRule {
+
public Statement apply(Statement base, Description description) {
return statement(base);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleJUnitTest.java
index 6ce4b94..04ff0f4 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/examples/RetryRuleExampleJUnitTest.java
@@ -1,7 +1,6 @@
package com.gemstone.gemfire.test.junit.rules.examples;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.assertj.core.api.Assertions.*;
import org.junit.Rule;
import org.junit.Test;
@@ -22,7 +21,7 @@ public class RetryRuleExampleJUnitTest {
public void unreliableTestWithRaceConditions() {
count++;
if (count < 2) {
- assertThat(count, is(2)); // doomed to fail
+ assertThat(count).isEqualTo(2); // doomed to fail
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleJUnitTest.java
index 27aa258..41ef275 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/ExpectedTimeoutRuleJUnitTest.java
@@ -1,10 +1,7 @@
package com.gemstone.gemfire.test.junit.rules.tests;
import static com.gemstone.gemfire.test.junit.rules.tests.RunTest.*;
-import static org.hamcrest.core.StringContains.*;
-import static org.hamcrest.core.Is.*;
-import static org.hamcrest.core.IsInstanceOf.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -32,84 +29,85 @@ public class ExpectedTimeoutRuleJUnitTest {
public void passesUnused() {
Result result = runTest(PassingTestShouldPassWhenUnused.class);
- assertTrue(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isTrue();
}
@Test
public void failsWithoutExpectedException() {
Result result = runTest(FailsWithoutExpectedException.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString("Expected test to throw an instance of " + TimeoutException.class.getName()));
+ 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);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWithoutExpectedTimeoutException.message + "\")"));
+ 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);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(NullPointerException.class.getName()));
+ 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);
- assertTrue(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isTrue();
}
@Test
public void failsWhenTimeoutIsEarly() {
Result result = runTest(FailsWhenTimeoutIsEarly.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWhenTimeoutIsEarly.message + "\")"));
+ 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);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString("Expected test to throw (an instance of " + TimeoutException.class.getName() + " and exception with message a string containing \"" + FailsWhenTimeoutIsLate.message + "\")"));
+ 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 {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleJUnitTest.java
index 80724bb..9d8d5e6 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/IgnoreUntilRuleJUnitTest.java
@@ -1,10 +1,7 @@
package com.gemstone.gemfire.test.junit.rules.tests;
import static com.gemstone.gemfire.test.junit.rules.tests.RunTest.*;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import java.util.List;
@@ -32,38 +29,36 @@ public class IgnoreUntilRuleJUnitTest {
public void shouldIgnoreWhenUntilIsInFuture() {
Result result = runTest(ShouldIgnoreWhenUntilIsInFuture.class);
- assertTrue(result.wasSuccessful());
- assertThat(ShouldIgnoreWhenUntilIsInFuture.count, is(0));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(ShouldIgnoreWhenUntilIsInFuture.count).isEqualTo(0);
}
@Test
public void shouldExecuteWhenUntilIsInPast() {
Result result = runTest(ShouldExecuteWhenUntilIsInPast.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(ASSERTION_ERROR_MESSAGE));
- assertThat(ShouldExecuteWhenUntilIsInPast.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
+ assertThat(ShouldExecuteWhenUntilIsInPast.count).isEqualTo(1);
}
@Test
public void shouldExecuteWhenUntilIsDefault() {
Result result = runTest(ShouldExecuteWhenUntilIsDefault.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(ASSERTION_ERROR_MESSAGE));
- assertThat(ShouldExecuteWhenUntilIsDefault.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
+ assertThat(ShouldExecuteWhenUntilIsDefault.count).isEqualTo(1);
}
public static class ShouldIgnoreWhenUntilIsInFuture {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java
index ff102f7..56e7d81 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/JUnitRuleTestSuite.java
@@ -6,6 +6,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
ExpectedTimeoutRuleJUnitTest.class,
+ IgnoreUntilRuleJUnitTest.class,
RepeatRuleJUnitTest.class,
RetryRuleGlobalWithErrorJUnitTest.class,
RetryRuleGlobalWithExceptionJUnitTest.class,
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleJUnitTest.java
index 749b81b..337f816 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RepeatRuleJUnitTest.java
@@ -1,11 +1,7 @@
package com.gemstone.gemfire.test.junit.rules.tests;
import static com.gemstone.gemfire.test.junit.rules.tests.RunTest.*;
-import static org.hamcrest.Matchers.*;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
import java.util.List;
@@ -33,122 +29,116 @@ public class RepeatRuleJUnitTest {
public void failingTestShouldFailOneTimeWhenRepeatIsUnused() {
Result result = runTest(FailingTestShouldFailOneTimeWhenRepeatIsUnused.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(ASSERTION_ERROR_MESSAGE));
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsUnused.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
+ assertThat(FailingTestShouldFailOneTimeWhenRepeatIsUnused.count).isEqualTo(1);
}
@Test
public void passingTestShouldPassOneTimeWhenRepeatIsUnused() {
Result result = runTest(PassingTestShouldPassOneTimeWhenRepeatIsUnused.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassingTestShouldPassOneTimeWhenRepeatIsUnused.count, is(1));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassingTestShouldPassOneTimeWhenRepeatIsUnused.count).isEqualTo(1);
}
@Test
public void zeroValueShouldThrowIllegalArgumentException() {
Result result = runTest(ZeroValueShouldThrowIllegalArgumentException.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(IllegalArgumentException.class)));
- assertThat(failure.getException().getMessage(), containsString("Repeat value must be a positive integer"));
- assertThat(ZeroValueShouldThrowIllegalArgumentException.count, is(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);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(IllegalArgumentException.class)));
- assertThat(failure.getException().getMessage(), containsString("Repeat value must be a positive integer"));
- assertThat(NegativeValueShouldThrowIllegalArgumentException.count, is(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);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(ASSERTION_ERROR_MESSAGE));
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsOne.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
+ assertThat(FailingTestShouldFailOneTimeWhenRepeatIsOne.count).isEqualTo(1);
}
@Test
public void passingTestShouldPassOneTimeWhenRepeatIsOne() {
Result result = runTest(PassingTestShouldPassOneTimeWhenRepeatIsOne.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassingTestShouldPassOneTimeWhenRepeatIsOne.count, is(1));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassingTestShouldPassOneTimeWhenRepeatIsOne.count).isEqualTo(1);
}
@Test
public void failingTestShouldFailOneTimeWhenRepeatIsTwo() {
Result result = runTest(FailingTestShouldFailOneTimeWhenRepeatIsTwo.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(ASSERTION_ERROR_MESSAGE));
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsTwo.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
+ assertThat(FailingTestShouldFailOneTimeWhenRepeatIsTwo.count).isEqualTo(1);
}
@Test
public void passingTestShouldPassTwoTimesWhenRepeatIsTwo() {
Result result = runTest(PassingTestShouldPassTwoTimesWhenRepeatIsTwo.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassingTestShouldPassTwoTimesWhenRepeatIsTwo.count, is(2));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassingTestShouldPassTwoTimesWhenRepeatIsTwo.count).isEqualTo(2);
}
@Test
public void failingTestShouldFailOneTimeWhenRepeatIsThree() {
Result result = runTest(FailingTestShouldFailOneTimeWhenRepeatIsThree.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(ASSERTION_ERROR_MESSAGE));
- assertThat(FailingTestShouldFailOneTimeWhenRepeatIsThree.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(ASSERTION_ERROR_MESSAGE);
+ assertThat(FailingTestShouldFailOneTimeWhenRepeatIsThree.count).isEqualTo(1);
}
@Test
public void passingTestShouldPassThreeTimesWhenRepeatIsThree() {
Result result = runTest(PassingTestShouldPassThreeTimesWhenRepeatIsThree.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassingTestShouldPassThreeTimesWhenRepeatIsThree.count, is(3));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassingTestShouldPassThreeTimesWhenRepeatIsThree.count).isEqualTo(3);
}
public static class FailingTestShouldFailOneTimeWhenRepeatIsUnused {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorJUnitTest.java
index 24d636b..2e07126 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithErrorJUnitTest.java
@@ -1,13 +1,7 @@
package com.gemstone.gemfire.test.junit.rules.tests;
import static com.gemstone.gemfire.test.junit.rules.tests.RunTest.*;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.fail;
import java.util.List;
@@ -35,94 +29,93 @@ public class RetryRuleGlobalWithErrorJUnitTest {
public void zeroIsIllegal() {
Result result = runTest(ZeroIsIllegal.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(IllegalArgumentException.class)));
- assertThat(failure.getException().getMessage(), containsString("Retry count must be greater than zero"));
- assertThat(ZeroIsIllegal.count, is(0));
+ assertThat(failure.getException()).isExactlyInstanceOf(IllegalArgumentException.class).hasMessage(ZeroIsIllegal.message);
+ assertThat(ZeroIsIllegal.count).isEqualTo(0);
}
@Test
public void failsWithOne() {
Result result = runTest(FailsWithOne.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsWithOne.message));
- assertThat(FailsWithOne.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsWithOne.message);
+ assertThat(FailsWithOne.count).isEqualTo(1);
}
@Test
public void passesWithOne() {
Result result = runTest(PassesWithOne.class);
- assertTrue(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesWithOne.count).isEqualTo(1);
}
@Test
public void passesWithUnused() {
Result result = runTest(PassesWhenUnused.class);
- assertTrue(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesWhenUnused.count).isEqualTo(1);
}
@Test
public void failsOnSecondAttempt() {
Result result = runTest(FailsOnSecondAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnSecondAttempt.message));
- assertThat(FailsOnSecondAttempt.count, is(2));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnSecondAttempt.message);
+ assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void passesOnSecondAttempt() {
Result result = runTest(PassesOnSecondAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnSecondAttempt.count, is(2));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void failsOnThirdAttempt() {
Result result = runTest(FailsOnThirdAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnThirdAttempt.message));
- assertThat(FailsOnThirdAttempt.count, is(3));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnThirdAttempt.message);
+ assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
}
@Test
public void passesOnThirdAttempt() {
Result result = runTest(PassesOnThirdAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnThirdAttempt.count, is(3));
+ 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);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionJUnitTest.java
index b2a5840..93c6dc5 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleGlobalWithExceptionJUnitTest.java
@@ -1,13 +1,7 @@
package com.gemstone.gemfire.test.junit.rules.tests;
import static com.gemstone.gemfire.test.junit.rules.tests.RunTest.*;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.*;
import java.util.List;
@@ -34,90 +28,86 @@ public class RetryRuleGlobalWithExceptionJUnitTest {
public void zeroIsIllegal() {
Result result = runTest(ZeroIsIllegal.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(IllegalArgumentException.class)));
- assertThat(failure.getException().getMessage(), containsString("Retry count must be greater than zero"));
- assertThat(ZeroIsIllegal.count, is(0));
+ assertThat(failure.getException()).isExactlyInstanceOf(IllegalArgumentException.class).hasMessage(ZeroIsIllegal.message);
+ assertThat(ZeroIsIllegal.count).isEqualTo(0);
}
@Test
public void failsWithOne() {
Result result = runTest(FailsWithOne.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(CustomException.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsWithOne.message));
- assertThat(FailsWithOne.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsWithOne.message);
+ assertThat(FailsWithOne.count).isEqualTo(1);
}
@Test
public void passesWithOne() {
Result result = runTest(PassesWithOne.class);
- assertTrue(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isTrue();
}
@Test
public void passesWithUnused() {
Result result = runTest(PassesWhenUnused.class);
- assertTrue(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isTrue();
}
@Test
public void failsOnSecondAttempt() {
Result result = runTest(FailsOnSecondAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(CustomException.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnSecondAttempt.message));
- assertThat(FailsOnSecondAttempt.count, is(2));
+ assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnSecondAttempt.message);
+ assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void passesOnSecondAttempt() {
Result result = runTest(PassesOnSecondAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnSecondAttempt.count, is(2));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void failsOnThirdAttempt() {
Result result = runTest(FailsOnThirdAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(CustomException.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnThirdAttempt.message));
- assertThat(FailsOnThirdAttempt.count, is(3));
+ assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnThirdAttempt.message);
+ assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
}
@Test
public void passesOnThirdAttempt() {
Result result = runTest(PassesOnThirdAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnThirdAttempt.count, is(3));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
}
public static class CustomException extends Exception {
@@ -129,6 +119,7 @@ public class RetryRuleGlobalWithExceptionJUnitTest {
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);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorJUnitTest.java
index 07a894c..9bec82b 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithErrorJUnitTest.java
@@ -1,13 +1,7 @@
package com.gemstone.gemfire.test.junit.rules.tests;
import static com.gemstone.gemfire.test.junit.rules.tests.RunTest.*;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.fail;
import java.util.List;
@@ -35,69 +29,66 @@ public class RetryRuleLocalWithErrorJUnitTest {
public void failsUnused() {
Result result = runTest(FailsUnused.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsUnused.message));
- assertThat(FailsUnused.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsUnused.message);
+ assertThat(FailsUnused.count).isEqualTo(1);
}
@Test
public void passesUnused() {
Result result = runTest(PassesUnused.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesUnused.count, is(1));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesUnused.count).isEqualTo(1);
}
@Test
public void failsOnSecondAttempt() {
Result result = runTest(FailsOnSecondAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnSecondAttempt.message));
- assertThat(FailsOnSecondAttempt.count, is(2));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnSecondAttempt.message);
+ assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void passesOnSecondAttempt() {
Result result = runTest(PassesOnSecondAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnSecondAttempt.count, is(2));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void failsOnThirdAttempt() {
Result result = runTest(FailsOnThirdAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(AssertionError.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnThirdAttempt.message));
- assertThat(FailsOnThirdAttempt.count, is(3));
+ assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class).hasMessage(FailsOnThirdAttempt.message);
+ assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
}
@Test
public void passesOnThirdAttempt() {
Result result = runTest(PassesOnThirdAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnThirdAttempt.count, is(3));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
}
public static class FailsUnused {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionJUnitTest.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionJUnitTest.java
index 46fd16c..16c9f8d 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionJUnitTest.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/rules/tests/RetryRuleLocalWithExceptionJUnitTest.java
@@ -1,13 +1,7 @@
package com.gemstone.gemfire.test.junit.rules.tests;
import static com.gemstone.gemfire.test.junit.rules.tests.RunTest.*;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.*;
import java.util.List;
@@ -34,69 +28,66 @@ public class RetryRuleLocalWithExceptionJUnitTest {
public void failsUnused() {
Result result = runTest(FailsUnused.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals("Failures: " + failures, 1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(CustomException.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsUnused.message));
- assertThat(FailsUnused.count, is(1));
+ assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsUnused.message);
+ assertThat(FailsUnused.count).isEqualTo(1);
}
@Test
public void passesUnused() {
Result result = runTest(PassesUnused.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesUnused.count, is(1));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesUnused.count).isEqualTo(1);
}
@Test
public void failsOnSecondAttempt() {
Result result = runTest(FailsOnSecondAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(CustomException.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnSecondAttempt.message));
- assertThat(FailsOnSecondAttempt.count, is(2));
+ assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnSecondAttempt.message);
+ assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void passesOnSecondAttempt() {
Result result = runTest(PassesOnSecondAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnSecondAttempt.count, is(2));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesOnSecondAttempt.count).isEqualTo(2);
}
@Test
public void failsOnThirdAttempt() {
Result result = runTest(FailsOnThirdAttempt.class);
- assertFalse(result.wasSuccessful());
+ assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
- assertEquals(1, failures.size());
+ assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
- assertThat(failure.getException(), is(instanceOf(CustomException.class)));
- assertThat(failure.getException().getMessage(), containsString(FailsOnThirdAttempt.message));
- assertThat(FailsOnThirdAttempt.count, is(3));
+ assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class).hasMessage(FailsOnThirdAttempt.message);
+ assertThat(FailsOnThirdAttempt.count).isEqualTo(3);
}
@Test
public void passesOnThirdAttempt() {
Result result = runTest(PassesOnThirdAttempt.class);
- assertTrue(result.wasSuccessful());
- assertThat(PassesOnThirdAttempt.count, is(3));
+ assertThat(result.wasSuccessful()).isTrue();
+ assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
}
public static class CustomException extends Exception {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7c27657a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/support/IgnoreConditionEvaluationException.java
----------------------------------------------------------------------
diff --git a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/support/IgnoreConditionEvaluationException.java b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/support/IgnoreConditionEvaluationException.java
index 50e1bc7..402cf63 100755
--- a/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/support/IgnoreConditionEvaluationException.java
+++ b/gemfire-junit/src/test/java/com/gemstone/gemfire/test/junit/support/IgnoreConditionEvaluationException.java
@@ -6,7 +6,7 @@ package com.gemstone.gemfire.test.junit.support;
* @author John Blum
* @see java.lang.RuntimeException
*/
-@SuppressWarnings("unused")
+@SuppressWarnings({ "serial", "unused" })
public class IgnoreConditionEvaluationException extends RuntimeException {
public IgnoreConditionEvaluationException() {