Search in sources :

Example 6 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project tutorials by eugenp.

the class RestEasyClientLiveTest method testAddMovieMultiConnection.

@Test
public void testAddMovieMultiConnection() {
    final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    final CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
    final ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
    final ResteasyClient client = new ResteasyClientBuilder().httpEngine(engine).build();
    final ResteasyWebTarget target = client.target(FULL_PATH);
    final ServicesInterface proxy = target.proxy(ServicesInterface.class);
    final Response batmanResponse = proxy.addMovie(batmanMovie);
    final Response transformerResponse = proxy.addMovie(transformerMovie);
    if (batmanResponse.getStatus() != Response.Status.CREATED.getStatusCode()) {
        System.out.println("Batman Movie creation Failed : HTTP error code : " + batmanResponse.getStatus());
    }
    if (batmanResponse.getStatus() != Response.Status.CREATED.getStatusCode()) {
        System.out.println("Batman Movie creation Failed : HTTP error code : " + batmanResponse.getStatus());
    }
    batmanResponse.close();
    transformerResponse.close();
    cm.close();
}
Also used : Response(javax.ws.rs.core.Response) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ApacheHttpClient4Engine(org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ServicesInterface(com.baeldung.client.ServicesInterface) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager) Test(org.junit.Test)

Example 7 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project tutorials by eugenp.

the class RestEasyClientLiveTest method testListAllMovies.

@Test
public void testListAllMovies() {
    final ResteasyClient client = new ResteasyClientBuilder().build();
    final ResteasyWebTarget target = client.target(FULL_PATH);
    final ServicesInterface proxy = target.proxy(ServicesInterface.class);
    Response moviesResponse = proxy.addMovie(transformerMovie);
    moviesResponse.close();
    moviesResponse = proxy.addMovie(batmanMovie);
    moviesResponse.close();
    final List<Movie> movies = proxy.listMovies();
    System.out.println(movies);
}
Also used : Response(javax.ws.rs.core.Response) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Movie(com.baeldung.model.Movie) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ServicesInterface(com.baeldung.client.ServicesInterface) Test(org.junit.Test)

Example 8 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project tutorials by eugenp.

the class RestEasyClientLiveTest method testDeleteMovie.

@Test
public void testDeleteMovie() {
    final ResteasyClient client = new ResteasyClientBuilder().build();
    final ResteasyWebTarget target = client.target(FULL_PATH);
    final ServicesInterface proxy = target.proxy(ServicesInterface.class);
    Response moviesResponse = proxy.addMovie(batmanMovie);
    moviesResponse.close();
    moviesResponse = proxy.deleteMovie(batmanMovie.getImdbId());
    if (moviesResponse.getStatus() != Response.Status.OK.getStatusCode()) {
        System.out.println(moviesResponse.readEntity(String.class));
        throw new RuntimeException("Failed : HTTP error code : " + moviesResponse.getStatus());
    }
    moviesResponse.close();
    System.out.println("Response Code: " + moviesResponse.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ServicesInterface(com.baeldung.client.ServicesInterface) Test(org.junit.Test)

Example 9 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project tutorials by eugenp.

the class RestEasyClientLiveTest method testMovieByImdbId.

@Test
public void testMovieByImdbId() {
    final String transformerImdbId = "tt0418279";
    final ResteasyClient client = new ResteasyClientBuilder().build();
    final ResteasyWebTarget target = client.target(FULL_PATH);
    final ServicesInterface proxy = target.proxy(ServicesInterface.class);
    final Response moviesResponse = proxy.addMovie(transformerMovie);
    moviesResponse.close();
    final Movie movies = proxy.movieByImdbId(transformerImdbId);
    System.out.println(movies);
}
Also used : Response(javax.ws.rs.core.Response) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Movie(com.baeldung.model.Movie) ResteasyClient(org.jboss.resteasy.client.jaxrs.ResteasyClient) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ServicesInterface(com.baeldung.client.ServicesInterface) Test(org.junit.Test)

Example 10 with ResteasyClientBuilder

use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project microservice_framework by CJSCommonPlatform.

the class CakeShopPostgresIT method before.

@Before
public void before() throws Exception {
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
    // Increase max total connection to 200
    cm.setMaxTotal(200);
    // Increase default max connection per route to 20
    cm.setDefaultMaxPerRoute(20);
    ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpClient);
    client = new ResteasyClientBuilder().httpEngine(engine).build();
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) ApacheHttpClient4Engine(org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager) Before(org.junit.Before)

Aggregations

ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)40 ResteasyClient (org.jboss.resteasy.client.jaxrs.ResteasyClient)22 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)18 Response (javax.ws.rs.core.Response)11 Test (org.junit.Test)9 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)8 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)7 ServicesInterface (com.baeldung.client.ServicesInterface)6 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)6 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)6 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)6 RequestConfig (org.apache.http.client.config.RequestConfig)5 ApacheHttpClient43Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43Engine)5 IOException (java.io.IOException)4 Client (javax.ws.rs.client.Client)4 HttpClient (org.apache.http.client.HttpClient)4 ProcessingException (javax.ws.rs.ProcessingException)3 ClientHttpEngine (org.jboss.resteasy.client.jaxrs.ClientHttpEngine)3 Movie (com.baeldung.model.Movie)2 JacksonJaxbJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)2