use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableConcatWithMaybeTest method mainError.
@Test
public void mainError() {
final TestObserver<Integer> to = new TestObserver<>();
Observable.<Integer>error(new TestException()).concatWith(Maybe.<Integer>fromAction(new Action() {
@Override
public void run() throws Exception {
to.onNext(100);
}
})).subscribe(to);
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableConcatWithCompletableTest method mainError.
@Test
public void mainError() {
final TestObserver<Integer> to = new TestObserver<>();
Observable.<Integer>error(new TestException()).concatWith(Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
to.onNext(100);
}
})).subscribe(to);
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableConcatWithSingleTest method mainError.
@Test
public void mainError() {
final TestObserver<Integer> to = new TestObserver<>();
Observable.<Integer>error(new TestException()).concatWith(Single.just(100)).subscribe(to);
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableCreateTest method serializedDrainDoneButNotEmpty.
@Test
public void serializedDrainDoneButNotEmpty() throws Throwable {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
TestObserver<Integer> to = new TestObserver<>();
AtomicReference<ObservableEmitter<Integer>> ref = new AtomicReference<>();
CountDownLatch cdl = new CountDownLatch(1);
Observable.<Integer>create(emitter -> {
emitter = emitter.serialize();
ref.set(emitter);
emitter.onNext(1);
}).doOnNext(v -> {
if (v == 1) {
TestHelper.raceOther(() -> {
ref.get().onNext(2);
ref.get().onComplete();
}, cdl);
ref.get().onNext(3);
}
}).subscribe(to);
cdl.await();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableDelaySubscriptionOtherTest method noPrematureSubscription.
@Test
public void noPrematureSubscription() {
PublishSubject<Object> other = PublishSubject.create();
TestObserver<Integer> to = new TestObserver<>();
final AtomicInteger subscribed = new AtomicInteger();
Observable.just(1).doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable d) {
subscribed.getAndIncrement();
}
}).delaySubscription(other).subscribe(to);
to.assertNotComplete();
to.assertNoErrors();
to.assertNoValues();
Assert.assertEquals("Premature subscription", 0, subscribed.get());
other.onNext(1);
Assert.assertEquals("No subscription", 1, subscribed.get());
to.assertValue(1);
to.assertNoErrors();
to.assertComplete();
}
Aggregations