You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2018/07/28 04:49:45 UTC
[22/50] [abbrv] lucene-solr:jira/solr-11990: SOLR-12555: Add add'l
expectThrows() test helper
SOLR-12555: Add add'l expectThrows() test helper
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6ed9607f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6ed9607f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6ed9607f
Branch: refs/heads/jira/solr-11990
Commit: 6ed9607f74398d054e1cda7d1c02da80c2d93180
Parents: de16baa
Author: Jason Gerlowski <ja...@lucidworks.com>
Authored: Mon Jul 23 20:37:04 2018 -0400
Committer: Jason Gerlowski <ja...@lucidworks.com>
Committed: Mon Jul 23 20:37:04 2018 -0400
----------------------------------------------------------------------
.../src/java/org/apache/lucene/util/LuceneTestCase.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6ed9607f/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
index 6be8d03..baf72c1 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
@@ -2665,6 +2665,11 @@ public abstract class LuceneTestCase extends Assert {
/** Checks a specific exception class is thrown by the given runnable, and returns it. */
public static <T extends Throwable> T expectThrows(Class<T> expectedType, ThrowingRunnable runnable) {
+ return expectThrows(expectedType, "Expected exception "+ expectedType.getSimpleName() + " but no exception was thrown", runnable);
+ }
+
+ /** Checks a specific exception class is thrown by the given runnable, and returns it. */
+ public static <T extends Throwable> T expectThrows(Class<T> expectedType, String noExceptionMessage, ThrowingRunnable runnable) {
try {
runnable.run();
} catch (Throwable e) {
@@ -2675,7 +2680,7 @@ public abstract class LuceneTestCase extends Assert {
assertion.initCause(e);
throw assertion;
}
- throw new AssertionFailedError("Expected exception " + expectedType.getSimpleName() + " but no exception was thrown");
+ throw new AssertionFailedError(noExceptionMessage);
}
/**