Package org.apache.cxf.jaxrs.client

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


        WebClient wc = createWebClient(address, new SamlFormOutInterceptor(),
                                       formProvider, true);
       
        wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML);
        try {
            Book book = wc.post(new Form().set("name", "CXF").set("id", 125),
                                Book.class);               
            assertEquals(125L, book.getId());
        } catch (WebApplicationException ex) {
            fail(ex.getMessage());
        } catch (ClientException ex) {
View Full Code Here


        WebClient wc = createWebClientForExistingToken(address, new SamlFormOutInterceptor(),
                                       formProvider);
       
        wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML);
        try {
            Book book = wc.post(new Form().set("name", "CXF").set("id", 125),
                                Book.class);               
            assertEquals(125L, book.getId());
        } catch (WebApplicationException ex) {
            fail(ex.getMessage());
        } catch (ClientException ex) {
View Full Code Here

        }
               
        WebClient.getConfig(wc).getOutInterceptors().add(xmlSig);
        wc.type(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML);
        try {
            Book book = wc.post(new Book("CXF", 125L), Book.class);               
            assertEquals(125L, book.getId());
        } catch (WebApplicationException ex) {
            fail(ex.getMessage());
        } catch (ClientException ex) {
            if (ex.getCause() != null && ex.getCause().getMessage() != null) {
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

            };
        GenericType<List<Book>> genericResponseType =
            new GenericType<List<Book>>() {
            };
       
        List<Book> books2 = wc.post(genericCollectionEntity, genericResponseType);
        assertNotNull(books2);
        assertNotSame(books, books2);
        assertEquals(2, books2.size());
        Book b11 = books.get(0);
        assertEquals(123L, b11.getId());
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 testEmptyPostBytes() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/emptypost");
        Response response = wc.post(new byte[]{});
        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().getHeaderString("CustomHeader"));
    }
   
    @Test
View Full Code Here

    public void testPostEmptyFormAsInStream() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/emptyform";
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.empty.request", true);
        wc.type(MediaType.APPLICATION_FORM_URLENCODED);
        Response r = wc.post(new ByteArrayInputStream("".getBytes()));
        assertEquals("empty form", r.readEntity(String.class));
    }
   
    @Test
    public void testGetBookDescriptionHttpResponse() throws Exception {
View Full Code Here

    @Test
    public void testUseMapperOnBus() {
        String address = "http://localhost:" + PORT + "/bookstore/mapperonbus";
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
        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));
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.