use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableTakeTimedTest method takeTimedErrorAfterTime.
@Test
public void takeTimedErrorAfterTime() {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> source = PublishSubject.create();
Observable<Integer> result = source.take(1, TimeUnit.SECONDS, scheduler);
Observer<Object> o = TestHelper.mockObserver();
result.subscribe(o);
source.onNext(1);
source.onNext(2);
source.onNext(3);
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
source.onNext(4);
source.onError(new TestException());
InOrder inOrder = inOrder(o);
inOrder.verify(o).onNext(1);
inOrder.verify(o).onNext(2);
inOrder.verify(o).onNext(3);
inOrder.verify(o).onComplete();
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(4);
verify(o, never()).onError(any(TestException.class));
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableTakeUntilTest method untilPublisherOtherError.
@Test
public void untilPublisherOtherError() {
PublishSubject<Integer> main = PublishSubject.create();
PublishSubject<Integer> other = PublishSubject.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasObservers());
other.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableTakeUntilTest method untilPublisherMainError.
@Test
public void untilPublisherMainError() {
PublishSubject<Integer> main = PublishSubject.create();
PublishSubject<Integer> other = PublishSubject.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasObservers());
main.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableReplayTest method noHeadRetentionErrorSize.
@Test
public void noHeadRetentionErrorSize() {
PublishSubject<Integer> source = PublishSubject.create();
ObservableReplay<Integer> co = (ObservableReplay<Integer>) source.replay(1);
co.connect();
BoundedReplayBuffer<Integer> buf = (BoundedReplayBuffer<Integer>) (co.current.get().buffer);
source.onNext(1);
source.onNext(2);
source.onError(new TestException());
assertNull(buf.get().value);
Object o = buf.get();
buf.trimHead();
assertSame(o, buf.get());
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableWindowWithTimeTest method overlappingOnError.
@Test
@SuppressUndeliverable
public void overlappingOnError() {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Integer> to = ps.window(2, 1, TimeUnit.SECONDS, scheduler).flatMap(Functions.<Observable<Integer>>identity()).test();
ps.onError(new TestException());
to.assertFailure(TestException.class);
}
Aggregations