use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class SingleTakeUntilTest method mainErrorCompletable.
@Test
public void mainErrorCompletable() {
PublishProcessor<Integer> pp = PublishProcessor.create();
PublishProcessor<Integer> source = PublishProcessor.create();
TestObserver<Integer> to = source.single(-99).takeUntil(pp.ignoreElements()).test();
source.onError(new TestException());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class SingleTakeUntilTest method otherErrorCompletable.
@Test
public void otherErrorCompletable() {
PublishProcessor<Integer> pp = PublishProcessor.create();
PublishProcessor<Integer> source = PublishProcessor.create();
TestObserver<Integer> to = source.single(-99).takeUntil(pp.ignoreElements()).test();
pp.onError(new TestException());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.processors.PublishProcessor 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.processors.PublishProcessor in project RxJava by ReactiveX.
the class SingleZipArrayTest method innerErrorRace.
@Test
public void innerErrorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp0 = PublishProcessor.create();
final PublishProcessor<Integer> pp1 = PublishProcessor.create();
final TestObserver<Object> to = Single.zip(pp0.single(0), pp1.single(0), addString).test();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
pp0.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
pp1.onError(ex);
}
};
TestHelper.race(r1, r2);
to.assertFailure(TestException.class);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.processors.PublishProcessor 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