use of io.reactivex.rxjava3.annotations.NonNull in project RxJava by ReactiveX.
the class BaseTestConsumer method fail.
/**
* Fail with the given message and add the sequence of errors as suppressed ones.
* <p>Note this is deliberately the only fail method. Most of the times an assertion
* would fail but it is possible it was due to an exception somewhere. This construct
* will capture those potential errors and report it along with the original failure.
*
* @param message the message to use
* @return AssertionError the prepared AssertionError instance
*/
@NonNull
protected final AssertionError fail(@NonNull String message) {
StringBuilder b = new StringBuilder(64 + message.length());
b.append(message);
b.append(" (").append("latch = ").append(done.getCount()).append(", ").append("values = ").append(values.size()).append(", ").append("errors = ").append(errors.size()).append(", ").append("completions = ").append(completions);
if (timeout) {
b.append(", timeout!");
}
if (isDisposed()) {
b.append(", disposed!");
}
CharSequence tag = this.tag;
if (tag != null) {
b.append(", tag = ").append(tag);
}
b.append(')');
AssertionError ae = new AssertionError(b.toString());
if (!errors.isEmpty()) {
if (errors.size() == 1) {
ae.initCause(errors.get(0));
} else {
CompositeException ce = new CompositeException(errors);
ae.initCause(ce);
}
}
return ae;
}
use of io.reactivex.rxjava3.annotations.NonNull in project RxJava by ReactiveX.
the class SerializedProcessorTest method onErrorQueued.
@Test
public void onErrorQueued() {
FlowableProcessor<Integer> sp = PublishProcessor.<Integer>create().toSerialized();
TestSubscriber<Integer> ts = new TestSubscriber<Integer>() {
@Override
public void onNext(@NonNull Integer t) {
super.onNext(t);
if (t == 1) {
sp.onNext(2);
sp.onSubscribe(new BooleanSubscription());
sp.onError(new TestException());
}
}
};
sp.subscribe(ts);
sp.onNext(1);
// errors skip ahead
ts.assertFailure(TestException.class, 1);
}
use of io.reactivex.rxjava3.annotations.NonNull in project RxJava by ReactiveX.
the class MaybeSafeSubscribeTest method onCompleteCrash.
@Test
public void onCompleteCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") MaybeObserver<Integer> consumer = mock(MaybeObserver.class);
doThrow(new TestException()).when(consumer).onComplete();
new Maybe<Integer>() {
@Override
protected void subscribeActual(@NonNull MaybeObserver<? super Integer> 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.annotations.NonNull in project RxJava by ReactiveX.
the class SerializedSubjectTest method onErrorQueued.
@Test
public void onErrorQueued() {
Subject<Integer> sp = PublishSubject.<Integer>create().toSerialized();
TestObserver<Integer> to = new TestObserver<Integer>() {
@Override
public void onNext(@NonNull Integer t) {
super.onNext(t);
if (t == 1) {
sp.onNext(2);
sp.onNext(3);
sp.onSubscribe(Disposable.empty());
sp.onError(new TestException());
}
}
};
sp.subscribe(to);
sp.onNext(1);
// errors skip ahead
to.assertFailure(TestException.class, 1);
}
use of io.reactivex.rxjava3.annotations.NonNull 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);
});
}
Aggregations