use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method reentrantOnNextOnComplete.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantOnNextOnComplete() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Subscriber[] a = { null };
final TestSubscriber ts = new TestSubscriber();
FlowableSubscriber s = new FlowableSubscriber() {
@Override
public void onSubscribe(Subscription s) {
ts.onSubscribe(s);
}
@Override
public void onNext(Object t) {
if (t.equals(1)) {
HalfSerializer.onComplete(a[0], wip, error);
}
ts.onNext(t);
}
@Override
public void onError(Throwable t) {
ts.onError(t);
}
@Override
public void onComplete() {
ts.onComplete();
}
};
a[0] = s;
s.onSubscribe(new BooleanSubscription());
HalfSerializer.onNext(s, 1, wip, error);
ts.assertResult(1);
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method reentrantErrorOnError.
@Test
@SuppressUndeliverable
@SuppressWarnings({ "rawtypes", "unchecked" })
public void reentrantErrorOnError() {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final Subscriber[] a = { null };
final TestSubscriber ts = new TestSubscriber();
FlowableSubscriber s = new FlowableSubscriber() {
@Override
public void onSubscribe(Subscription s) {
ts.onSubscribe(s);
}
@Override
public void onNext(Object t) {
ts.onNext(t);
}
@Override
public void onError(Throwable t) {
ts.onError(t);
HalfSerializer.onError(a[0], new IOException(), wip, error);
}
@Override
public void onComplete() {
ts.onComplete();
}
};
a[0] = s;
s.onSubscribe(new BooleanSubscription());
HalfSerializer.onError(s, new TestException(), wip, error);
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class DeferredScalarSubscriberTest method emissionRequestRace.
@Test
public void emissionRequestRace() {
Worker w = Schedulers.computation().createWorker();
try {
for (int i = 0; i < 10000; i++) {
final TestSubscriber<Integer> ts = TestSubscriber.create(0L);
TestingDeferredScalarSubscriber ds = new TestingDeferredScalarSubscriber(ts);
ds.setupDownstream();
ds.onNext(1);
final AtomicInteger ready = new AtomicInteger(2);
w.schedule(new Runnable() {
@Override
public void run() {
ready.decrementAndGet();
while (ready.get() != 0) {
}
ts.request(1);
}
});
ready.decrementAndGet();
while (ready.get() != 0) {
}
ds.onComplete();
ts.awaitDone(5, TimeUnit.SECONDS);
ts.assertValues(1);
ts.assertNoErrors();
ts.assertComplete();
}
} finally {
w.dispose();
}
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class QueueDrainSubscriberTest method acceptBadRequest.
@Test
public void acceptBadRequest() {
TestSubscriber<Integer> ts = new TestSubscriber<>(0);
Disposable d = Disposable.empty();
QueueDrainSubscriber<Integer, Integer, Integer> qd = createUnordered(ts, d);
ts.onSubscribe(new BooleanSubscription());
assertTrue(qd.accept(ts, 0));
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
qd.requested(-1);
TestHelper.assertError(errors, 0, IllegalArgumentException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class QueueDrainSubscriberTest method orderedFastPathRequest1.
@Test
public void orderedFastPathRequest1() {
TestSubscriber<Integer> ts = new TestSubscriber<>(1);
Disposable d = Disposable.empty();
QueueDrainSubscriber<Integer, Integer, Integer> qd = createOrdered(ts, d);
ts.onSubscribe(new BooleanSubscription());
qd.requested(1);
qd.onNext(1);
ts.assertValuesOnly(1);
}
Aggregations