use of io.reactivex.rxjava3.subjects.PublishSubject 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);
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class MaybeMergeArrayTest method errorRace.
@Test
public void errorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishSubject<Integer> ps1 = PublishSubject.create();
final PublishSubject<Integer> ps2 = PublishSubject.create();
TestSubscriber<Integer> ts = Maybe.mergeArray(ps1.singleElement(), ps2.singleElement()).test();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
ps1.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
ps2.onError(ex);
}
};
TestHelper.race(r1, r2);
ts.assertFailure(Throwable.class);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableWithLatestFromTest method sourceThrows.
@Test
public void sourceThrows() {
PublishSubject<Integer> source = PublishSubject.create();
PublishSubject<Integer> other = PublishSubject.create();
Observable<Integer> result = source.withLatestFrom(other, COMBINER);
TestObserverEx<Integer> to = new TestObserverEx<>();
result.subscribe(to);
assertTrue(source.hasObservers());
assertTrue(other.hasObservers());
other.onNext(1);
source.onNext(1);
source.onError(new TestException());
to.assertTerminated();
to.assertValue((1 << 8) + 1);
to.assertError(TestException.class);
to.assertNotComplete();
assertFalse(source.hasObservers());
assertFalse(other.hasObservers());
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableWithLatestFromTest method otherThrows.
@Test
public void otherThrows() {
PublishSubject<Integer> source = PublishSubject.create();
PublishSubject<Integer> other = PublishSubject.create();
Observable<Integer> result = source.withLatestFrom(other, COMBINER);
TestObserverEx<Integer> to = new TestObserverEx<>();
result.subscribe(to);
assertTrue(source.hasObservers());
assertTrue(other.hasObservers());
other.onNext(1);
source.onNext(1);
other.onError(new TestException());
to.assertTerminated();
to.assertValue((1 << 8) + 1);
to.assertNotComplete();
to.assertError(TestException.class);
assertFalse(source.hasObservers());
assertFalse(other.hasObservers());
}
use of io.reactivex.rxjava3.subjects.PublishSubject in project RxJava by ReactiveX.
the class ObservableZipIterableTest method zipIterableNextThrows.
@Test
public void zipIterableNextThrows() {
PublishSubject<String> r1 = PublishSubject.create();
/* define an Observer to receive aggregated events */
Observer<String> o = TestHelper.mockObserver();
InOrder io = inOrder(o);
Iterable<String> r2 = new Iterable<String>() {
@Override
public Iterator<String> iterator() {
return new Iterator<String>() {
@Override
public boolean hasNext() {
return true;
}
@Override
public String next() {
throw new TestException();
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
};
r1.zipWith(r2, zipr2).subscribe(o);
r1.onError(new TestException());
io.verify(o).onError(any(TestException.class));
verify(o, never()).onNext(any(String.class));
verify(o, never()).onComplete();
}
Aggregations