use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class SingleTimeoutTest method shouldUnsubscribeFromUnderlyingSubscriptionOnDispose.
@Test
public void shouldUnsubscribeFromUnderlyingSubscriptionOnDispose() {
final PublishSubject<String> subject = PublishSubject.create();
final TestScheduler scheduler = new TestScheduler();
final TestObserver<String> observer = subject.single("").timeout(100, TimeUnit.MILLISECONDS, scheduler).test();
assertTrue(subject.hasObservers());
observer.dispose();
assertFalse(subject.hasObservers());
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class SingleZipIterableTest 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(Arrays.asList(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.observers.TestObserver in project RxJava by ReactiveX.
the class AsyncSubjectTest method onErrorCrossCancel.
@Test
@SuppressUndeliverable
public void onErrorCrossCancel() {
AsyncSubject<Object> p = AsyncSubject.create();
final TestObserver<Object> to2 = new TestObserver<>();
TestObserver<Object> to1 = new TestObserver<Object>() {
@Override
public void onError(Throwable t) {
to2.dispose();
super.onError(t);
}
};
p.subscribe(to1);
p.subscribe(to2);
p.onError(new TestException());
to1.assertFailure(TestException.class);
to2.assertEmpty();
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableConcatWithMaybeTest method normalEmpty.
@Test
public void normalEmpty() {
final TestObserver<Integer> to = new TestObserver<>();
Observable.range(1, 5).concatWith(Maybe.<Integer>fromAction(new Action() {
@Override
public void run() throws Exception {
to.onNext(100);
}
})).subscribe(to);
to.assertResult(1, 2, 3, 4, 5, 100);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableConcatWithMaybeTest method otherError.
@Test
public void otherError() {
final TestObserver<Integer> to = new TestObserver<>();
Observable.range(1, 5).concatWith(Maybe.<Integer>error(new TestException())).subscribe(to);
to.assertFailure(TestException.class, 1, 2, 3, 4, 5);
}
Aggregations