Package org.apache.cxf.jaxrs.client

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


   
    @Test
    public void testUploadFileWithSemicolonName() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/books/file/semicolon";
        WebClient client = WebClient.create(address);
        client.type("multipart/form-data").accept("text/plain");
       
        ContentDisposition cd = new ContentDisposition("attachment;name=\"a\";filename=\"a;txt\"");
        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
        headers.putSingle("Content-Disposition", cd.toString());
        Attachment att = new Attachment(new ByteArrayInputStream("file name with semicolon".getBytes()),
View Full Code Here


        String address = "http://localhost:" + PORT + "/bookstore/books/formimage2";
        WebClient client = WebClient.create(address);
        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/form-data").accept("multipart/form-data");
       
        MultipartBody body2 = client.post(file, MultipartBody.class);
        InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
        byte[] image1 = IOUtils.readBytesFromStream(
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
View Full Code Here

   
    @Test
    public void testGetBookSubresourceWebClientParamExtensions() throws Exception {
       
        WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
        client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
        Book bean = new Book("CXF Rocks", 139L);
        Form form = new Form();
        form.set("name", "CXF Rocks").set("id", Long.valueOf(139L));
        Book b = readBook((InputStream)client.matrix("", bean).query("", bean).form(form).getEntity());
View Full Code Here

   
    @Test
    public void testGetBookSubresourceWebClientProxyBean() throws Exception {
       
        WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE)
            .accept(MediaType.APPLICATION_XML_TYPE, MediaType.TEXT_XML_TYPE);
        BookStoreJaxrsJaxws proxy =
            JAXRSClientFactory.fromClient(client, BookStoreJaxrsJaxws.class, true);
       
        doTestSubresource(proxy);
View Full Code Here

    @Test
    public void testGetBookSubresourceWebClientProxy2() throws Exception {
       
        WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest/bookstore")
            .path("/books/378");
        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
        BookSubresource proxy = JAXRSClientFactory.fromClient(client, BookSubresource.class);
       
        Book b = proxy.getTheBook2("CXF ", "in ", "Acti", "on ", "- 3", "7", "8");
        assertEquals(378, b.getId());
        assertEquals("CXF in Action - 378", b.getName());
View Full Code Here

   
    @Test
    public void testRetrieveBookCustomMethodAsyncSync() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/retrieve";
        WebClient wc = WebClient.create(address);
        wc.type("application/xml").accept("application/xml");
        WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit", true);
        Book book = wc.invoke("RETRIEVE", new Book("Retrieve", 123L), Book.class);
        assertEquals("Retrieve", book.getName());
    }
   
View Full Code Here

   
    @Test
    public void testDeleteWithBody() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/deletebody";
        WebClient wc = WebClient.create(address);
        wc.type("application/xml").accept("application/xml");
        WebClient.getConfig(wc).getRequestContext().put("use.async.http.conduit", true);
        Book book = wc.invoke("DELETE", new Book("Delete", 123L), Book.class);
        assertEquals("Delete", book.getName());
    }
   
View Full Code Here

        props.put(FIStaxOutInterceptor.FI_ENABLED, Boolean.TRUE);
        bean.setProperties(props);
       
        WebClient client = bean.createWebClient();
        Book b = new Book("CXF", 1L);
        Book b2 = client.type("application/fastinfoset").accept("application/fastinfoset")
            .post(b, Book.class);
        assertEquals(b2.getName(), b.getName());
        assertEquals(b2.getId(), b.getId());
    }
   
View Full Code Here

   
    @Test
    public void testGetBookSubresourceWebClientParamExtensions() throws Exception {
       
        WebClient client = WebClient.create("http://localhost:9092/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
        client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
        Book bean = new Book("CXF Rocks", 139L);
        Book b = client.matrix("", bean).query("", bean).get(Book.class);
        assertEquals(139, b.getId());
        assertEquals("CXF Rocks", b.getName());
View Full Code Here

   
    @Test
    public void testGetBookSubresourceWebClientProxyBean() throws Exception {
       
        WebClient client = WebClient.create("http://localhost:9092/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE)
            .accept(MediaType.APPLICATION_XML_TYPE, MediaType.TEXT_XML_TYPE);
        BookStoreJaxrsJaxws proxy =
            JAXRSClientFactory.fromClient(client, BookStoreJaxrsJaxws.class, true);
       
        doTestSubresource(proxy);
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.