|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -13,6 +13,7 @@ |
|
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
|
* limitations under the License. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
package org.springframework.test.util; |
|
|
|
|
|
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
@ -26,13 +27,8 @@ import org.springframework.util.ObjectUtils; |
|
|
|
|
*/ |
|
|
|
|
public abstract class AssertionErrors { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private AssertionErrors() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Fails a test with the given message. |
|
|
|
|
* |
|
|
|
|
* @param message describes the reason for the failure |
|
|
|
|
*/ |
|
|
|
|
public static void fail(String message) { |
|
|
|
@ -42,7 +38,6 @@ public abstract class AssertionErrors { |
|
|
|
|
/** |
|
|
|
|
* Fails a test with the given message passing along expected and actual |
|
|
|
|
* values to be added to the message. |
|
|
|
|
* |
|
|
|
|
* <p>For example given: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* assertEquals("Response header [" + name + "]", actual, expected); |
|
|
|
@ -51,7 +46,6 @@ public abstract class AssertionErrors { |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* Response header [Accept] expected:<application/json> but was:<text/plain> |
|
|
|
|
* </pre> |
|
|
|
|
* |
|
|
|
|
* @param message describes the value that failed the match |
|
|
|
|
* @param expected expected value |
|
|
|
|
* @param actual actual value |
|
|
|
@ -63,7 +57,6 @@ public abstract class AssertionErrors { |
|
|
|
|
/** |
|
|
|
|
* Assert the given condition is {@code true} and raise an |
|
|
|
|
* {@link AssertionError} if it is not. |
|
|
|
|
* |
|
|
|
|
* @param message the message |
|
|
|
|
* @param condition the condition to test for |
|
|
|
|
*/ |
|
|
|
@ -79,14 +72,13 @@ public abstract class AssertionErrors { |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* assertEquals("Response header [" + name + "]", actual, expected); |
|
|
|
|
* </pre> |
|
|
|
|
* |
|
|
|
|
* @param message describes the value being checked |
|
|
|
|
* @param expected the expected value |
|
|
|
|
* @param actual the actual value |
|
|
|
|
*/ |
|
|
|
|
public static void assertEquals(String message, Object expected, Object actual) { |
|
|
|
|
if (!ObjectUtils.nullSafeEquals(expected, actual)) { |
|
|
|
|
fail(message, expected, actual); |
|
|
|
|
fail(message, ObjectUtils.nullSafeToString(expected), ObjectUtils.nullSafeToString(actual)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|