use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableAndThenCompletableTest method andThenNoInterrupt.
@Test
public void andThenNoInterrupt() throws InterruptedException {
for (int k = 0; k < 100; k++) {
final int count = 10;
final CountDownLatch latch = new CountDownLatch(count);
final boolean[] interrupted = { false };
for (int i = 0; i < count; i++) {
Completable.complete().subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).andThen(Completable.fromAction(new Action() {
@Override
public void run() throws Exception {
try {
Thread.sleep(30);
} catch (InterruptedException e) {
System.out.println("Interrupted! " + Thread.currentThread());
interrupted[0] = true;
}
}
})).subscribe(new Action() {
@Override
public void run() throws Exception {
latch.countDown();
}
});
}
latch.await();
assertFalse("The second Completable was interrupted!", interrupted[0]);
}
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableConcatTest method overflowReported.
@Test
public void overflowReported() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Completable.concat(Flowable.fromPublisher(new Publisher<Completable>() {
@Override
public void subscribe(Subscriber<? super Completable> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(Completable.never());
s.onNext(Completable.never());
s.onNext(Completable.never());
s.onNext(Completable.never());
s.onComplete();
}
}), 1).test().assertFailure(MissingBackpressureException.class);
TestHelper.assertError(errors, 0, MissingBackpressureException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableMergeTest method mainErrorInnerErrorDelayedRace.
@Test
public void mainErrorInnerErrorDelayedRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final PublishProcessor<Integer> pp1 = PublishProcessor.create();
final PublishProcessor<Integer> pp2 = PublishProcessor.create();
TestObserverEx<Void> to = Completable.mergeDelayError(pp1.map(new Function<Integer, Completable>() {
@Override
public Completable apply(Integer v) throws Exception {
return pp2.ignoreElements();
}
})).to(TestHelper.<Void>testConsumer());
pp1.onNext(1);
final Throwable ex1 = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
pp1.onError(ex1);
}
};
final Throwable ex2 = new TestException();
Runnable r2 = new Runnable() {
@Override
public void run() {
pp2.onError(ex2);
}
};
TestHelper.race(r1, r2);
to.assertFailure(CompositeException.class);
List<Throwable> errors = TestHelper.compositeList(to.errors().get(0));
TestHelper.assertError(errors, 0, TestException.class);
TestHelper.assertError(errors, 1, TestException.class);
}
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableSafeSubscribeTest method onCompleteCrash.
@Test
public void onCompleteCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
CompletableObserver consumer = mock(CompletableObserver.class);
doThrow(new TestException()).when(consumer).onComplete();
new Completable() {
@Override
protected void subscribeActual(@NonNull CompletableObserver observer) {
observer.onSubscribe(Disposable.empty());
// none of the following should arrive at the consumer
observer.onComplete();
}
}.safeSubscribe(consumer);
InOrder order = inOrder(consumer);
order.verify(consumer).onSubscribe(any(Disposable.class));
order.verify(consumer).onComplete();
order.verifyNoMoreInteractions();
TestHelper.assertUndeliverable(errors, 0, TestException.class);
});
}
use of io.reactivex.rxjava3.core.Completable in project RxJava by ReactiveX.
the class CompletableSwitchOnNextTest method noDelaySwitch.
@Test
public void noDelaySwitch() {
PublishProcessor<Completable> pp = PublishProcessor.create();
TestObserver<Void> to = Completable.switchOnNext(pp).test();
assertTrue(pp.hasSubscribers());
to.assertEmpty();
CompletableSubject cs1 = CompletableSubject.create();
CompletableSubject cs2 = CompletableSubject.create();
pp.onNext(cs1);
assertTrue(cs1.hasObservers());
pp.onNext(cs2);
assertFalse(cs1.hasObservers());
assertTrue(cs2.hasObservers());
pp.onComplete();
assertTrue(cs2.hasObservers());
cs2.onComplete();
to.assertResult();
}
Aggregations