Skip to content

Commit 4cc57dc

Browse files
committed
Test to show that Completable doesn't call error handler plugin
1 parent d43c05c commit 4cc57dc

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/test/java/rx/plugins/RxJavaPluginsTest.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323

2424
import org.junit.*;
2525

26+
import rx.Completable;
2627
import rx.Observable;
28+
import rx.Single;
2729
import rx.Subscriber;
2830
import rx.exceptions.OnErrorThrowable;
2931
import rx.functions.Func1;
@@ -286,4 +288,56 @@ public void testShortPluginDiscoveryMissing() {
286288

287289
RxJavaPlugins.getPluginImplementationViaProperty(Map.class, props);
288290
}
291+
292+
@Test
293+
public void testOnErrorWhenUsingCompletable() {
294+
RxJavaErrorHandlerTestImpl errorHandler = new RxJavaErrorHandlerTestImpl();
295+
RxJavaPlugins.getInstance().registerErrorHandler(errorHandler);
296+
297+
RuntimeException re = new RuntimeException("test onError");
298+
Completable.error(re).subscribe(new Subscriber<Object>() {
299+
@Override
300+
public void onCompleted() {
301+
302+
}
303+
304+
@Override
305+
public void onError(Throwable e) {
306+
307+
}
308+
309+
@Override
310+
public void onNext(Object o) {
311+
312+
}
313+
});
314+
assertEquals(re, errorHandler.e);
315+
assertEquals(1, errorHandler.count);
316+
}
317+
318+
@Test
319+
public void testOnErrorWhenUsingSingle() {
320+
RxJavaErrorHandlerTestImpl errorHandler = new RxJavaErrorHandlerTestImpl();
321+
RxJavaPlugins.getInstance().registerErrorHandler(errorHandler);
322+
323+
RuntimeException re = new RuntimeException("test onError");
324+
Single.error(re).subscribe(new Subscriber<Object>() {
325+
@Override
326+
public void onCompleted() {
327+
328+
}
329+
330+
@Override
331+
public void onError(Throwable e) {
332+
333+
}
334+
335+
@Override
336+
public void onNext(Object o) {
337+
338+
}
339+
});
340+
assertEquals(re, errorHandler.e);
341+
assertEquals(1, errorHandler.count);
342+
}
289343
}

0 commit comments

Comments
 (0)