use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class MaybeTakeUntilTest method onErrorRace.
@Test
public void onErrorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final PublishProcessor<Integer> pp1 = PublishProcessor.create();
final PublishProcessor<Integer> pp2 = PublishProcessor.create();
TestObserver<Integer> to = pp1.singleElement().takeUntil(pp2.singleElement()).test();
final TestException ex1 = new TestException();
final TestException ex2 = new TestException();
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Runnable r1 = new Runnable() {
@Override
public void run() {
pp1.onError(ex1);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
pp2.onError(ex2);
}
};
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 MaybeTakeUntilTest method untilPublisherMainError.
@Test
public void untilPublisherMainError() {
MaybeSubject<Integer> main = MaybeSubject.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());
main.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasSubscribers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class MaybeTimeoutPublisherTest method fallbackError.
@Test
public void fallbackError() {
PublishProcessor<Integer> pp1 = PublishProcessor.create();
PublishProcessor<Integer> pp2 = PublishProcessor.create();
TestObserver<Integer> to = pp1.singleElement().timeout(pp2, Maybe.<Integer>error(new TestException())).test();
assertTrue(pp1.hasSubscribers());
assertTrue(pp2.hasSubscribers());
pp2.onNext(1);
pp2.onComplete();
assertFalse(pp1.hasSubscribers());
assertFalse(pp2.hasSubscribers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class MaybeTimeoutPublisherTest method mainError.
@Test
public void mainError() {
PublishProcessor<Integer> pp1 = PublishProcessor.create();
PublishProcessor<Integer> pp2 = PublishProcessor.create();
TestObserver<Integer> to = pp1.singleElement().timeout(pp2).test();
assertTrue(pp1.hasSubscribers());
assertTrue(pp2.hasSubscribers());
pp1.onError(new TestException());
assertFalse(pp1.hasSubscribers());
assertFalse(pp2.hasSubscribers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class MaybeTimeoutPublisherTest method onErrorRace.
@Test
public void onErrorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp1 = PublishProcessor.create();
final PublishProcessor<Integer> pp2 = PublishProcessor.create();
TestObserver<Integer> to = pp1.singleElement().timeout(pp2).test();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
pp1.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
pp2.onError(ex);
}
};
TestHelper.race(r1, r2);
to.assertFailure(TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
}
Aggregations