Skip to content

Commit

Permalink
Fix false negative test case for AsyncFeign Retry feature (#1795)
Browse files Browse the repository at this point in the history
False negative test case is added in PR #1757

Co-authored-by: Marvin Froeder <velo@users.noreply.github.com>
  • Loading branch information
wplong11 and velo committed Oct 20, 2022
1 parent 5922b96 commit 853ae4c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions core/src/test/java/feign/AsyncFeignTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -564,39 +564,39 @@ public void throwsFeignExceptionWithoutBody() {
}

@Test
public void ensureRetryerClonesItself() throws Exception {
public void ensureRetryerClonesItself() throws Throwable {
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
server.enqueue(new MockResponse().setResponseCode(200).setBody("foo 2"));
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 3"));
server.enqueue(new MockResponse().setResponseCode(200).setBody("foo 4"));

MockRetryer retryer = new MockRetryer();

FeignTest.TestInterface api = Feign.builder()
TestInterfaceAsync api = AsyncFeign.builder()
.retryer(retryer)
.errorDecoder(new ErrorDecoder() {
@Override
public Exception decode(String methodKey, Response response) {
return new RetryableException(response.status(), "play it again sam!", HttpMethod.POST,
null, response.request());
}
}).target(FeignTest.TestInterface.class, "http://localhost:" + server.getPort());
}).target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());

api.post();
api.post(); // if retryer instance was reused, this statement will throw an exception
unwrap(api.post());
unwrap(api.post()); // if retryer instance was reused, this statement will throw an exception
assertEquals(4, server.getRequestCount());
}

@Test
public void throwsOriginalExceptionAfterFailedRetries() throws Exception {
public void throwsOriginalExceptionAfterFailedRetries() throws Throwable {
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 2"));

final String message = "the innerest";
thrown.expect(TestInterfaceException.class);
thrown.expectMessage(message);

TestInterfaceAsync api = Feign.builder()
TestInterfaceAsync api = AsyncFeign.builder()
.exceptionPropagationPolicy(UNWRAP)
.retryer(new Retryer.Default(1, 1, 2))
.errorDecoder(new ErrorDecoder() {
Expand All @@ -607,19 +607,19 @@ public Exception decode(String methodKey, Response response) {
}
}).target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());

api.post();
unwrap(api.post());
}

@Test
public void throwsRetryableExceptionIfNoUnderlyingCause() throws Exception {
public void throwsRetryableExceptionIfNoUnderlyingCause() throws Throwable {
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 1"));
server.enqueue(new MockResponse().setResponseCode(503).setBody("foo 2"));

String message = "play it again sam!";
thrown.expect(RetryableException.class);
thrown.expectMessage(message);

TestInterfaceAsync api = Feign.builder()
TestInterfaceAsync api = AsyncFeign.builder()
.exceptionPropagationPolicy(UNWRAP)
.retryer(new Retryer.Default(1, 1, 2))
.errorDecoder(new ErrorDecoder() {
Expand All @@ -630,7 +630,7 @@ public Exception decode(String methodKey, Response response) {
}
}).target(TestInterfaceAsync.class, "http://localhost:" + server.getPort());

api.post();
unwrap(api.post());
}

@SuppressWarnings("deprecation")
Expand Down

0 comments on commit 853ae4c

Please sign in to comment.