Examples of readEntity()


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

        String address = "http://localhost:" + PORT + "/bookstore/booknames/123";
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000);
       
        Response r = wc.accept("application/bar").get();
        String name = r.readEntity(String.class);
        assertEquals("CXF in Action", name);
        String lengthStr = r.getHeaderString(HttpHeaders.CONTENT_LENGTH);
        assertNotNull(lengthStr);
        long length = Long.valueOf(lengthStr);
        assertEquals(name.length(), length);
View Full Code Here

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

        Response r = wc.post(null);
        assertEquals(500, r.getStatus());
        MediaType mt = r.getMediaType();
        assertEquals("text/plain;charset=utf-8", mt.toString().toLowerCase());
        assertEquals("the-mapper", r.getHeaderString("BusMapper"));
        assertEquals("BusMapperException", r.readEntity(String.class));
    }
   
    @Test
    public void testUseParamBeanWebClient() {
        String address = "http://localhost:" + PORT + "/bookstore/beanparam";
View Full Code Here

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

    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

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

    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

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

    public void testGetBookFromResponseWithWebClientAndReader() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/genericresponse/123";
        WebClient wc = WebClient.create(address);
        Response r = wc.accept("application/xml").get();
        assertEquals(200, r.getStatus());
        Book book = r.readEntity(Book.class);
        assertEquals(123L, book.getId());
    }
   
    @Test
    public void testGetBookFromResponseWithWebClient() throws Exception {
View Full Code Here

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

    public void testGetBookFromResponseWithWebClient() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/genericresponse/123";
        WebClient wc = WebClient.create(address);
        Response r = wc.accept("application/xml").get();
        assertEquals(200, r.getStatus());
        Book book = r.readEntity(Book.class);
        assertEquals(123L, book.getId());
    }
   
    @Test
    public void testUpdateWithProxy() throws Exception {
View Full Code Here

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

        WebClient wc = WebClient.create(address);
        wc.accept("application/xml");
        wc.header("BOOK", "2", "3");
        Response r = wc.get();
        assertEquals(400, r.getStatus());
        assertEquals("Param setter: 3 header values are required", r.readEntity(String.class));
    }
   
    @Test
    public void testGetBookByHeaderPerRequestConstructorFault() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore2/bookheaders";
View Full Code Here

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

        WebClient wc = WebClient.create(address);
        wc.accept("application/xml");
        wc.header("BOOK", "1", "2", "4");
        Response r = wc.get();
        assertEquals(400, r.getStatus());
        assertEquals("Constructor: Header value 3 is required", r.readEntity(String.class));
    }
   
    @Test
    public void testGetBookByHeaderPerRequestContextFault() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore2/bookheaders";
View Full Code Here

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

        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000);
        wc.accept("application/xml");
        wc.header("BOOK", "1", "3", "4");
        Response r = wc.get();
        assertEquals(400, r.getStatus());
        assertEquals("Context setter: unexpected header value", r.readEntity(String.class));
    }
   
    @Test
    public void testGetBookByHeaderDefault() throws Exception {
        getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/bookheaders2",
View Full Code Here

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

    Response response = null;

    try {
      response = databaseTestClient.getNumberOfEntities();
      if ( response.getStatus() == Response.Status.OK.getStatusCode() ) {
        return response.readEntity( EntityCountResponse.class ).getCount();
      }
      else {
        GenericResponse responseEntity = response.readEntity( GenericResponse.class );
        throw logger.unableToRetrieveTheNumberOfEntities( response.getStatus(), responseEntity.getError(), responseEntity.getReason() );
      }
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.