use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class CompletableTakeUntilTest method otherErrorLate.
@Test
public void otherErrorLate() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final AtomicReference<CompletableObserver> ref = new AtomicReference<>();
Completable.complete().takeUntil(new Completable() {
@Override
protected void subscribeActual(CompletableObserver observer) {
observer.onSubscribe(Disposable.empty());
ref.set(observer);
}
}).test().assertResult();
ref.get().onError(new TestException());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class CompletableDetachTest method errorDetaches.
@Test
public void errorDetaches() throws Exception {
Disposable d = Disposable.empty();
final WeakReference<Disposable> wr = new WeakReference<>(d);
TestObserver<Void> to = new Completable() {
@Override
protected void subscribeActual(CompletableObserver observer) {
observer.onSubscribe(wr.get());
observer.onError(new TestException());
observer.onError(new IOException());
}
}.onTerminateDetach().test();
d = null;
System.gc();
Thread.sleep(200);
to.assertFailure(TestException.class);
assertNull(wr.get());
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class CompletableDoOnLifecycleTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<? super Disposable> onSubscribe = mock(Consumer.class);
Action onDispose = mock(Action.class);
doThrow(new TestException("First")).when(onSubscribe).accept(any());
Disposable bs = Disposable.empty();
new Completable() {
@Override
protected void subscribeActual(CompletableObserver observer) {
observer.onSubscribe(bs);
observer.onError(new TestException("Second"));
observer.onComplete();
}
}.doOnLifecycle(onSubscribe, onDispose).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(bs.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
verify(onSubscribe).accept(any());
verify(onDispose, never()).run();
});
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableAllTest method predicateThrows.
@Test
public void predicateThrows() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onNext(1);
observer.onNext(2);
observer.onError(new TestException());
observer.onComplete();
}
}.all(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableAllTest method predicateThrowsObservable.
@Test
public void predicateThrowsObservable() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onNext(1);
observer.onNext(2);
observer.onError(new TestException());
observer.onComplete();
}
}.all(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).toObservable().test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
Aggregations