use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.
the class FlowableSwitchMapCompletableTest method onErrorInnerErrorRace.
@Test
public void onErrorInnerErrorRace() {
final TestException ex0 = new TestException();
final TestException ex = new TestException();
for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp = PublishProcessor.create();
final CompletableSubject cs = CompletableSubject.create();
TestObserver<Void> to = pp.switchMapCompletable(Functions.justFunction(cs)).test();
pp.onNext(1);
Runnable r1 = new Runnable() {
@Override
public void run() {
pp.onError(ex0);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
cs.onError(ex);
}
};
TestHelper.race(r1, r2);
to.assertError(new Predicate<Throwable>() {
@Override
public boolean test(Throwable e) throws Exception {
return e instanceof TestException || e instanceof CompositeException;
}
});
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.
the class FlowableSwitchMapCompletableTest method onNextInnerErrorRace.
@Test
public void onNextInnerErrorRace() {
final TestException ex = new TestException();
for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp = PublishProcessor.create();
final CompletableSubject cs = CompletableSubject.create();
TestObserver<Void> to = pp.switchMapCompletable(Functions.justFunction(cs)).test();
pp.onNext(1);
Runnable r1 = new Runnable() {
@Override
public void run() {
pp.onNext(2);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
cs.onError(ex);
}
};
TestHelper.race(r1, r2);
to.assertError(new Predicate<Throwable>() {
@Override
public boolean test(Throwable e) throws Exception {
return e instanceof TestException || e instanceof CompositeException;
}
});
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.
the class FlowableSwitchMapCompletableTest method mainErrorDelayed.
@Test
public void mainErrorDelayed() {
final PublishProcessor<Integer> pp = PublishProcessor.create();
final CompletableSubject cs = CompletableSubject.create();
TestObserver<Void> to = pp.switchMapCompletableDelayError(Functions.justFunction(cs)).test();
pp.onNext(1);
pp.onError(new TestException());
to.assertEmpty();
assertTrue(cs.hasObservers());
cs.onComplete();
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.
the class CompletableAndThenObservableTest method errorMain.
@Test
public void errorMain() {
CompletableSubject cs = CompletableSubject.create();
PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Integer> to = cs.andThen(ps).test();
assertTrue(cs.hasObservers());
assertFalse(ps.hasObservers());
cs.onError(new TestException());
assertFalse(cs.hasObservers());
assertFalse(ps.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.
the class CompletableAndThenObservableTest method errorOther.
@Test
public void errorOther() {
CompletableSubject cs = CompletableSubject.create();
PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Integer> to = cs.andThen(ps).test();
assertTrue(cs.hasObservers());
assertFalse(ps.hasObservers());
cs.onComplete();
assertFalse(cs.hasObservers());
assertTrue(ps.hasObservers());
ps.onError(new TestException());
assertFalse(cs.hasObservers());
assertFalse(ps.hasObservers());
to.assertFailure(TestException.class);
}
Aggregations