org.springframework.test.util

Class AssertionErrors

  • java.lang.Object
    • org.springframework.test.util.AssertionErrors


  • public abstract class AssertionErrors
    extends java.lang.Object
    JUnit independent assertion class.
    Since:
    3.2
    Author:
    Lukas Krecan, Arjen Poutsma
    • Constructor Summary

      Constructors 
      Constructor and Description
      AssertionErrors() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void assertEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
      Assert two objects are equal and raise an AssertionError if not.
      static void assertNotEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
      Assert two objects are not equal and raise an AssertionError otherwise.
      static void assertTrue(java.lang.String message, boolean condition)
      Assert the given condition is true and raise an AssertionError if it is not.
      static void fail(java.lang.String message)
      Fails a test with the given message.
      static void fail(java.lang.String message, java.lang.Object expected, java.lang.Object actual)
      Fails a test with the given message passing along expected and actual values to be added to the message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AssertionErrors

        public AssertionErrors()
    • Method Detail

      • fail

        public static void fail(java.lang.String message)
        Fails a test with the given message.
        Parameters:
        message - describes the reason for the failure
      • fail

        public static void fail(java.lang.String message,
                                @Nullable
                                java.lang.Object expected,
                                @Nullable
                                java.lang.Object actual)
        Fails a test with the given message passing along expected and actual values to be added to the message.

        For example given:

         assertEquals("Response header [" + name + "]", actual, expected);
         

        The resulting message is:

         Response header [Accept] expected:<application/json> but was:<text/plain>
         
        Parameters:
        message - describes the value that failed the match
        expected - expected value
        actual - actual value
      • assertTrue

        public static void assertTrue(java.lang.String message,
                                      boolean condition)
        Assert the given condition is true and raise an AssertionError if it is not.
        Parameters:
        message - the message
        condition - the condition to test for
      • assertEquals

        public static void assertEquals(java.lang.String message,
                                        @Nullable
                                        java.lang.Object expected,
                                        @Nullable
                                        java.lang.Object actual)
        Assert two objects are equal and raise an AssertionError if not.

        For example:

         assertEquals("Response header [" + name + "]", expected, actual);
         
        Parameters:
        message - describes the value being checked
        expected - the expected value
        actual - the actual value
      • assertNotEquals

        public static void assertNotEquals(java.lang.String message,
                                           @Nullable
                                           java.lang.Object expected,
                                           @Nullable
                                           java.lang.Object actual)
        Assert two objects are not equal and raise an AssertionError otherwise.

        For example:

         assertNotEquals("Response header [" + name + "]", expected, actual);
         
        Parameters:
        message - describes the value being checked
        expected - the expected value
        actual - the actual value