use of io.servicetalk.concurrent.api.TestCompletable in project servicetalk by apple.
the class CompletableConcatWithCompletablesTest method setUp.
@BeforeEach
void setUp() {
subscriber = new TestCompletableSubscriber();
source = new TestCompletable();
}
use of io.servicetalk.concurrent.api.TestCompletable 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.TestCompletable in project servicetalk by apple.
the class CompletableToPublisherTest method publishOnOriginalIsPreservedOnComplete.
@Test
void publishOnOriginalIsPreservedOnComplete() throws Exception {
ConcurrentLinkedQueue<AssertionError> errors = new ConcurrentLinkedQueue<>();
TestPublisherSubscriber<String> subscriber = new TestPublisherSubscriber<>();
TestCompletable completable = new TestCompletable();
CountDownLatch analyzed = publishOnOriginalIsPreserved0(errors, subscriber, completable);
completable.onComplete();
analyzed.await();
assertThat("Unexpected errors observed: " + errors, errors, hasSize(0));
subscriber.awaitOnComplete();
}
use of io.servicetalk.concurrent.api.TestCompletable in project servicetalk by apple.
the class CompletableToPublisherTest method publishOnOriginalIsPreserved0.
private CountDownLatch publishOnOriginalIsPreserved0(final ConcurrentLinkedQueue<AssertionError> errors, final TestPublisherSubscriber<String> subscriber, final TestCompletable completable) {
final Thread testThread = currentThread();
CountDownLatch analyzed = new CountDownLatch(1);
CountDownLatch receivedOnSubscribe = new CountDownLatch(1);
toSource(completable.publishOn(EXEC.executor()).beforeOnComplete(() -> {
if (currentThread() == testThread) {
errors.add(new AssertionError("Invalid thread invoked onComplete " + "(from Completable). Thread: " + currentThread()));
}
}).beforeOnError(__ -> {
if (currentThread() == testThread) {
errors.add(new AssertionError("Invalid thread invoked onError" + "(from Completable). Thread: " + currentThread()));
}
}).<String>toPublisher().beforeOnComplete(() -> {
if (currentThread() == testThread) {
errors.add(new AssertionError("Invalid thread invoked onComplete " + "(from Publisher). Thread: " + currentThread()));
}
}).beforeOnError(__ -> {
if (currentThread() == testThread) {
errors.add(new AssertionError("Invalid thread invoked onError " + "(from Publisher). Thread: " + currentThread()));
}
}).afterOnComplete(analyzed::countDown).afterOnError(__ -> analyzed.countDown()).afterOnSubscribe(__ -> receivedOnSubscribe.countDown())).subscribe(subscriber);
assertThat("Completable not subscribed.", completable.isSubscribed(), is(true));
return analyzed;
}
use of io.servicetalk.concurrent.api.TestCompletable in project servicetalk by apple.
the class CompletableConcatWithCompletableTest method setUp.
@BeforeEach
void setUp() {
subscriber = new TestCompletableSubscriber();
source = new TestCompletable();
next = new TestCompletable();
}
Aggregations