use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class FlowableConcatMapCompletableTest method doneButNotEmpty.
@Test
public void doneButNotEmpty() {
final PublishProcessor<Integer> pp = PublishProcessor.create();
final CompletableSubject cs = CompletableSubject.create();
final TestObserver<Void> to = pp.concatMapCompletable(Functions.justFunction(cs)).test();
pp.onNext(1);
pp.onNext(2);
pp.onComplete();
cs.onComplete();
to.assertResult();
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class MaybeFromFutureTest method cancelAndCrashWhileRunning.
@Test
public void cancelAndCrashWhileRunning() {
final TestObserver<Object> to = new TestObserver<>();
FutureTask<Object> ft = new FutureTask<>(new Runnable() {
@Override
public void run() {
to.dispose();
throw new TestException();
}
}, null);
Schedulers.single().scheduleDirect(ft, 100, TimeUnit.MILLISECONDS);
Maybe.fromFuture(ft).subscribeWith(to).assertEmpty();
assertTrue(to.isDisposed());
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class MaybeTakeUntilTest method untilMaybeMainError.
@Test
public void untilMaybeMainError() {
MaybeSubject<Integer> main = MaybeSubject.create();
MaybeSubject<Integer> other = MaybeSubject.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasObservers());
main.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class MaybeTakeUntilTest method untilMaybeOtherError.
@Test
public void untilMaybeOtherError() {
MaybeSubject<Integer> main = MaybeSubject.create();
MaybeSubject<Integer> other = MaybeSubject.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasObservers());
other.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver 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();
}
}
}
Aggregations