Example usage for java.lang AssertionError toString

List of usage examples for java.lang AssertionError toString

Introduction

In this page you can find the example usage for java.lang AssertionError toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.apache.hadoop.test.TestGenericTestUtils.java

@Test
public void testAssertExceptionContainsNullEx() throws Throwable {
    try {//from www.j  a  va2 s . c om
        assertExceptionContains("", null);
    } catch (AssertionError e) {
        if (!e.toString().contains(E_NULL_THROWABLE)) {
            throw e;
        }
    }
}

From source file:org.apache.hadoop.test.TestGenericTestUtils.java

@Test
public void testAssertExceptionContainsNullString() throws Throwable {
    try {// w  ww .  j av  a2s  . com
        assertExceptionContains("", new BrokenException());
    } catch (AssertionError e) {
        if (!e.toString().contains(E_NULL_THROWABLE_STRING)) {
            throw e;
        }
    }
}

From source file:org.apache.hadoop.test.TestGenericTestUtils.java

@Test
public void testAssertExceptionContainsWrongText() throws Throwable {
    try {/*from w w w  . j a v  a  2  s . co m*/
        assertExceptionContains("Expected", new Exception("(actual)"));
    } catch (AssertionError e) {
        String s = e.toString();
        if (!s.contains(E_UNEXPECTED_EXCEPTION) || !s.contains("(actual)")) {
            throw e;
        }
        if (e.getCause() == null) {
            throw new AssertionError("No nested cause in assertion", e);
        }
    }
}