@Test
public void testRetryOnError() throws Exception {

    Func1<Observable<? extends Throwable>, Observable<?>> retryFun = builder.buildExponentialBackoff();
    observableOf("A", new IOException("Error1"), "B", new IOException("Error2"), "C")
            .retryWhen(retryFun, testScheduler)
            .subscribe(testSubscriber);
    // Expect first item
    testScheduler.triggerActions();
    assertThat(testSubscriber.getLatestItem()).isEqualTo("A");
    // Expect second item
    testScheduler.advanceTimeBy(RETRY_DELAY_SEC, TimeUnit.SECONDS);
    assertThat(testSubscriber.getLatestItem()).isEqualTo("B");
    // Expect third item
    testScheduler.advanceTimeBy(2 * RETRY_DELAY_SEC, TimeUnit.SECONDS);
    assertThat(testSubscriber.getLatestItem()).isEqualTo("C");
    assertThat(testSubscriber.isUnsubscribed());
}