use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleTakeUntilTest method untilSingleMainError.
@Test
public void untilSingleMainError() {
SingleSubject<Integer> main = SingleSubject.create();
SingleSubject<Integer> other = SingleSubject.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.SingleSubject in project RxJava by ReactiveX.
the class SingleTakeUntilTest method untilSingleOtherError.
@Test
public void untilSingleOtherError() {
SingleSubject<Integer> main = SingleSubject.create();
SingleSubject<Integer> other = SingleSubject.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.SingleSubject in project RxJava by ReactiveX.
the class SingleSwitchOnNextTest method delaySwitch.
@Test
public void delaySwitch() {
PublishProcessor<Single<Integer>> pp = PublishProcessor.create();
TestSubscriber<Integer> ts = Single.switchOnNextDelayError(pp).test();
assertTrue(pp.hasSubscribers());
ts.assertEmpty();
SingleSubject<Integer> ss1 = SingleSubject.create();
SingleSubject<Integer> ss2 = SingleSubject.create();
pp.onNext(ss1);
assertTrue(ss1.hasObservers());
pp.onNext(ss2);
assertFalse(ss1.hasObservers());
assertTrue(ss2.hasObservers());
assertTrue(ss2.hasObservers());
ss2.onError(new TestException());
assertTrue(pp.hasSubscribers());
ts.assertEmpty();
pp.onComplete();
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleDoOnLifecycleTest method onDisposeCrash.
@Test
public void onDisposeCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<? super Disposable> onSubscribe = mock(Consumer.class);
Action onDispose = mock(Action.class);
doThrow(new TestException("First")).when(onDispose).run();
SingleSubject<Integer> ss = SingleSubject.create();
TestObserver<Integer> to = ss.doOnLifecycle(onSubscribe, onDispose).test();
assertTrue(ss.hasObservers());
to.dispose();
assertFalse(ss.hasObservers());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
verify(onSubscribe).accept(any());
verify(onDispose).run();
});
}
use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleTakeUntilTest method untilPublisherOtherError.
@Test
public void untilPublisherOtherError() {
SingleSubject<Integer> main = SingleSubject.create();
PublishProcessor<Integer> other = PublishProcessor.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasSubscribers());
other.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasSubscribers());
to.assertFailure(TestException.class);
}
Aggregations