From 25ad7daa5814a151b629c580fb8b363c83d697b6 Mon Sep 17 00:00:00 2001 From: Steven Rowe Date: Wed, 1 Feb 2012 00:16:37 +0000 Subject: [PATCH] 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 --- .../apache/lucene/util/LuceneTestCase.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java index 7084194dc92..d21355960ed 100644 --- a/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/src/test-framework/java/org/apache/lucene/util/LuceneTestCase.java @@ -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 = ""; + 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();