Package org.apache.cxf.jaxrs.client

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


        client.path("/bookstore/books").accept(MediaType.APPLICATION_XML_TYPE)
            .type(MediaType.APPLICATION_XML_TYPE);
        Book b = new Book();
        b.setId(124);
        b.setName("CXF in Action - 2");
        Book b2 = client.post(b, Book.class);
        assertNotSame(b, b2);
        assertEquals(124, b2.getId());
        assertEquals("CXF in Action - 2", b2.getName());
    }
   
View Full Code Here


       
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/post401";
        WebClient wc = WebClient.create(endpointAddress);
        WebClient.getConfig(wc).getHttpConduit().getClient().setAllowChunking(false);
        Response r = wc.post(null);
        assertEquals(401, r.getStatus());
        assertEquals("This is 401", getStringFromInputStream((InputStream)r.getEntity()));
    }

    @Test
View Full Code Here

    @Test
    public void testEmptyPost() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/emptypost");
        Response response = wc.post(null);
        assertEquals(204, response.getStatus());
    }
   
    @Test
    public void testEmptyPut() throws Exception {
View Full Code Here

        books.add(b2);
        GenericEntity<List<Book>> genericCollectionEntity =
            new GenericEntity<List<Book>>(books) {
            };
       
        Book book = wc.post(genericCollectionEntity, Book.class);
        assertEquals(200, wc.getResponse().getStatus());
        assertNotSame(b1, book);
        assertEquals(b1.getName(), book.getName());
    }
   
View Full Code Here

    @Test
    public void testEmptyPost() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/emptypost");
        Response response = wc.post(null);
        assertEquals(204, response.getStatus());
        assertNull(response.getMetadata().getFirst("Content-Type"));
    }
   
    @Test
View Full Code Here

   
    @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().getMetadata().getFirst("CustomHeader").toString());
    }
   
    @Test
View Full Code Here

       
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/post401";
        WebClient wc = WebClient.create(endpointAddress);
        WebClient.getConfig(wc).getHttpConduit().getClient().setAllowChunking(false);
        Response r = wc.post(null);
        assertEquals(401, r.getStatus());
        assertEquals("This is 401", getStringFromInputStream((InputStream)r.getEntity()));
    }

    @Test
View Full Code Here

    @Test
    public void testEmptyPost() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/emptypost");
        Response response = wc.post(null);
        assertEquals(204, response.getStatus());
        assertNull(response.getMetadata().getFirst("Content-Type"));
    }
   
    @Test
View Full Code Here

   
    @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().getMetadata().getFirst("CustomHeader").toString());
    }
   
    @Test
View Full Code Here

       
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/post401";
        WebClient wc = WebClient.create(endpointAddress);
        WebClient.getConfig(wc).getHttpConduit().getClient().setAllowChunking(false);
        Response r = wc.post(null);
        assertEquals(401, r.getStatus());
        assertEquals("This is 401", getStringFromInputStream((InputStream)r.getEntity()));
    }

    @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.