|
|
|
@ -29,6 +29,7 @@ import feign.Response;
@@ -29,6 +29,7 @@ import feign.Response;
|
|
|
|
|
|
|
|
|
|
import static feign.Util.RETRY_AFTER; |
|
|
|
|
import static feign.Util.UTF_8; |
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
|
|
public class DefaultErrorDecoderTest { |
|
|
|
|
|
|
|
|
@ -54,13 +55,21 @@ public class DefaultErrorDecoderTest {
@@ -54,13 +55,21 @@ public class DefaultErrorDecoderTest {
|
|
|
|
|
thrown.expect(FeignException.class); |
|
|
|
|
thrown.expectMessage("status 500 reading Service#foo(); content:\nhello world"); |
|
|
|
|
|
|
|
|
|
Response |
|
|
|
|
response = |
|
|
|
|
Response.create(500, "Internal server error", headers, "hello world", UTF_8); |
|
|
|
|
Response response = Response.create(500, "Internal server error", headers, "hello world", UTF_8); |
|
|
|
|
|
|
|
|
|
throw errorDecoder.decode("Service#foo()", response); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testFeignExceptionIncludesStatus() throws Throwable { |
|
|
|
|
Response response = Response.create(400, "Bad request", headers, (byte[]) null); |
|
|
|
|
|
|
|
|
|
Exception exception = errorDecoder.decode("Service#foo()", response); |
|
|
|
|
|
|
|
|
|
assertThat(exception).isInstanceOf(FeignException.class); |
|
|
|
|
assertThat(((FeignException) exception).status()).isEqualTo(400); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void retryAfterHeaderThrowsRetryableException() throws Throwable { |
|
|
|
|
thrown.expect(FeignException.class); |
|
|
|
|