Search in sources :

Example 16 with Person

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);
}
Also used : HttpClientResponse(io.reactivex.netty.protocol.http.client.HttpClientResponse) ByteBuf(io.netty.buffer.ByteBuf) Person(com.netflix.ribbon.test.resources.EmbeddedResources.Person) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Aggregations

Person (com.netflix.ribbon.test.resources.EmbeddedResources.Person)16 ByteBuf (io.netty.buffer.ByteBuf)16 Test (org.junit.Test)16 MockWebServer (com.google.mockwebserver.MockWebServer)12 Server (com.netflix.loadbalancer.Server)12 HttpServer (com.sun.net.httpserver.HttpServer)12 IClientConfig (com.netflix.client.config.IClientConfig)9 AvailabilityFilteringRule (com.netflix.loadbalancer.AvailabilityFilteringRule)9 BaseLoadBalancer (com.netflix.loadbalancer.BaseLoadBalancer)9 DummyPing (com.netflix.loadbalancer.DummyPing)9 ServerStats (com.netflix.loadbalancer.ServerStats)8 HttpClientListener (io.reactivex.netty.servo.http.HttpClientListener)7 HttpClientResponse (io.reactivex.netty.protocol.http.client.HttpClientResponse)5 MockResponse (com.google.mockwebserver.MockResponse)4 RequestSpecificRetryHandler (com.netflix.client.RequestSpecificRetryHandler)3 RetryHandler (com.netflix.client.RetryHandler)3 ClientException (com.netflix.client.ClientException)2 HttpClientConfig (io.reactivex.netty.protocol.http.client.HttpClient.HttpClientConfig)1 ServerSentEvent (io.reactivex.netty.protocol.text.sse.ServerSentEvent)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1