Search in sources :

Example 1 with Response

use of feign.Response in project feign by OpenFeign.

the class JacksonJaxbCodecTest method notFoundDecodesToEmpty.

/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmpty() throws Exception {
    Response response = Response.builder().status(404).reason("NOT FOUND").headers(Collections.<String, Collection<String>>emptyMap()).build();
    assertThat((byte[]) new JacksonJaxbJsonDecoder().decode(response, byte[].class)).isEmpty();
}
Also used : Response(feign.Response) Collection(java.util.Collection) Test(org.junit.Test)

Example 2 with Response

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);
}
Also used : Response(feign.Response) Test(org.junit.Test)

Example 3 with Response

use of feign.Response in project feign by OpenFeign.

the class AbstractClientTest method postWithSpacesInPath.

@Test
public void postWithSpacesInPath() throws IOException, InterruptedException {
    server.enqueue(new MockResponse().setBody("foo"));
    TestInterface api = newBuilder().target(TestInterface.class, "http://localhost:" + server.getPort());
    Response response = api.post("current documents", "foo");
    MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("POST").hasPath("/path/current%20documents/resource").hasBody("foo");
}
Also used : Response(feign.Response) MockResponse(okhttp3.mockwebserver.MockResponse) MockResponse(okhttp3.mockwebserver.MockResponse) Test(org.junit.Test)

Example 4 with Response

use of feign.Response in project feign by OpenFeign.

the class JacksonCodecTest method notFoundDecodesToEmpty.

/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmpty() throws Exception {
    Response response = Response.builder().status(404).reason("NOT FOUND").headers(Collections.<String, Collection<String>>emptyMap()).build();
    assertThat((byte[]) new JacksonDecoder().decode(response, byte[].class)).isEmpty();
}
Also used : Response(feign.Response) Collection(java.util.Collection) Test(org.junit.Test)

Example 5 with Response

use of feign.Response in project feign by OpenFeign.

the class JAXBCodecTest method notFoundDecodesToEmpty.

/** Enabled via {@link feign.Feign.Builder#decode404()} */
@Test
public void notFoundDecodesToEmpty() throws Exception {
    Response response = Response.builder().status(404).reason("NOT FOUND").headers(Collections.<String, Collection<String>>emptyMap()).build();
    assertThat((byte[]) new JAXBDecoder(new JAXBContextFactory.Builder().build()).decode(response, byte[].class)).isEmpty();
}
Also used : Response(feign.Response) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

Response (feign.Response)169 Test (org.junit.Test)118 IOException (java.io.IOException)32 MockResponse (okhttp3.mockwebserver.MockResponse)26 KeyManagementException (org.wso2.carbon.apimgt.core.exception.KeyManagementException)22 Test (org.testng.annotations.Test)20 Collection (java.util.Collection)19 HashMap (java.util.HashMap)16 OAuth2IntrospectionResponse (org.wso2.carbon.apimgt.core.auth.dto.OAuth2IntrospectionResponse)16 ArrayList (java.util.ArrayList)15 Gson (com.google.gson.Gson)13 FeignException (feign.FeignException)13 OAuth2ServiceStubs (org.wso2.carbon.apimgt.core.auth.OAuth2ServiceStubs)13 IdentityProviderException (org.wso2.carbon.apimgt.core.exception.IdentityProviderException)13 Request (feign.Request)11 RetryableException (feign.RetryableException)11 DecodeException (feign.codec.DecodeException)10 Map (java.util.Map)10 ExpectedException (org.junit.rules.ExpectedException)10 Type (java.lang.reflect.Type)9