diff --git a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java index bc85f80df55d..cf1bbf510df4 100644 --- a/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/UsefulTestCase.java @@ -869,6 +869,7 @@ public abstract class UsefulTestCase extends TestCase { * @param expectedErrorMsg expected error message */ protected void assertException(AbstractExceptionCase exceptionCase, @Nullable String expectedErrorMsg) throws Throwable { + //noinspection unchecked assertExceptionOccurred(true, exceptionCase, expectedErrorMsg); } @@ -878,8 +879,8 @@ public abstract class UsefulTestCase extends TestCase { * @param exceptionClass Expected exception type * @param runnable Block annotated with some exception type */ - protected void assertThrows(@NotNull Class exceptionClass, - @NotNull ThrowableRunnable runnable) throws Throwable { + protected void assertThrows(@NotNull Class exceptionClass, + @NotNull ThrowableRunnable runnable) throws T { assertThrows(exceptionClass, null, runnable); } @@ -891,12 +892,13 @@ public abstract class UsefulTestCase extends TestCase { * @param expectedErrorMsg expected error message, of any * @param runnable Block annotated with some exception type */ - protected void assertThrows(@NotNull Class exceptionClass, @Nullable String expectedErrorMsg, - @NotNull ThrowableRunnable runnable) throws Throwable { - assertException(new AbstractExceptionCase() { + @SuppressWarnings({"unchecked", "SameParameterValue"}) + protected void assertThrows(@NotNull Class exceptionClass, @Nullable String expectedErrorMsg, + @NotNull ThrowableRunnable runnable) throws T { + assertExceptionOccurred(true, new AbstractExceptionCase() { @Override - public Class getExpectedExceptionClass() { - return exceptionClass; + public Class getExpectedExceptionClass() { + return (Class)exceptionClass; } @Override @@ -911,7 +913,7 @@ public abstract class UsefulTestCase extends TestCase { * * @param exceptionCase Block annotated with some exception type */ - protected void assertNoException(final AbstractExceptionCase exceptionCase) throws Throwable { + protected void assertNoException(final AbstractExceptionCase exceptionCase) throws T { assertExceptionOccurred(false, exceptionCase, null); } @@ -926,9 +928,9 @@ public abstract class UsefulTestCase extends TestCase { assertNull(throwableName); } - private static void assertExceptionOccurred(boolean shouldOccur, - AbstractExceptionCase exceptionCase, - String expectedErrorMsg) throws Throwable { + private static void assertExceptionOccurred(boolean shouldOccur, + AbstractExceptionCase exceptionCase, + String expectedErrorMsg) throws T { boolean wasThrown = false; try { exceptionCase.tryClosure();