use of io.servicetalk.concurrent.SingleSource in project servicetalk by apple.
the class ReactiveStreamsAdaptersTest method singleToRSFromSourceCancel.
@Test
void singleToRSFromSourceCancel() {
Cancellable srcCancellable = mock(Cancellable.class);
SingleSource<Integer> source = s -> s.onSubscribe(srcCancellable);
Subscriber<Integer> subscriber = toRSPublisherFromSourceAndSubscribe(source);
ArgumentCaptor<Subscription> rsSubscriptionCaptor = ArgumentCaptor.forClass(Subscription.class);
verify(subscriber).onSubscribe(rsSubscriptionCaptor.capture());
rsSubscriptionCaptor.getValue().cancel();
verify(srcCancellable).cancel();
}
use of io.servicetalk.concurrent.SingleSource in project servicetalk by apple.
the class SourceAdaptersTest method singleFromSourceError.
@Test
void singleFromSourceError() {
SingleSource<Integer> src = s -> {
s.onSubscribe(IGNORE_CANCEL);
s.onError(DELIBERATE_EXCEPTION);
};
Future<Integer> future = fromSource(src).toFuture();
Exception e = assertThrows(ExecutionException.class, () -> future.get());
assertThat(e.getCause(), sameInstance(DELIBERATE_EXCEPTION));
}
use of io.servicetalk.concurrent.SingleSource in project servicetalk by apple.
the class SourceAdaptersTest method singleFromSourceCancel.
@Test
void singleFromSourceCancel() {
Cancellable srcCancellable = mock(Cancellable.class);
SingleSource<Integer> source = s -> s.onSubscribe(srcCancellable);
fromSource(source).toFuture().cancel(true);
verify(srcCancellable).cancel();
}
Aggregations