Search in sources :

Example 26 with AssertionFailedError

use of junit.framework.AssertionFailedError in project caffeine by ben-manes.

the class JSR166TestCase method threadUnexpectedException.

/**
     * Records the given exception using {@link #threadRecordFailure},
     * then rethrows the exception, wrapping it in an
     * AssertionFailedError if necessary.
     */
public void threadUnexpectedException(Throwable t) {
    threadRecordFailure(t);
    t.printStackTrace();
    if (t instanceof RuntimeException) {
        throw (RuntimeException) t;
    } else if (t instanceof Error) {
        throw (Error) t;
    } else {
        AssertionFailedError afe = new AssertionFailedError("unexpected exception: " + t);
        afe.initCause(t);
        throw afe;
    }
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) AssertionFailedError(junit.framework.AssertionFailedError)

Example 27 with AssertionFailedError

use of junit.framework.AssertionFailedError in project caffeine by ben-manes.

the class JSR166TestCase method tearDown.

/**
     * Extra checks that get done for all test cases.
     *
     * Triggers test case failure if any thread assertions have failed,
     * by rethrowing, in the test harness thread, any exception recorded
     * earlier by threadRecordFailure.
     *
     * Triggers test case failure if interrupt status is set in the main thread.
     */
@Override
public void tearDown() throws Exception {
    Throwable t = threadFailure.getAndSet(null);
    if (t != null) {
        if (t instanceof Error) {
            throw (Error) t;
        } else if (t instanceof RuntimeException) {
            throw (RuntimeException) t;
        } else if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            AssertionFailedError afe = new AssertionFailedError(t.toString());
            afe.initCause(t);
            throw afe;
        }
    }
    if (Thread.interrupted()) {
        throw new AssertionFailedError("interrupt status set in main thread");
    }
    checkForkJoinPoolThreadLeaks();
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) AssertionFailedError(junit.framework.AssertionFailedError) TimeoutException(java.util.concurrent.TimeoutException) NoSuchElementException(java.util.NoSuchElementException)

Example 28 with AssertionFailedError

use of junit.framework.AssertionFailedError in project j2objc by google.

the class JSR166TestCase method threadUnexpectedException.

/**
     * Records the given exception using {@link #threadRecordFailure},
     * then rethrows the exception, wrapping it in an
     * AssertionFailedError if necessary.
     */
public void threadUnexpectedException(Throwable t) {
    threadRecordFailure(t);
    t.printStackTrace();
    if (t instanceof RuntimeException)
        throw (RuntimeException) t;
    else if (t instanceof Error)
        throw (Error) t;
    else {
        AssertionFailedError afe = new AssertionFailedError("unexpected exception: " + t);
        afe.initCause(t);
        throw afe;
    }
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) AssertionFailedError(junit.framework.AssertionFailedError)

Example 29 with AssertionFailedError

use of junit.framework.AssertionFailedError in project j2objc by google.

the class SerializationTester method test.

public void test() {
    try {
        if (golden == null || golden.length() == 0) {
            fail("No golden value supplied! Consider using this: " + hexEncode(serialize(value)));
        }
        // deserialize should return the proper type
        @SuppressWarnings("unchecked") T deserialized = (T) deserialize(hexDecode(golden));
        assertTrue("User-constructed value doesn't equal deserialized golden value", equals(value, deserialized));
        // deserialize should return the proper type
        @SuppressWarnings("unchecked") T reserialized = (T) deserialize(serialize(value));
        assertTrue("User-constructed value doesn't equal itself, reserialized", equals(value, reserialized));
        // just a sanity check! if this fails, verify() is probably broken
        verify(value);
        verify(deserialized);
        verify(reserialized);
    } catch (Exception e) {
        Error failure = new AssertionFailedError();
        failure.initCause(e);
        throw failure;
    }
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) AssertionFailedError(junit.framework.AssertionFailedError) IOException(java.io.IOException)

Example 30 with AssertionFailedError

use of junit.framework.AssertionFailedError in project guava by google.

the class JSR166TestCase method tearDown.

/**
     * Extra checks that get done for all test cases.
     *
     * Triggers test case failure if any thread assertions have failed,
     * by rethrowing, in the test harness thread, any exception recorded
     * earlier by threadRecordFailure.
     *
     * Triggers test case failure if interrupt status is set in the main thread.
     */
public void tearDown() throws Exception {
    Throwable t = threadFailure.getAndSet(null);
    if (t != null) {
        if (t instanceof Error)
            throw (Error) t;
        else if (t instanceof RuntimeException)
            throw (RuntimeException) t;
        else if (t instanceof Exception)
            throw (Exception) t;
        else {
            AssertionFailedError afe = new AssertionFailedError(t.toString());
            afe.initCause(t);
            throw afe;
        }
    }
    if (Thread.interrupted())
        throw new AssertionFailedError("interrupt status set in main thread");
}
Also used : AssertionFailedError(junit.framework.AssertionFailedError) AssertionFailedError(junit.framework.AssertionFailedError) TimeoutException(java.util.concurrent.TimeoutException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)787 TestFailureException (org.apache.openejb.test.TestFailureException)503 JMSException (javax.jms.JMSException)336 EJBException (javax.ejb.EJBException)334 RemoteException (java.rmi.RemoteException)268 InitialContext (javax.naming.InitialContext)168 RemoveException (javax.ejb.RemoveException)80 CreateException (javax.ejb.CreateException)77 NamingException (javax.naming.NamingException)65 BasicStatefulObject (org.apache.openejb.test.stateful.BasicStatefulObject)42 Test (org.junit.Test)42 BasicBmpObject (org.apache.openejb.test.entity.bmp.BasicBmpObject)41 BasicStatelessObject (org.apache.openejb.test.stateless.BasicStatelessObject)38 CountDownLatch (java.util.concurrent.CountDownLatch)28 EntityManager (javax.persistence.EntityManager)21 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)21 EntityManagerFactory (javax.persistence.EntityManagerFactory)17 IOException (java.io.IOException)16 DataSource (javax.sql.DataSource)16 ConnectionFactory (javax.jms.ConnectionFactory)15