Search in sources :

Example 1 with TestSingleSubscriber

use of io.servicetalk.concurrent.test.internal.TestSingleSubscriber in project servicetalk by apple.

the class RetryWhenTest method exceptionInTerminalCallsOnError.

@Test
void exceptionInTerminalCallsOnError() {
    DeliberateException ex = new DeliberateException();
    TestSingleSubscriber<Integer> subscriberRule = new TestSingleSubscriber<>();
    source = new LegacyTestSingle<>(false, false);
    toSource(source.retryWhen((times, cause) -> {
        throw ex;
    })).subscribe(subscriberRule);
    source.onError(DELIBERATE_EXCEPTION);
    assertThat(subscriberRule.awaitOnError(), is(ex));
    assertEquals(1, ex.getSuppressed().length);
    assertSame(DELIBERATE_EXCEPTION, ex.getSuppressed()[0]);
}
Also used : TestSingleSubscriber(io.servicetalk.concurrent.test.internal.TestSingleSubscriber) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) Test(org.junit.jupiter.api.Test)

Example 2 with TestSingleSubscriber

use of io.servicetalk.concurrent.test.internal.TestSingleSubscriber in project servicetalk by apple.

the class RetryTest method exceptionInTerminalCallsOnError.

@Test
void exceptionInTerminalCallsOnError() {
    DeliberateException ex = new DeliberateException();
    TestSingleSubscriber<Integer> subscriberRule = new TestSingleSubscriber<>();
    source = new LegacyTestSingle<>(false, false);
    toSource(source.retry((times, cause) -> {
        throw ex;
    })).subscribe(subscriberRule);
    source.onError(DELIBERATE_EXCEPTION);
    assertThat(subscriberRule.awaitOnError(), is(ex));
    assertEquals(1, ex.getSuppressed().length);
    assertSame(DELIBERATE_EXCEPTION, ex.getSuppressed()[0]);
}
Also used : TestSingleSubscriber(io.servicetalk.concurrent.test.internal.TestSingleSubscriber) DeliberateException(io.servicetalk.concurrent.internal.DeliberateException) Test(org.junit.jupiter.api.Test)

Aggregations

DeliberateException (io.servicetalk.concurrent.internal.DeliberateException)2 TestSingleSubscriber (io.servicetalk.concurrent.test.internal.TestSingleSubscriber)2 Test (org.junit.jupiter.api.Test)2