|
23 | 23 |
|
24 | 24 | import org.junit.*;
|
25 | 25 |
|
| 26 | +import rx.Completable; |
26 | 27 | import rx.Observable;
|
| 28 | +import rx.Single; |
27 | 29 | import rx.Subscriber;
|
28 | 30 | import rx.exceptions.OnErrorThrowable;
|
29 | 31 | import rx.functions.Func1;
|
@@ -286,4 +288,56 @@ public void testShortPluginDiscoveryMissing() {
|
286 | 288 |
|
287 | 289 | RxJavaPlugins.getPluginImplementationViaProperty(Map.class, props);
|
288 | 290 | }
|
| 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 | + } |
289 | 343 | }
|
0 commit comments