use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteAlreadyComplete.
@Test
public void postCompleteAlreadyComplete() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
Queue<Integer> q = new ArrayDeque<>();
q.offer(1);
AtomicLong state = new AtomicLong(QueueDrainHelper.COMPLETED_MASK);
QueueDrainHelper.postComplete(ts, q, state, new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return false;
}
});
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class QueueDrainHelperTest method drainMaxLoopMissingBackpressureWithResource.
@Test
public void drainMaxLoopMissingBackpressureWithResource() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
ts.onSubscribe(new BooleanSubscription());
QueueDrain<Integer, Integer> qd = new QueueDrain<Integer, Integer>() {
@Override
public boolean cancelled() {
return false;
}
@Override
public boolean done() {
return false;
}
@Override
public Throwable error() {
return null;
}
@Override
public boolean enter() {
return true;
}
@Override
public long requested() {
return 0;
}
@Override
public long produced(long n) {
return 0;
}
@Override
public int leave(int m) {
return 0;
}
@Override
public boolean accept(Subscriber<? super Integer> a, Integer v) {
return false;
}
};
SpscArrayQueue<Integer> q = new SpscArrayQueue<>(32);
q.offer(1);
Disposable d = Disposable.empty();
QueueDrainHelper.drainMaxLoop(q, ts, false, d, qd);
ts.assertFailure(MissingBackpressureException.class);
assertTrue(d.isDisposed());
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class AtomicThrowableTest method tryTerminateConsumerSubscriberError.
@Test
public void tryTerminateConsumerSubscriberError() {
TestSubscriber<Object> ts = new TestSubscriber<>();
ts.onSubscribe(new BooleanSubscription());
AtomicThrowable ex = new AtomicThrowable();
ex.set(new TestException());
ex.tryTerminateConsumer(ts);
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableDetachTest method error.
@Test
public void error() {
TestSubscriber<Object> ts = new TestSubscriber<>();
Flowable.error(new TestException()).onTerminateDetach().subscribe(ts);
ts.assertNoValues();
ts.assertError(TestException.class);
ts.assertNotComplete();
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableDoAfterTerminateTest method ifFinallyActionThrowsExceptionShouldNotBeSwallowedAndActionShouldBeCalledOnce.
@Test
public void ifFinallyActionThrowsExceptionShouldNotBeSwallowedAndActionShouldBeCalledOnce() throws Throwable {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Action finallyAction = Mockito.mock(Action.class);
doThrow(new IllegalStateException()).when(finallyAction).run();
TestSubscriber<String> testSubscriber = new TestSubscriber<>();
Flowable.just("value").doAfterTerminate(finallyAction).subscribe(testSubscriber);
testSubscriber.assertValue("value");
verify(finallyAction).run();
TestHelper.assertError(errors, 0, IllegalStateException.class);
// Actual result:
// Not only IllegalStateException was swallowed
// But finallyAction was called twice!
} finally {
RxJavaPlugins.reset();
}
}
Aggregations