use of feign.Response in project feign by OpenFeign.
the class DefaultDecoderTest method testDecodesToByteArray.
@Test
public void testDecodesToByteArray() throws Exception {
Response response = knownResponse();
Object decodedObject = decoder.decode(response, byte[].class);
assertEquals(byte[].class, decodedObject.getClass());
assertEquals("response body", new String((byte[]) decodedObject, UTF_8));
}
use of feign.Response in project feign by OpenFeign.
the class DefaultErrorDecoderTest method throwsFeignExceptionIncludingBody.
@Test
public void throwsFeignExceptionIncludingBody() throws Throwable {
thrown.expect(FeignException.class);
thrown.expectMessage("status 500 reading Service#foo(); content:\nhello world");
Response response = Response.builder().status(500).reason("Internal server error").headers(headers).body("hello world", UTF_8).build();
throw errorDecoder.decode("Service#foo()", response);
}
use of feign.Response in project feign by OpenFeign.
the class DefaultErrorDecoderTest method retryAfterHeaderThrowsRetryableException.
@Test
public void retryAfterHeaderThrowsRetryableException() throws Throwable {
thrown.expect(FeignException.class);
thrown.expectMessage("status 503 reading Service#foo()");
headers.put(RETRY_AFTER, Arrays.asList("Sat, 1 Jan 2000 00:00:00 GMT"));
Response response = Response.builder().status(503).reason("Service Unavailable").headers(headers).build();
throw errorDecoder.decode("Service#foo()", response);
}
use of feign.Response in project feign by OpenFeign.
the class AbstractClientTest method testContentTypeWithoutCharset.
@Test
public void testContentTypeWithoutCharset() throws Exception {
server.enqueue(new MockResponse().setBody("AAAAAAAA"));
TestInterface api = newBuilder().target(TestInterface.class, "http://localhost:" + server.getPort());
Response response = api.postWithContentType("foo", "text/plain");
// Response length should not be null
assertEquals("AAAAAAAA", Util.toString(response.body().asReader()));
}
use of feign.Response in project feign by OpenFeign.
the class AbstractClientTest method reasonPhraseIsOptional.
@Test
public void reasonPhraseIsOptional() throws IOException, InterruptedException {
server.enqueue(new MockResponse().setStatus("HTTP/1.1 " + 200));
TestInterface api = newBuilder().target(TestInterface.class, "http://localhost:" + server.getPort());
Response response = api.post("foo");
assertThat(response.status()).isEqualTo(200);
assertThat(response.reason()).isNullOrEmpty();
}
Aggregations