use of feign.Request in project feign by OpenFeign.
the class SpringContractTest method inheritance.
@Test
public void inheritance() {
final Data data = resource.getData(new Data());
assertThat(data, notNullValue());
final Request request = mockClient.verifyOne(HttpMethod.GET, "/health/generic");
assertThat(request.headers(), hasEntry("Content-Type", Arrays.asList("application/json")));
}
use of feign.Request in project feign by OpenFeign.
the class LBClient method execute.
@Override
public RibbonResponse execute(RibbonRequest request, IClientConfig configOverride) throws IOException, ClientException {
Request.Options options;
if (configOverride != null) {
options = new Request.Options(configOverride.get(CommonClientConfigKey.ConnectTimeout, connectTimeout), TimeUnit.MILLISECONDS, (configOverride.get(CommonClientConfigKey.ReadTimeout, readTimeout)), TimeUnit.MILLISECONDS, configOverride.get(CommonClientConfigKey.FollowRedirects, followRedirects));
} else {
options = new Request.Options(connectTimeout, TimeUnit.MILLISECONDS, readTimeout, TimeUnit.MILLISECONDS, true);
}
Response response = request.client().execute(request.toRequest(), options);
if (retryableStatusCodes.contains(response.status())) {
response.close();
throw new ClientException(ClientException.ErrorType.SERVER_THROTTLED);
}
return new RibbonResponse(request.getUri(), response);
}
use of feign.Request in project feign by OpenFeign.
the class JsonCodecTest method encodes.
@Test
public void encodes() {
JSONObject contributor = new JSONObject();
contributor.put("login", "radio-rogal");
contributor.put("contributions", 0);
mockClient.ok(HttpMethod.POST, "/repos/openfeign/feign/contributors", "{\"login\":\"radio-rogal\",\"contributions\":0}");
JSONObject response = github.create("openfeign", "feign", contributor);
Request request = mockClient.verifyOne(HttpMethod.POST, "/repos/openfeign/feign/contributors");
assertNotNull(request.body());
String json = new String(request.body());
assertThat(json, containsString("\"login\":\"radio-rogal\""));
assertThat(json, containsString("\"contributions\":0"));
assertEquals("radio-rogal", response.getString("login"));
assertEquals(0, response.getInt("contributions"));
}
Aggregations