Java Assert Equal assertEqual(Object obj1, Object obj2)

Here you can find the source of assertEqual(Object obj1, Object obj2)

Description

Method assertEqual.

License

Open Source License

Parameter

Parameter Description
obj1 Object
obj2 Object

Declaration

public final static void assertEqual(Object obj1, Object obj2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w ww  .  j av  a  2s  .  c o m*/
     * Method assertEqual.
     * 
     * @param obj1
     *            Object
     * @param obj2
     *            Object
     */
    public final static void assertEqual(Object obj1, Object obj2) {
        if (obj1 == null || obj2 == null) {
            throw new RuntimeException("assertion: " + obj1 + " must be equal to " + obj2);
        }
        if (obj1 != null && !obj1.equals(obj2)) {
            throw new RuntimeException("assertion: " + obj1 + " must be equal to " + obj2);
        }
        if (obj2 != null && !obj2.equals(obj1)) {
            throw new RuntimeException("assertion: " + obj1 + " must be equal to " + obj2);
        }
    }
}

Related

  1. assertArrayEquals(double[] p1, double[] p2, double eps)
  2. assertArrayLengthEqual(Object[] array, String name, Object[] array1, String name1)
  3. assertCharacterArraysEqual(char[] first, char[] second)
  4. assertDatesEqual(Calendar first, Calendar second)
  5. assertEqual(final double d1, final double d2, final double precisionRange)
  6. assertEquality(Object original, Object equal, Object... notEqual)
  7. assertEquals(double x, double y)
  8. assertEquals(double x, double y)
  9. assertEquals(final int expected, final int actual)