use of org.reactivestreams.Subscription in project RxJava by ReactiveX.
the class InnerQueuedSubscriberTest method requestInBatches.
@Test
public void requestInBatches() {
InnerQueuedSubscriberSupport<Integer> support = new InnerQueuedSubscriberSupport<Integer>() {
@Override
public void innerNext(InnerQueuedSubscriber<Integer> inner, Integer value) {
}
@Override
public void innerError(InnerQueuedSubscriber<Integer> inner, Throwable e) {
}
@Override
public void innerComplete(InnerQueuedSubscriber<Integer> inner) {
}
@Override
public void drain() {
}
};
InnerQueuedSubscriber<Integer> inner = new InnerQueuedSubscriber<Integer>(support, 4);
final List<Long> requests = new ArrayList<Long>();
inner.onSubscribe(new Subscription() {
@Override
public void request(long n) {
requests.add(n);
}
@Override
public void cancel() {
// ignore
}
});
inner.request(1);
inner.request(1);
inner.request(1);
inner.request(1);
inner.request(1);
assertEquals(Arrays.asList(4L, 3L), requests);
}
use of org.reactivestreams.Subscription in project RxJava by ReactiveX.
the class BlockingSubscriberTest method cancelUpfront.
@Test
public void cancelUpfront() {
final BlockingFirstSubscriber<Integer> bf = new BlockingFirstSubscriber<Integer>();
final AtomicBoolean b = new AtomicBoolean();
bf.cancelled = true;
Subscription s = new Subscription() {
@Override
public void request(long n) {
b.set(true);
}
@Override
public void cancel() {
}
};
bf.onSubscribe(s);
assertFalse(b.get());
}
use of org.reactivestreams.Subscription in project RxJava by ReactiveX.
the class AsyncSubscriptionTest method testSingleSet.
@Test
public void testSingleSet() {
AsyncSubscription as = new AsyncSubscription();
Subscription s = mock(Subscription.class);
as.setSubscription(s);
Subscription s1 = mock(Subscription.class);
as.setSubscription(s1);
assertSame(as.actual.get(), s);
verify(s1).cancel();
}
use of org.reactivestreams.Subscription in project RxJava by ReactiveX.
the class AsyncSubscriptionTest method testCancelOnce.
@Test
public void testCancelOnce() {
Disposable r = mock(Disposable.class);
AsyncSubscription as = new AsyncSubscription(r);
Subscription s = mock(Subscription.class);
as.setSubscription(s);
as.cancel();
as.cancel();
as.cancel();
verify(s, never()).request(anyLong());
verify(s).cancel();
verify(r).dispose();
}
use of org.reactivestreams.Subscription in project RxJava by ReactiveX.
the class AsyncSubscriptionTest method testNoResource.
@Test
public void testNoResource() {
AsyncSubscription as = new AsyncSubscription();
Subscription s = mock(Subscription.class);
as.setSubscription(s);
as.request(1);
as.cancel();
verify(s).request(1);
verify(s).cancel();
}
Aggregations