use of feign.Response in project feign by OpenFeign.
the class WhatShouldWeCacheBenchmarks method setup.
@Setup
public void setup() {
feignContract = new Contract.Default();
cachedContact = new Contract() {
private final List<MethodMetadata> cached = new Default().parseAndValidatateMetadata(FeignTestInterface.class);
public List<MethodMetadata> parseAndValidatateMetadata(Class<?> declaring) {
return cached;
}
};
fakeClient = new Client() {
public Response execute(Request request, Request.Options options) throws IOException {
Map<String, Collection<String>> headers = new LinkedHashMap<String, Collection<String>>();
return Response.create(200, "ok", headers, (byte[]) null);
}
};
cachedFakeFeign = Feign.builder().client(fakeClient).build();
cachedFakeApi = cachedFakeFeign.newInstance(new HardCodedTarget<FeignTestInterface>(FeignTestInterface.class, "http://localhost"));
}
use of feign.Response in project feign by OpenFeign.
the class LBClient method execute.
@Override
public RibbonResponse execute(RibbonRequest request, IClientConfig configOverride) throws IOException {
Request.Options options;
if (configOverride != null) {
options = new Request.Options(configOverride.get(CommonClientConfigKey.ConnectTimeout, connectTimeout), (configOverride.get(CommonClientConfigKey.ReadTimeout, readTimeout)));
} else {
options = new Request.Options(connectTimeout, readTimeout);
}
Response response = request.client().execute(request.toRequest(), options);
return new RibbonResponse(request.getUri(), response);
}
use of feign.Response in project feign by OpenFeign.
the class SAXDecoderTest method nullBodyDecodesToNull.
@Test
public void nullBodyDecodesToNull() throws Exception {
Response response = Response.builder().status(204).reason("OK").headers(Collections.<String, Collection<String>>emptyMap()).build();
assertNull(decoder.decode(response, String.class));
}
use of feign.Response in project feign by OpenFeign.
the class SAXDecoderTest 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[]) decoder.decode(response, byte[].class)).isEmpty();
}
Aggregations