Example usage for junit.framework ComparisonFailure ComparisonFailure

List of usage examples for junit.framework ComparisonFailure ComparisonFailure

Introduction

In this page you can find the example usage for junit.framework ComparisonFailure ComparisonFailure.

Prototype

public ComparisonFailure(String message, String expected, String actual) 

Source Link

Document

Constructs a comparison failure.

Usage

From source file:com.redhat.rhn.testing.RhnBaseTestCase.java

/**
 * Assert that the date <code>later</code> is after the date
 * <code>earlier</code>. The assertion succeeds if the dates
 * are equal. Both dates must be non-null.
 *
 * @param msg the message to print if the assertion fails
 * @param earlier the earlier date to compare
 * @param later the later date to compare
 *//*from  ww  w  . ja v a2 s.c  om*/
public static void assertNotBefore(String msg, Date earlier, Date later) {
    assertNotNull(msg, earlier);
    assertNotNull(msg, later);
    if (earlier.after(later) && !earlier.equals(later)) {
        String e = DateFormat.getDateTimeInstance().format(earlier);
        String l = DateFormat.getDateTimeInstance().format(later);
        throw new ComparisonFailure(msg, e, l);
    }
}

From source file:com.eviware.soapui.support.Tools.java

/**
 * Compares two string for similarity, allows wildcard.
 *
 * @param expected//w w w . j  a v  a 2  s  .  c  o  m
 * @param real
 * @param wildcard
 * @throws ComparisonFailure
 */
public static void assertSimilar(String expected, String real, char wildcard) throws ComparisonFailure {
    if (!isSimilar(expected, real, wildcard)) {
        throw new ComparisonFailure("Not matched", expected, real);
    }
}

From source file:org.olap4j.test.TestContext.java

/**
 * Checks that an actual string matches an expected string. If they do not,
 * throws a {@link junit.framework.ComparisonFailure} and prints the
 * difference, including the actual string as an easily pasted Java string
 * literal./*from   www . j ava  2s  . c  o m*/
 *
 * @param safeExpected Expected string, where all line endings have been
 * converted into platform-specific line endings
 * @param actual Actual string returned by test case
 * @param java Whether to print the actual value as a Java string literal
 * if the strings differ
 * @param message Message to print if the strings differ
 */
public static void assertEqualsVerbose(SafeString safeExpected, String actual, boolean java, String message) {
    String expected = safeExpected == null ? null : safeExpected.s;
    if ((expected == null) && (actual == null)) {
        return;
    }
    if ((expected != null) && expected.equals(actual)) {
        return;
    }
    if (message == null) {
        message = "";
    } else {
        message += NL;
    }
    message += "Expected:" + NL + expected + NL + "Actual:" + NL + actual + NL;
    if (java) {
        message += "Actual java:" + NL + toJavaString(actual) + NL;
    }
    throw new ComparisonFailure(message, expected, actual);
}