Search in sources :

Example 16 with TerminalSignalConsumer

use of io.servicetalk.concurrent.api.TerminalSignalConsumer in project servicetalk by apple.

the class BeforeFinallyTest method testCallbackThrowsErrorOnComplete.

@Override
@Test
void testCallbackThrowsErrorOnComplete() {
    TerminalSignalConsumer mock = throwableMock(DELIBERATE_EXCEPTION);
    doFinally(publisher, mock).subscribe(subscriber);
    assertFalse(subscription.isCancelled());
    publisher.onComplete();
    Throwable receivedError = subscriber.awaitOnError();
    assertThat(receivedError, is(notNullValue()));
    assertThat(receivedError, sameInstance(DELIBERATE_EXCEPTION));
    verify(mock).onComplete();
    verifyNoMoreInteractions(mock);
    assertFalse(subscription.isCancelled());
}
Also used : TerminalSignalConsumer(io.servicetalk.concurrent.api.TerminalSignalConsumer) Test(org.junit.jupiter.api.Test)

Aggregations

TerminalSignalConsumer (io.servicetalk.concurrent.api.TerminalSignalConsumer)16 Test (org.junit.jupiter.api.Test)10 DeliberateException (io.servicetalk.concurrent.internal.DeliberateException)8 AsyncContext (io.servicetalk.concurrent.api.AsyncContext)4 ContextMap (io.servicetalk.context.api.ContextMap)4 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)4 PublisherSource (io.servicetalk.concurrent.PublisherSource)3 Executor (io.servicetalk.concurrent.api.Executor)3 Single (io.servicetalk.concurrent.api.Single)3 SourceAdapters.toSource (io.servicetalk.concurrent.api.SourceAdapters.toSource)3 AbstractOffloadingTest (io.servicetalk.concurrent.api.internal.AbstractOffloadingTest)3 EnumSet (java.util.EnumSet)3 BiFunction (java.util.function.BiFunction)3 CoreMatchers.is (org.hamcrest.CoreMatchers.is)3 CoreMatchers.not (org.hamcrest.CoreMatchers.not)3 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)3 CoreMatchers.sameInstance (org.hamcrest.CoreMatchers.sameInstance)3 Matchers.lessThan (org.hamcrest.Matchers.lessThan)3 Publisher (io.servicetalk.concurrent.api.Publisher)2 StreamingHttpRequest (io.servicetalk.http.api.StreamingHttpRequest)2