use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class BoundedSubscriberTest method cancel.
@Test
public void cancel() {
BoundedSubscriber<Integer> subscriber = new BoundedSubscriber<>(Functions.<Integer>emptyConsumer(), Functions.<Throwable>emptyConsumer(), Functions.EMPTY_ACTION, Functions.<Subscription>boundedConsumer(128), 128);
BooleanSubscription bs = new BooleanSubscription();
subscriber.onSubscribe(bs);
subscriber.cancel();
assertTrue(bs.isCancelled());
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class BoundedSubscriberTest method dispose.
@Test
public void dispose() {
BoundedSubscriber<Integer> subscriber = new BoundedSubscriber<>(Functions.<Integer>emptyConsumer(), Functions.<Throwable>emptyConsumer(), Functions.EMPTY_ACTION, Functions.<Subscription>boundedConsumer(128), 128);
BooleanSubscription bs = new BooleanSubscription();
subscriber.onSubscribe(bs);
assertFalse(subscriber.isDisposed());
subscriber.dispose();
assertTrue(bs.isCancelled());
assertTrue(subscriber.isDisposed());
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FutureSubscriberTest method onSubscribe.
@Test
public void onSubscribe() throws Exception {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
BooleanSubscription s = new BooleanSubscription();
fs.onSubscribe(s);
BooleanSubscription s2 = new BooleanSubscription();
fs.onSubscribe(s2);
assertFalse(s.isCancelled());
assertTrue(s2.isCancelled());
TestHelper.assertError(errors, 0, IllegalStateException.class, "Subscription already set!");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FutureSubscriberTest method onCompleteCancelRace.
@Test
@SuppressUndeliverable
public void onCompleteCancelRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final FutureSubscriber<Integer> fs = new FutureSubscriber<>();
if (i % 3 == 0) {
fs.onSubscribe(new BooleanSubscription());
}
if (i % 2 == 0) {
fs.onNext(1);
}
Runnable r1 = new Runnable() {
@Override
public void run() {
fs.cancel(false);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
fs.onComplete();
}
};
TestHelper.race(r1, r2);
}
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class LambdaSubscriberTest 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<>();
LambdaSubscriber<Object> subscriber = new LambdaSubscriber<>(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(Long.MAX_VALUE);
}
});
source.subscribe(subscriber);
assertEquals(Arrays.asList(1, 100), received);
}
Aggregations