Package javax.ws.rs.core

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


    assertEquals(200, response.getStatus());
    assertTrue(response.hasEntity());

    System.out.println("########## " + response.getEntity());

    book = response.readEntity(Book04.class);
    assertEquals("The Hitchhiker's Guide to the Galaxy", book.getTitle());
    assertEquals("Science fiction comedy book", book.getDescription());
  }
}
View Full Code Here


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


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

  @Test
  public void shouldEchoUserAgentWithReponse() {
    Response response = client.target("http://localhost:8282/07/customer/userAgentRep").request().get();
    assertEquals(200, response.getStatus());
    assertTrue(response.readEntity(String.class).startsWith("Jersey/2."));
  }
}
View Full Code Here

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    Invocation.Builder builder = target.request(MediaType.TEXT_PLAIN);
    Response response = builder.get();
    String entity = response.readEntity(String.class);

    assertEquals("H2G2", entity);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertEquals("H2G2 is 4 characters", 4, entity.length());
  }
View Full Code Here

    Client client = ClientBuilder.newClient();
    WebTarget target = client.target("http://localhost:8282/03/book");
    Invocation invocation = target.request(MediaType.TEXT_PLAIN).buildGet();
    Response response = invocation.invoke();
    String entity = response.readEntity(String.class);

    assertEquals("H2G2", entity);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertEquals("H2G2 is 4 characters", 4, entity.length());
  }
View Full Code Here

  }

  @Test
  public void shouldCheckForH2G2Entity() {
    Response response = ClientBuilder.newClient().target("http://localhost:8282/03/book").request().get();
    assertEquals("H2G2", response.readEntity(String.class));
  }

  @Test
  public void shouldCheckForWrongMediaType() {
    Response response = ClientBuilder.newClient().target("http://localhost:8282/03/book").request(MediaType.APPLICATION_OCTET_STREAM).get();
View Full Code Here

  @Test
  public void shouldCheckForH2G2WithResponse() {
    Response response = client.target(UriBuilder.fromUri(uri).path("03/book").build()).request("text/plain").get();
    assertEquals(200, response.getStatus());
    assertTrue(response.hasEntity());
    assertTrue("H2G2".equals(response.readEntity(String.class)));
  }

  @Test
  public void shouldCheckForApplicationWadl() {
    assertTrue(ClientBuilder.newClient().target(uri).path("application.wadl").request(MediaTypes.WADL).get(String.class).length() > 0);
View Full Code Here

            Exception ex = clientExceptionMapper.fromResponse(response);
            if (ex != null) {
                throw (RuntimeException) ex;
            }
        }
        return response.readEntity(UserTO.class);
    }

    @SuppressWarnings("unchecked")
    protected <T extends AbstractSchemaTO> T createSchema(final AttributableType kind,
            final SchemaType type, final T schemaTO) {
View Full Code Here

    public void testGetBookFromResponseWithProxyAndReader() throws Exception {
        BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT,
                                                 BookStore.class);
        Response r = bs.getGenericResponseBook("123");
        assertEquals(200, r.getStatus());
        Book book = r.readEntity(Book.class);
        assertEquals(123L, book.getId());
    }
   
    @Test
    public void testGetBookFromResponseWithProxy() throws Exception {
View Full Code Here

    public void testGetBookFromResponseWithProxy() throws Exception {
        BookStore bs = JAXRSClientFactory.create("http://localhost:" + PORT,
                                                 BookStore.class);
        Response r = bs.getGenericResponseBook("123");
        assertEquals(200, r.getStatus());
        Book book = r.readEntity(Book.class);
        assertEquals(123L, book.getId());
    }
   
    @Test
    public void testGetBookFromResponseWithWebClientAndReader() throws Exception {
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.