Package org.apache.cxf.jaxrs.client

Examples of org.apache.cxf.jaxrs.client.WebClient


    }
   
    @Test
    public void testGetHeadBook123WebClient2() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/getheadbook/";
        WebClient client = WebClient.create(address);
        Book b = client.get(Book.class);
        assertEquals(b.getId(), 123L);
    }
View Full Code Here


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

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

   
    @Test
    public void testSearchBook123WithWebClient() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/books/search";
                         
        WebClient client = WebClient.create(address);
        Book b = client.query("_s", "name==CXF*;id=ge=123;id=lt=124").get(Book.class);
        assertEquals(b.getId(), 123L);
       
    }
View Full Code Here

    @Test
    public void testGetSearchBookSQL() throws Exception {
        String address = "http://localhost:" + PORT
            + "/bookstore/books/querycontext/id=ge=123";
                         
        WebClient client = WebClient.create(address);
        client.accept("text/plain");
        String sql = client.get(String.class);
        assertEquals("SELECT * FROM books WHERE id >= '123'", sql);
    }
View Full Code Here

                               "application/xml", 200);
    }
   
    @Test
    public void testGetBookSimple222() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/simplebooks/222");
        Book book = wc.get(Book.class);
        assertEquals(222L, book.getId());
    }
View Full Code Here

        assertEquals(222L, book.getId());
    }
   
    @Test
    public void testGetBookLowCaseHeader() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/booksecho3");
        wc.type("text/plain").accept("text/plain").header("CustomHeader", "custom");
        String name = wc.post("book", String.class);
        assertEquals("book", name);
        assertEquals("custom", wc.getResponse().getHeaderString("CustomHeader"));
    }
View Full Code Here

        assertEquals("custom", wc.getResponse().getHeaderString("CustomHeader"));
    }
   
    @Test
    public void testGetBookSimple() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/simplebooks/simple");
        Book book = wc.get(Book.class);
        assertEquals(444L, book.getId());
    }
View Full Code Here

    public void testEmptyJAXB() {
        doTestEmptyResponse("application/xml");
    }
   
    private void doTestEmptyResponse(String mt) {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/emptybook");
        WebClient.getConfig(wc).getInInterceptors().add(new ReplaceStatusInterceptor());
        wc.accept(mt);
        wc.get(Book.class);
    }
View Full Code Here

        assertNull(store.getEmptyBookNullable());
    }
   
    @Test
    public void testDropJSONRootDynamically() {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/dropjsonroot");
        wc.accept("application/json");
        String response = wc.get(String.class);
        // with root: {"Book":{"id":123,"name":"CXF in Action"}}
        assertEquals("{\"id\":123,\"name\":\"CXF in Action\"}", response);
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.client.WebClient

Copyright © 2018 www.massapicom. 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.