/**
* Test demonstrates the usage of {@link com.rzagorski.retrofitrx2errorhandler.backoff.strategies.Simple}
* backoff strategy. The server responds with 500 server error every time. The backoff strategy
* is executed and after {@link com.rzagorski.retrofitrx2errorhandler.backoff.strategies.Simple.Builder#setMaxRetries(int)}
* is run out, the appropriate error is passed to client.
* 4 times 10 second timeout.
* <br>
* Test created by Robert Zagorski on 19.10.2016
*/
@Test
public void testBackoffCompletes1() throws Exception {
mockWebServer.setDispatcher(new Dispatcher() {
@Override
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
return new MockResponse().setResponseCode(500);
}
});
RxCallAdapter rxCallAdapter = new RxCallAdapter.Builder()
.addBackoffStrategy(Simple.init()
.addHttpCode(500)
.setMaxRetries(300).build())
.build();
GitHub github = createRetrofitInstance(mockWebServer.url("/").toString(),
new RxErrorHandingFactory(rxCallAdapter));
Observable observable = github.repos("square");
TestObserver testObserver = observable.test();
testObserver.awaitTerminalEvent();
testObserver.assertError(HttpException.class);
}
SimpleBackoffTest.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:RetrofitRxErrorHandler
作者:
评论列表
文章目录