Skip to content

Commit

Permalink
new DeliberateException
Browse files Browse the repository at this point in the history
  • Loading branch information
Scottmitch committed Oct 4, 2023
1 parent 09c3593 commit 1eddb7d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.servicetalk.concurrent.api;

import io.servicetalk.concurrent.internal.DeliberateException;
import io.servicetalk.concurrent.test.internal.TestPublisherSubscriber;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -50,16 +51,17 @@ void nullCompletes() {
@ParameterizedTest(name = "{displayName} [{index}] shouldThrow={0}")
@ValueSource(booleans = {false, true})
void completeToError(boolean shouldThrow) {
final DeliberateException thrown = new DeliberateException();
toSource(from(1)
.onCompleteError(() -> {
if (shouldThrow) {
throw DELIBERATE_EXCEPTION;
throw thrown;
}
return DELIBERATE_EXCEPTION;
})
).subscribe(subscriber);
subscriber.awaitSubscription().request(1);
assertThat(subscriber.takeOnNext(), equalTo(1));
assertThat(subscriber.awaitOnError(), sameInstance(DELIBERATE_EXCEPTION));
assertThat(subscriber.awaitOnError(), shouldThrow ? sameInstance(thrown) : sameInstance(DELIBERATE_EXCEPTION));
}
}

0 comments on commit 1eddb7d

Please sign in to comment.