Package javax.ws.rs.core

Examples of javax.ws.rs.core.Response.readEntity()


  @Test
  public void shouldGetCustomers() {
    Response response = client.target("http://localhost:8282/13/customer").request(MediaType.APPLICATION_XML).get();
    assertEquals(200, response.getStatus());
    assertTrue(response.hasEntity());
    Customers13 customers = response.readEntity(Customers13.class);
    assertEquals(2, customers.size());
  }

  @Test
  public void shouldGetCustomer() {
View Full Code Here


  @Test
  public void shouldGetCustomer() {
    Response response = client.target("http://localhost:8282/13/customer/1234").request().get();
    assertEquals(200, response.getStatus());
    assertTrue(response.hasEntity());
    Customer13 customer = response.readEntity(Customer13.class);
    assertEquals("jsmith@gmail.com", customer.getEmail());
    assertEquals("John", customer.getFirstName());
    assertEquals("Smith", customer.getLastName());
  }
View Full Code Here

  @Test
  public void shouldUpdateCustomer() {
    Response response = client.target("http://localhost:8282/13/customer").request().put(Entity.entity(new Customer13("John", "Smith", "jsmith@gmail.com", "1334565"), MediaType.APPLICATION_XML));
    assertEquals(200, response.getStatus());
    assertTrue(response.hasEntity());
    Customer13 customer = response.readEntity(Customer13.class);
    assertEquals("JohnUpdated", customer.getFirstName());
  }

  @Test
  public void shouldDeleteCustomer() {
View Full Code Here

    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());
View Full Code Here

  public void getGetDefaultMediaType() {
//    Response response = client.target("http://localhost:8282/15/customer/locale").request().get();
    Response response = client.target("http://localhost:8080/chapter15-service-1.0/rs/15/customer/media").request().get();
    assertEquals(200, response.getStatus());
    assertTrue(response.hasEntity());
    assertEquals("text/html", response.readEntity(String.class));
  }

  @Test
  public void shouldCreateCustomer() {
//    Response response = client.target("http://localhost:8282/15/customer/locale").request().get();
View Full Code Here

  @Test
  public void shouldGetCustomerAsPlainText() {
    Response response = client.target("http://localhost:8282/11/customer").request(MediaType.TEXT_PLAIN).get();
    assertEquals(200, response.getStatus());
    assertEquals(CUSTOMER_TEXT, response.readEntity(String.class));
  }

  @Test
  public void shouldGetCustomerAsHTML() {
    Response response = client.target("http://localhost:8282/11/customer").request(MediaType.TEXT_HTML).get();
View Full Code Here

  @Test
  public void shouldGetCustomerAsHTML() {
    Response response = client.target("http://localhost:8282/11/customer").request(MediaType.TEXT_HTML).get();
    assertEquals(200, response.getStatus());
    assertEquals(CUSTOMER_HTML, response.readEntity(String.class));
  }

  @Test
  public void shouldGetCustomerAsXML() {
    Response response = client.target("http://localhost:8282/11/customer").request(MediaType.APPLICATION_XML).get();
View Full Code Here

  @Test
  public void shouldGetCustomerAsXML() {
    Response response = client.target("http://localhost:8282/11/customer").request(MediaType.APPLICATION_XML).get();
    assertEquals(200, response.getStatus());
    assertEquals(CUSTOMER_XML, response.readEntity(String.class));
  }

  @Test
  public void shouldGetCustomerAsJSON() {
    Response response = client.target("http://localhost:8282/11/customer").request(MediaType.APPLICATION_JSON).get();
View Full Code Here

  @Test
  public void shouldGetCustomerAsJSON() {
    Response response = client.target("http://localhost:8282/11/customer").request(MediaType.APPLICATION_JSON).get();
    assertEquals(200, response.getStatus());
    assertEquals(CUSTOMER_JSON, response.readEntity(String.class));
  }
}
View Full Code Here

  @Test
  public void shouldGetCustomerAsXML() {
    Response response = client.target("http://localhost:8282/16/customer/1234").request(MediaType.APPLICATION_XML).get();
    assertEquals(200, response.getStatus());
    assertEquals(XML, response.readEntity(String.class));
  }

  @Test
  public void shouldCreateCustomerXML() {
    Response response = client.target("http://localhost:8282/16/customer").request().post(Entity.xml(new Customer16("1234", "John", "Smith")));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.