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;
}
}
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();
}
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;
}
}
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;
}
}
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");
}
Aggregations