Skip to content

Instantly share code, notes, and snippets.

@ikhoon
Created August 19, 2020 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikhoon/a7be4742f1600a077cb6b5fc517825ad to your computer and use it in GitHub Desktop.
Save ikhoon/a7be4742f1600a077cb6b5fc517825ad to your computer and use it in GitHub Desktop.
class FixedStreamMessageTest {
@ArgumentsSource(IntsProvider.class)
@ParameterizedTest
void spec_306_requestAfterCancel(List<Integer> nums) throws InterruptedException {
final Integer[] array = nums.stream().toArray(Integer[]::new);
final StreamMessage<Integer> message = StreamMessage.of(array);
final CompletableFuture<Subscription> subscriptionFuture = new CompletableFuture<>();
message.subscribe(new Subscriber<Integer>() {
@Override
public void onSubscribe(Subscription s) {
subscriptionFuture.complete(s);
}
@Override
public void onNext(Integer integer) {}
@Override
public void onError(Throwable t) {}
@Override
public void onComplete() {}
}, ImmediateEventExecutor.INSTANCE);
final Subscription subscription = subscriptionFuture.join();
subscription.cancel();
assertThatCode(() -> subscription.request(1)).doesNotThrowAnyException();
}
private static class IntsProvider implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
return Stream.of(ImmutableList.of(),
ImmutableList.of(1),
ImmutableList.of(1, 2),
ImmutableList.of(1, 2, 3),
ImmutableList.of(1, 2, 3, 4))
.map(Arguments::of);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment