aboutsummaryrefslogtreecommitdiff
path: root/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java')
-rw-r--r--android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java b/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
index 14210ac14..6e02627fe 100644
--- a/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
+++ b/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
@@ -17,6 +17,7 @@
package com.google.common.eventbus;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.EqualsTester;
import java.lang.reflect.InvocationTargetException;
@@ -70,23 +71,18 @@ public class SubscriberTest extends TestCase {
Method method = getTestSubscriberMethod("exceptionThrowingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
- try {
- subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
- fail("Subscribers whose methods throw must throw InvocationTargetException");
- } catch (InvocationTargetException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(IntentionalException.class);
- }
+ InvocationTargetException expected =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT));
+ assertThat(expected).hasCauseThat().isInstanceOf(IntentionalException.class);
}
public void testInvokeSubscriberMethod_errorPassthrough() throws Throwable {
Method method = getTestSubscriberMethod("errorThrowingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
- try {
- subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
- fail("Subscribers whose methods throw Errors must rethrow them");
- } catch (JudgmentError expected) {
- }
+ assertThrows(JudgmentError.class, () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT));
}
public void testEquals() throws Exception {