use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class CompletableConcatWithCompletablesTest method testCancelNext.
@ParameterizedTest
@ValueSource(ints = { 1, 2 })
void testCancelNext(int num) {
initNexts(num);
toSource(source.concat(nexts)).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());
}
use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class CompletableConcatWithPublisherTest method setUp.
@BeforeEach
void setUp() {
subscriber = new TestPublisherSubscriber<>();
cancellable = new TestCancellable();
source = new TestCompletable.Builder().disableAutoOnSubscribe().build();
next = new TestPublisher.Builder<Integer>().disableAutoOnSubscribe().build();
subscription = new TestSubscription();
toSource(source.concat(next)).subscribe(subscriber);
source.onSubscribe(cancellable);
subscriber.awaitSubscription();
}
use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class CompletableConcatWithSingleTest method testCancelNext.
@Test
void testCancelNext() {
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();
next.onSubscribe(nextCancellable);
assertTrue(nextCancellable.isCancelled());
}
use of io.servicetalk.concurrent.api.TestCancellable in project servicetalk by apple.
the class CompletableConcatWithSingleTest 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 CompletableToPublisherTest method invalidRequestNCancelsCompletable.
@Test
void invalidRequestNCancelsCompletable() {
TestCompletable completable = new TestCompletable.Builder().disableAutoOnSubscribe().build();
toSource(completable.<String>toPublisher()).subscribe(subscriber);
TestCancellable cancellable = new TestCancellable();
completable.onSubscribe(cancellable);
subscriber.awaitSubscription().request(-1);
assertThat(subscriber.awaitOnError(), is(instanceOf(IllegalArgumentException.class)));
assertThat("Completable not cancelled for invalid request-n", cancellable.isCancelled(), is(true));
}
Aggregations