use of com.netflix.ribbon.test.resources.EmbeddedResources.Person in project ribbon by Netflix.
the class NettyClientTest method testPostWithByteBuf.
@Test
public void testPostWithByteBuf() throws Exception {
Person myPerson = new Person("netty", 5);
ObjectMapper mapper = new ObjectMapper();
byte[] raw = mapper.writeValueAsBytes(myPerson);
ByteBuf buffer = Unpooled.copiedBuffer(raw);
HttpClientRequest<ByteBuf> request = HttpClientRequest.createPost(SERVICE_URI + "testAsync/person").withHeader("Content-type", "application/json").withHeader("Content-length", String.valueOf(raw.length)).withContent(buffer);
LoadBalancingHttpClient<ByteBuf, ByteBuf> observableClient = RibbonTransport.newHttpClient(DefaultClientConfigImpl.getClientConfigWithDefaultValues().set(CommonClientConfigKey.ReadTimeout, 10000));
Observable<HttpClientResponse<ByteBuf>> response = observableClient.submit(request);
Person person = getPersonObservable(response).toBlocking().single();
assertEquals(myPerson, person);
}
Aggregations