use of com.baeldung.client.ServicesInterface 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();
}
use of com.baeldung.client.ServicesInterface 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);
}
use of com.baeldung.client.ServicesInterface 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());
}
use of com.baeldung.client.ServicesInterface 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);
}
use of com.baeldung.client.ServicesInterface in project tutorials by eugenp.
the class RestEasyClientLiveTest method testAddMovie.
@Test
public void testAddMovie() {
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.addMovie(transformerMovie);
if (moviesResponse.getStatus() != Response.Status.CREATED.getStatusCode()) {
System.out.println("Failed : HTTP error code : " + moviesResponse.getStatus());
}
moviesResponse.close();
System.out.println("Response Code: " + moviesResponse.getStatus());
}
Aggregations