use of io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION in project servicetalk by apple.
the class CollectTest method collectIterableDelayErrorMaxConcurrency.
@Test
void collectIterableDelayErrorMaxConcurrency() throws Exception {
AtomicBoolean secondSubscribed = new AtomicBoolean();
Future<? extends Collection<Integer>> future = collectUnorderedDelayError(asList(failed(DELIBERATE_EXCEPTION), succeeded(2).beforeOnSubscribe(__ -> secondSubscribed.set(true))), 1).toFuture();
try {
future.get();
fail();
} catch (ExecutionException e) {
assertThat("Second source not subscribed.", secondSubscribed.get(), is(true));
assertThat("Unexpected exception.", e.getCause(), is(DELIBERATE_EXCEPTION));
}
}
use of io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION in project servicetalk by apple.
the class SingleToCompletionStageTest method completableFutureFromSingleToCompletionStageToCompletableFutureFailure.
@Test
void completableFutureFromSingleToCompletionStageToCompletableFutureFailure() {
CompletableFuture<Long> input = new CompletableFuture<>();
CompletableFuture<Long> output = Single.fromStage(input).toCompletionStage().toCompletableFuture().whenComplete((v, c) -> {
}).thenApply(l -> l + 1).whenComplete((v, c) -> {
});
input.completeExceptionally(DELIBERATE_EXCEPTION);
ExecutionException e = assertThrows(ExecutionException.class, () -> output.get());
assertThat(e.getCause(), is(DELIBERATE_EXCEPTION));
}
use of io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION in project servicetalk by apple.
the class BeforeErrorTest method testCallbackThrowsError.
@Override
@Test
void testCallbackThrowsError() {
DeliberateException srcEx = new DeliberateException();
this.<String>doError(Publisher.failed(srcEx), t1 -> {
throw DELIBERATE_EXCEPTION;
}).subscribe(subscriber);
subscriber.awaitSubscription().request(1);
assertThat(subscriber.awaitOnError(), sameInstance(srcEx));
verifySuppressed(subscriber.awaitOnError(), DELIBERATE_EXCEPTION);
}
use of io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION in project servicetalk by apple.
the class CollectTest method collectIterableDelayError.
@Test
void collectIterableDelayError() throws Exception {
AtomicBoolean secondSubscribed = new AtomicBoolean();
Future<Void> future = mergeAllDelayError(asList(failed(DELIBERATE_EXCEPTION), completed().beforeOnSubscribe(__ -> secondSubscribed.set(true)))).toFuture();
try {
future.get();
fail();
} catch (ExecutionException e) {
assertThat("Second source not subscribed.", secondSubscribed.get(), is(true));
assertThat("Unexpected exception.", e.getCause(), is(DELIBERATE_EXCEPTION));
}
}
use of io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION in project servicetalk by apple.
the class CollectTest method collectIterableDelayErrorMaxConcurrency.
@Test
void collectIterableDelayErrorMaxConcurrency() throws Exception {
AtomicBoolean secondSubscribed = new AtomicBoolean();
Future<Void> future = mergeAllDelayError(asList(failed(DELIBERATE_EXCEPTION), completed().beforeOnSubscribe(__ -> secondSubscribed.set(true))), 1).toFuture();
try {
future.get();
fail();
} catch (ExecutionException e) {
assertThat("Second source not subscribed.", secondSubscribed.get(), is(true));
assertThat("Unexpected exception.", e.getCause(), is(DELIBERATE_EXCEPTION));
}
}
Aggregations