LUCENE-3743: LuceneTestCase's uncaught exceptions handler should check for AssumptionViolatedExceptions and then not trigger test failure

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1238874 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Steven Rowe 2012-02-01 00:16:37 +00:00
parent 8e40ea5bf8
commit 25ad7daa58

View File

@ -542,11 +542,33 @@ public abstract class LuceneTestCase extends Assert {
savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
testsFailed = true;
uncaughtExceptions.add(new UncaughtExceptionEntry(t, e));
if (savedUncaughtExceptionHandler != null)
savedUncaughtExceptionHandler.uncaughtException(t, e);
// org.junit.internal.AssumptionViolatedException in older releases
// org.junit.Assume.AssumptionViolatedException in recent ones
if (e.getClass().getName().endsWith("AssumptionViolatedException")) {
String where = "<unknown>";
for (StackTraceElement elem : e.getStackTrace()) {
if ( ! elem.getClassName().startsWith("org.junit")) {
where = elem.toString();
break;
}
}
if (e.getCause() instanceof _TestIgnoredException)
e = e.getCause();
System.err.print("NOTE: Assume failed at " + where + " (ignored):");
if (VERBOSE) {
System.err.println();
e.printStackTrace(System.err);
} else {
System.err.print(" ");
System.err.println(e.getMessage());
}
} else {
testsFailed = true;
uncaughtExceptions.add(new UncaughtExceptionEntry(t, e));
if (savedUncaughtExceptionHandler != null)
savedUncaughtExceptionHandler.uncaughtException(t, e);
}
}
});
savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount();