use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class SingleConcatWithCompletableTest method testCancelSource.
@Test
void testCancelSource() {
assertThat(subscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
subscriber.awaitSubscription().cancel();
TestCancellable cancellable = new TestCancellable();
source.onSubscribe(cancellable);
assertTrue(cancellable.isCancelled());
assertFalse(next.isSubscribed());
}
use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class PublisherConcatWithSingleTest method initState.
private void initState() {
subscription = new TestSubscription();
cancellable = new TestCancellable();
source = new TestPublisher<>();
subscriber = new TestPublisherSubscriber<>();
single = new TestSingle<>();
}
use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class TimeoutCompletableTest method executorScheduleThrows.
@Test
void executorScheduleThrows() {
toSource(source.ignoreElement().timeout(1, NANOSECONDS, new DelegatingExecutor(testExecutor) {
@Override
public Cancellable schedule(final Runnable task, final long delay, final TimeUnit unit) {
throw DELIBERATE_EXCEPTION;
}
})).subscribe(listener);
assertThat(listener.awaitOnError(), is(DELIBERATE_EXCEPTION));
TestCancellable cancellable = new TestCancellable();
source.onSubscribe(cancellable);
assertTrue(cancellable.isCancelled());
}
use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class CompletableConcatWithCompletablesTest method testCancelSource.
@ParameterizedTest
@ValueSource(ints = { 1, 2 })
void testCancelSource(int num) {
initNexts(num);
toSource(source.concat(nexts)).subscribe(subscriber);
assertThat(subscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
subscriber.awaitSubscription().cancel();
TestCancellable cancellable = new TestCancellable();
source.onSubscribe(cancellable);
assertTrue(cancellable.isCancelled());
for (final TestCompletable next : nexts) {
assertFalse(next.isSubscribed());
}
}
use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class CompletableConcatWithCompletableTest method testCancelNext.
@Test
void testCancelNext() {
toSource(source.concat(next)).subscribe(subscriber);
source.onComplete();
assertThat(subscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
subscriber.awaitSubscription().cancel();
TestCancellable sourceCancellable = new TestCancellable();
source.onSubscribe(sourceCancellable);
assertFalse(sourceCancellable.isCancelled());
TestCancellable nextCancellable = new TestCancellable();
source.onSubscribe(nextCancellable);
assertTrue(nextCancellable.isCancelled());
}
Aggregations