Package org.apache.cxf.jaxrs.client

Examples of org.apache.cxf.jaxrs.client.WebClient.accept()


    @Test
    public void testGetBookByHeaderPerRequestContextFault() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore2/bookheaders";
        WebClient wc = WebClient.create(address);
        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));
    }
View Full Code Here


    }
   
    private void doTestGetBookWithResourceContext(String address) throws Exception {
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000);
        wc.accept("application/xml");
        wc.query("bookid", "12345");
        wc.query("bookname", "bookcontext");
        Book2 book = wc.get(Book2.class);
        assertEquals(12345L, book.getId());
        assertEquals("bookcontext", book.getName());
View Full Code Here

    @Test
    public void testGetCustomBookResponse() {
        String address = "http://localhost:" + PORT + "/bookstore/customresponse";
        WebClient wc = WebClient.create(address);
        Response r = wc.accept("application/xml").get(Response.class);
        Book book = r.readEntity(Book.class);
        assertEquals(222L, book.getId());
        assertEquals("OK", r.getHeaderString("customresponse"));
    }
   
View Full Code Here

   
    @Test
    public void testGetCustomBookBufferedResponse() {
        String address = "http://localhost:" + PORT + "/bookstore/customresponse";
        WebClient wc = WebClient.create(address);
        Response r = wc.accept("application/xml").get(Response.class);
       
        r.bufferEntity();
       
        String bookStr = r.readEntity(String.class);
        assertTrue(bookStr.endsWith("</Book>"));
View Full Code Here

   
    @Test
    public void testGetCustomBookText() {
        String address = "http://localhost:" + PORT + "/bookstore/customtext";
        WebClient wc = WebClient.create(address);
        Response r = wc.accept("text/custom").get();
        String name = r.readEntity(String.class);
        assertEquals("Good book", name);
        assertEquals("text/custom;charset=us-ascii", r.getMediaType().toString());
    }   
   
View Full Code Here

    public void testGetBookNameAsByteArray() {
        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);
View Full Code Here

    public void testGetIntroChapterFromSelectedBook2() {
        String address = "http://localhost:" + PORT + "/bookstore/";
        WebClient wc = WebClient.create(address);
        wc.path("books[id=le=123]");
        wc.path("chapter");
        wc.accept("application/xml");
        Chapter chapter = wc.get(Chapter.class);
        assertEquals("chapter 1", chapter.getTitle());
    }
   
    private void doTestGetChapterFromSelectedBook(String address) {
View Full Code Here

    private void doTestGetChapterFromSelectedBook(String address) {
       
        WebClient wc =
            WebClient.create(address);
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000);
        wc.accept("application/xml");
        Chapter chapter = wc.get(Chapter.class);
        assertEquals("chapter 1", chapter.getTitle());   
    }
   
    @Test
View Full Code Here

   
    @Test
    public void testWithComplexPath() {
        WebClient wc =
            WebClient.create("http://localhost:" + PORT + "/bookstore/allCharsButA-B/:@!$&'()*+,;=-._~");
        wc.accept("application/xml");
        Book book = wc.get(Book.class);
        assertEquals("Encoded Path", book.getName());
    }
   
    @Test
View Full Code Here

   
    @Test
    public void testMalformedAcceptType() {
        WebClient wc =
            WebClient.create("http://localhost:" + PORT + "/bookstore/books/123");
        wc.accept("application");
        Response r = wc.get();
        assertEquals(406, r.getStatus());
    }
   
    @Test
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.