use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class HalfSerializerSubscriberTest method onErrorOnCompleteRace.
@Test
@SuppressUndeliverable
public void onErrorOnCompleteRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final AtomicInteger wip = new AtomicInteger();
final AtomicThrowable error = new AtomicThrowable();
final TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
ts.onSubscribe(new BooleanSubscription());
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
HalfSerializer.onError(ts, ex, wip, error);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
HalfSerializer.onComplete(ts, wip, error);
}
};
TestHelper.race(r1, r2);
if (ts.completions() != 0) {
ts.assertResult();
} else {
ts.assertFailure(TestException.class);
}
}
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription 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.internal.subscriptions.BooleanSubscription 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);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class QueueDrainSubscriberTest method unorderedSlowPath.
@Test
public void unorderedSlowPath() {
TestSubscriber<Integer> ts = new TestSubscriber<>(1);
Disposable d = Disposable.empty();
QueueDrainSubscriber<Integer, Integer, Integer> qd = createUnordered(ts, d);
ts.onSubscribe(new BooleanSubscription());
qd.enter();
qd.onNext(1);
ts.assertEmpty();
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class BoundedSubscriberTest method badSourceEmitAfterDone.
@Test
@SuppressUndeliverable
public void badSourceEmitAfterDone() {
Flowable<Integer> source = Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
BooleanSubscription s1 = new BooleanSubscription();
s.onSubscribe(s1);
s.onNext(1);
s.onComplete();
s.onNext(2);
s.onError(new TestException());
s.onComplete();
}
});
final List<Object> received = new ArrayList<>();
BoundedSubscriber<Object> subscriber = new BoundedSubscriber<>(new Consumer<Object>() {
@Override
public void accept(Object v) throws Exception {
received.add(v);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
received.add(e);
}
}, new Action() {
@Override
public void run() throws Exception {
received.add(100);
}
}, new Consumer<Subscription>() {
@Override
public void accept(Subscription s) throws Exception {
s.request(128);
}
}, 128);
source.subscribe(subscriber);
assertEquals(Arrays.asList(1, 100), received);
}
Aggregations