From 1b9c25e3039b8bdad8fe0b0e275861dc4101689c Mon Sep 17 00:00:00 2001 From: Donghyeon Kim Date: Wed, 12 Oct 2022 23:13:51 +0900 Subject: [PATCH] Fix false negative test case for AsyncFeign Retry feature False negative test case is added in PR #1757 --- core/src/test/java/feign/AsyncFeignTest.java | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/src/test/java/feign/AsyncFeignTest.java b/core/src/test/java/feign/AsyncFeignTest.java index 20c208888..6ccfc714d 100644 --- a/core/src/test/java/feign/AsyncFeignTest.java +++ b/core/src/test/java/feign/AsyncFeignTest.java @@ -564,7 +564,7 @@ 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")); @@ -572,7 +572,7 @@ public void ensureRetryerClonesItself() throws Exception { MockRetryer retryer = new MockRetryer(); - FeignTest.TestInterface api = Feign.builder() + TestInterfaceAsync api = AsyncFeign.builder() .retryer(retryer) .errorDecoder(new ErrorDecoder() { @Override @@ -580,15 +580,15 @@ 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")); @@ -596,7 +596,7 @@ public void throwsOriginalExceptionAfterFailedRetries() throws Exception { 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() { @@ -607,11 +607,11 @@ 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")); @@ -619,7 +619,7 @@ public void throwsRetryableExceptionIfNoUnderlyingCause() throws Exception { 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() { @@ -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")