use of feign.jaxrs.JAXRSContract in project atlasdb by palantir.
the class TimestampRemotingTest method testNotLeader.
@Test
public void testNotLeader() {
ObjectMapper mapper = new ObjectMapper();
String uri = notLeader.baseUri().toString();
TimestampService ts = Feign.builder().decoder(new JacksonDecoder(mapper)).encoder(new JacksonEncoder(mapper)).contract(new JAXRSContract()).retryer(new Retryer.Default(1, 1, 40)).target(TimestampService.class, notLeader.baseUri().toString());
ts.getFreshTimestamp();
}
use of feign.jaxrs.JAXRSContract in project atlasdb by palantir.
the class TimestampRemotingTest method testSerializing.
@Test
public void testSerializing() {
ObjectMapper mapper = new ObjectMapper();
String uri = dropwizard.baseUri().toString();
TimestampService ts = Feign.builder().decoder(new JacksonDecoder(mapper)).encoder(new JacksonEncoder(mapper)).contract(new JAXRSContract()).target(TimestampService.class, uri);
long freshTimestamp = ts.getFreshTimestamp();
TimestampRange freshTimestamps = ts.getFreshTimestamps(100);
}
use of feign.jaxrs.JAXRSContract in project feign by OpenFeign.
the class JAXRSClientTest method testConsumesMultipleWithContentTypeHeaderAndBody.
@Test
public void testConsumesMultipleWithContentTypeHeaderAndBody() throws Exception {
server.enqueue(new MockResponse().setBody("AAAAAAAA"));
final JaxRSClientTestInterfaceWithJaxRsContract api = newBuilder().contract(// use JAXRSContract
new JAXRSContract()).target(JaxRSClientTestInterfaceWithJaxRsContract.class, "http://localhost:" + server.getPort());
final Response response = api.consumesMultipleWithContentTypeHeaderAndBody("application/json;charset=utf-8", "body");
assertEquals("AAAAAAAA", Util.toString(response.body().asReader(UTF_8)));
MockWebServerAssertions.assertThat(server.takeRequest()).hasHeaders(MapEntry.entry("Content-Type", Collections.singletonList("application/json;charset=utf-8"))).hasMethod("POST");
}
use of feign.jaxrs.JAXRSContract in project feign by OpenFeign.
the class ApacheHttp5ClientTest method queryParamsAreRespectedWhenBodyIsEmpty.
@Test
public void queryParamsAreRespectedWhenBodyIsEmpty() throws InterruptedException {
final HttpClient httpClient = HttpClientBuilder.create().build();
final JaxRsTestInterface testInterface = Feign.builder().contract(new JAXRSContract()).client(new ApacheHttp5Client(httpClient)).target(JaxRsTestInterface.class, "http://localhost:" + server.getPort());
server.enqueue(new MockResponse().setBody("foo"));
server.enqueue(new MockResponse().setBody("foo"));
assertEquals("foo", testInterface.withBody("foo", "bar"));
final RecordedRequest request1 = server.takeRequest();
assertEquals("/withBody?foo=foo", request1.getPath());
assertEquals("bar", request1.getBody().readString(StandardCharsets.UTF_8));
assertEquals("foo", testInterface.withoutBody("foo"));
final RecordedRequest request2 = server.takeRequest();
assertEquals("/withoutBody?foo=foo", request2.getPath());
assertEquals("", request2.getBody().readString(StandardCharsets.UTF_8));
}
use of feign.jaxrs.JAXRSContract in project feign by OpenFeign.
the class ApacheHttpClientTest method queryParamsAreRespectedWhenBodyIsEmpty.
@Test
public void queryParamsAreRespectedWhenBodyIsEmpty() throws InterruptedException {
final HttpClient httpClient = HttpClientBuilder.create().build();
final JaxRsTestInterface testInterface = Feign.builder().contract(new JAXRSContract()).client(new ApacheHttpClient(httpClient)).target(JaxRsTestInterface.class, "http://localhost:" + server.getPort());
server.enqueue(new MockResponse().setBody("foo"));
server.enqueue(new MockResponse().setBody("foo"));
assertEquals("foo", testInterface.withBody("foo", "bar"));
final RecordedRequest request1 = server.takeRequest();
assertEquals("/withBody?foo=foo", request1.getPath());
assertEquals("bar", request1.getBody().readString(StandardCharsets.UTF_8));
assertEquals("foo", testInterface.withoutBody("foo"));
final RecordedRequest request2 = server.takeRequest();
assertEquals("/withoutBody?foo=foo", request2.getPath());
assertEquals("", request2.getBody().readString(StandardCharsets.UTF_8));
}
Aggregations