@Test public void responseThrowingInOnSuccessDeliveredToPlugin() {
server.enqueue(new MockResponse());
final AtomicReference<Throwable> throwableRef = new AtomicReference<>();
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override public void accept(Throwable throwable) throws Exception {
if (!throwableRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable);
}
}
});
RecordingMaybeObserver<Response<String>> observer = subscriberRule.create();
final RuntimeException e = new RuntimeException();
service.response().subscribe(new ForwardingObserver<Response<String>>(observer) {
@Override public void onSuccess(Response<String> value) {
throw e;
}
});
assertThat(throwableRef.get()).isSameAs(e);
}
MaybeThrowingTest.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:GitHub
作者:
评论列表
文章目录