@Test public void errorConsumerEmpty() throws Exception { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { Functions.ERROR_CONSUMER.accept(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); assertEquals(errors.toString(), 1, errors.size()); } finally { RxJavaCommonPlugins.reset(); } } }
@SuppressWarnings("unchecked") @Test public void onError() { Iterator<Object> it = Flowable.never().blockingLatest().iterator(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { ((Subscriber<Object>)it).onError(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } } }
@SuppressWarnings("unchecked") @Test public void onError() { Iterator<Object> it = Observable.never().blockingLatest().iterator(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { ((Observer<Object>)it).onError(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } } }
@Test public void onSubscribeCrashes() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(true, 1, false, false, false); SafeObserver<Object> so = cd.toSafe(); so.onSubscribe(cd); TestCommonHelper.assertUndeliverable(list, 0, TestException.class, "onSubscribe()"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void onSubscribeCrashes() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(true, 1, false, false, false, false); SafeSubscriber<Object> so = cd.toSafe(); so.onSubscribe(cd); TestCommonHelper.assertUndeliverable(list, 0, TestException.class, "onSubscribe()"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void nextObserverError() { NextSubscriber<Integer> no = new NextSubscriber<Integer>(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { no.onError(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void nextObserverError() { NextObserver<Integer> no = new NextObserver<Integer>(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { no.onError(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void noErrorLoss() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { ConnectableFlowable<Object> co = Flowable.error(new TestException()).publish(); co.connect(); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void onErrorAfterComplete() { BehaviorProcessor<Object> p = BehaviorProcessor.create(); p.onComplete(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { p.onError(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void onErrorAfterComplete() { BehaviorSubject<Object> p = BehaviorSubject.create(); p.onComplete(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { p.onError(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void noErrorLoss() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { ConnectableObservable<Object> co = Observable.error(new TestException()).publish(); co.connect(); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void cancelCrash() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(false, 1, false, false, true, false); SafeSubscriber<Object> so = cd.toSafe(); so.onSubscribe(cd); so.cancel(); TestCommonHelper.assertUndeliverable(list, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void onCompleteteCrash() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(false, 1, false, true, false, false); SafeSubscriber<Object> so = cd.toSafe(); so.onSubscribe(cd); so.onComplete(); TestCommonHelper.assertUndeliverable(list, 0, TestException.class, "onComplete()"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void noneagerMapperThrowsDisposerThrows() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { Single.using(Functions.justCallable(Disposables.empty()), mapperThrows, disposerThrows, false) .test() .assertFailureAndMessage(TestException.class, "Mapper"); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class, "Disposer"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void disposerThrowsNonEager() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { Single.using(Functions.justCallable(Disposables.empty()), mapper, disposerThrows, false) .test() .assertResult(1); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class, "Disposer"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void filterInvalidSource() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { new ParallelInvalid() .filter(Functions.alwaysTrue(), ParallelFailureHandling.ERROR) .sequential() .test(); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void mapInvalidSource() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { new ParallelInvalid() .map(Functions.identity(), ParallelFailureHandling.ERROR) .sequential() .test(); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void errorAfterCancel() { FullArbiter<Integer> fa = new FullArbiter<Integer>(new TestSubscriber<Integer>(), null, 128); BooleanSubscription bs = new BooleanSubscription(); fa.cancel(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { fa.onError(new TestException(), bs); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void errorAfterCancel() { ObserverFullArbiter<Integer> fa = new ObserverFullArbiter<Integer>(new TestObserver<Integer>(), null, 128); Disposable bs = Disposables.empty(); fa.dispose(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { fa.onError(new TestException(), bs); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void cancelAfterError() { FullArbiter<Integer> fa = new FullArbiter<Integer>(new TestSubscriber<Integer>(), null, 128); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { fa.queue.offer(fa.s, NotificationLite.error(new TestException())); fa.cancel(); fa.drain(); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); } finally { RxJavaCommonPlugins.reset(); } }