use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class HalfSerializerObserverTest method reentrantOnNextOnComplete.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantOnNextOnComplete() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Observer[] a = { null };
final TestObserver to = new TestObserver();
Observer observer = new Observer() {
@Override
public void onSubscribe(Disposable d) {
to.onSubscribe(d);
}
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onComplete(a[0], wip, error);
}
to.onNext(t);
}
@Override
public void onError(Throwable t) {
to.onError(t);
}
@Override
public void onComplete() {
to.onComplete();
}
};
a[0] = observer;
observer.onSubscribe(Disposable.empty());
HalfSerializer.onNext(observer, 1, wip, error);
to.assertResult(1);
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class HalfSerializerObserverTest method reentrantErrorOnError.
@Test
@SuppressUndeliverable
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantErrorOnError() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Observer[] a = { null };
final TestObserver to = new TestObserver();
Observer observer = new Observer() {
@Override
public void onSubscribe(Disposable d) {
to.onSubscribe(d);
}
@Override
public void onNext(Object t) {
to.onNext(t);
}
@Override
public void onError(Throwable t) {
to.onError(t);
HalfSerializer.onError(a[0], new IOException(), wip, error);
}
@Override
public void onComplete() {
to.onComplete();
}
};
a[0] = observer;
observer.onSubscribe(Disposable.empty());
HalfSerializer.onError(observer, new TestException(), wip, error);
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableWindowWithStartEndObservableTest method openError.
@Test
public void openError() throws Throwable {
TestHelper.withErrorTracking(errors -> {
TestException ex1 = new TestException();
TestException ex2 = new TestException();
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
AtomicReference<Observer<? super Integer>> ref1 = new AtomicReference<>();
AtomicReference<Observer<? super Integer>> ref2 = new AtomicReference<>();
Observable<Integer> o1 = Observable.<Integer>unsafeCreate(ref1::set);
Observable<Integer> o2 = Observable.<Integer>unsafeCreate(ref2::set);
TestObserver<Observable<Integer>> to = BehaviorSubject.createDefault(1).window(o1, v -> o2).doOnNext(w -> w.test()).test();
ref1.get().onSubscribe(Disposable.empty());
ref1.get().onNext(1);
ref2.get().onSubscribe(Disposable.empty());
TestHelper.race(() -> ref1.get().onError(ex1), () -> ref2.get().onError(ex2));
to.assertError(RuntimeException.class);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
errors.clear();
}
});
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableZipIterableTest method zipIterableNextThrows.
@Test
public void zipIterableNextThrows() {
PublishSubject<String> r1 = PublishSubject.create();
/* define an Observer to receive aggregated events */
Observer<String> o = TestHelper.mockObserver();
InOrder io = inOrder(o);
Iterable<String> r2 = new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
@Override
public boolean hasNext() {
return true;
}
@Override
public String next() {
throw new TestException();
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
};
r1.zipWith(r2, zipr2).subscribe(o);
r1.onError(new TestException());
io.verify(o).onError(any(TestException.class));
verify(o, never()).onNext(any(String.class));
verify(o, never()).onComplete();
}
use of io.reactivex.rxjava3.core.Observer in project RxJava by ReactiveX.
the class ObservableThrottleFirstTest method before.
@Before
public void before() {
scheduler = new TestScheduler();
innerScheduler = scheduler.createWorker();
observer = TestHelper.mockObserver();
}
Aggregations