private static void all() {
System.out.println("-- ALL --");
System.out.println("--------------------------");
URI rootURI = UriBuilder.fromUri("http://localhost/chapter15-service-1.0/rs/book").port(8080).build();
Client client = ClientBuilder.newClient();
Response response;
System.out.println("--- GET all books in XML");
response = client.target(rootURI).request(MediaType.APPLICATION_XML).get();
System.out.println("\tStatus : " + response.getStatus());
System.out.println(response.readEntity(String.class));
System.out.println("--- POST new book");
Book book = new Book("The Hitchhiker's Guide to the Galaxy", 12.5F, "Science fiction comedy book", "1-84023-742-2", 354, false);
response = client.target(rootURI).request().post(Entity.entity(book, MediaType.APPLICATION_XML));
System.out.println("\tStatus : " + response.getStatus());
URI bookURI = response.getLocation();
System.out.println("\tLocation : " + bookURI);
book.setId(response.getLocation().toString().split("/")[6]);
System.out.println("--- GET the created book in JSon");
System.out.println(client.target(bookURI).request(MediaType.APPLICATION_JSON).get(String.class));
System.out.println("-- PUT updated book");
System.out.println("--------------------------");
book.setTitle("Updated title");
response = client.target(rootURI).request().put(Entity.entity(book, MediaType.APPLICATION_XML));
System.out.println("\tStatus : " + response.getStatus());
System.out.println("--- GET the created book in XML");
System.out.println(client.target(bookURI).request(MediaType.APPLICATION_XML).get(String.class));
System.out.println("--- DELETE the book");
response = client.target(rootURI).path(book.getId()).request().delete();
System.out.println("\tStatus : " + response.getStatus());
System.out.println("--- GET the deted book (404-Not Found)");
response = client.target(bookURI).request(MediaType.APPLICATION_XML).get();
System.out.println("\tStatus : " + response.getStatus());
}