Refine hamcrest dependency in spring-test-mvc project

1) removed the hamcrest-all dependency requirement and replaced it with
the more focused hamcrest-library dependency

2) added MatcherAssertionErrors as a replacement of
org.hamcrest.MatcherAssert, which in hamcrest 1.1 is only available
through the hamcrest-all dependency (and not in hamcrest-core nor in
the hamcrest embedded in JUnit 4.4 through 4.8)

3) changed the required hamcrest version from 1.1 to 1.3 and made sure
the spring-test-mvc project does not rely on newer hamcrest
functionality without checking if it is available first

Applications that already depend on older versions of hamcrest
(in particular 1.1) via hamcrest-library, hamcrest-all or as part of
junit 4.4 through 4.8 should not be disrupted if they add spring-test
but may wish to exclude the hamcrest-library transitive dependency
from spring-test in order to avoid extra jars in the classpath

Applications that depend on hamcrest 1.3 should not have to do anything

Issue: SPR-9940
This commit is contained in:
Rossen Stoyanchev
2012-11-01 13:49:00 -04:00
parent 468f9c7814
commit 242bf7c4e3
22 changed files with 157 additions and 79 deletions

View File

@@ -37,20 +37,22 @@ public abstract class AssertionErrors {
}
/**
* Fails a test with the given message passing along expected and actual values to be added to the message.
* Fails a test with the given message passing along expected and actual
* values to be added to the message.
*
* @param message the message
* @param expected the expected value
* @param actual the actual value
* @param actual the actual value
*/
public static void fail(String message, Object expected, Object actual) {
throw new AssertionError(message + " expected:<" + expected + "> but was:<" + actual + ">");
}
/**
* Asserts that a condition is {@code true}. If not, throws an {@link AssertionError} with the given message.
* Asserts that a condition is {@code true}. If not, throws an
* {@link AssertionError} with the given message.
*
* @param message the message
* @param message the message
* @param condition the condition to test for
*/
public static void assertTrue(String message, boolean condition) {
@@ -60,11 +62,12 @@ public abstract class AssertionErrors {
}
/**
* Asserts that two objects are equal. If not, an {@link AssertionError} is thrown with the given message.
* Asserts that two objects are equal. If not, an {@link AssertionError} is
* thrown with the given message.
*
* @param message the message
* @param message the message
* @param expected the expected value
* @param actual the actual value
* @param actual the actual value
*/
public static void assertEquals(String message, Object expected, Object actual) {
if (expected == null && actual == null) {