use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class CompletableAmbTest 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<Void> to = Completable.amb(Arrays.asList(pp0.ignoreElements(), pp1.ignoreElements())).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 CompletableMergeTest method iterableCompleteLater.
@Test
public void iterableCompleteLater() {
CompletableSubject cs = CompletableSubject.create();
TestObserver<Void> to = Completable.mergeDelayError(Arrays.asList(cs, cs, cs)).test();
to.assertEmpty();
cs.onComplete();
to.assertResult();
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class CompletableTakeUntilTest method mainErrors.
@Test
public void mainErrors() {
CompletableSubject cs1 = CompletableSubject.create();
CompletableSubject cs2 = CompletableSubject.create();
TestObserver<Void> to = cs1.takeUntil(cs2).test();
to.assertEmpty();
assertTrue(cs1.hasObservers());
assertTrue(cs2.hasObservers());
cs1.onError(new TestException());
assertFalse(cs1.hasObservers());
assertFalse(cs2.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class CompletableAmbTest method ambRace.
@Test
public void ambRace() {
TestObserver<Void> to = new TestObserver<>();
to.onSubscribe(Disposable.empty());
CompositeDisposable cd = new CompositeDisposable();
AtomicBoolean once = new AtomicBoolean();
Amb a = new Amb(once, cd, to);
a.onSubscribe(Disposable.empty());
a.onComplete();
a.onComplete();
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
a.onError(new TestException());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class CompletableDelaySubscriptionTest method timestep.
@Test
public void timestep() {
TestScheduler scheduler = new TestScheduler();
final AtomicInteger counter = new AtomicInteger();
Completable result = Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
counter.incrementAndGet();
}
}).delaySubscription(100, TimeUnit.MILLISECONDS, scheduler);
TestObserver<Void> to = result.test();
scheduler.advanceTimeBy(90, TimeUnit.MILLISECONDS);
to.assertEmpty();
scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS);
to.assertResult();
assertEquals(1, counter.get());
}
Aggregations