Package org.apache.cxf.jaxrs.client

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


    public void testGetCollectionOfBooks() throws Exception {
       
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/collections";
        WebClient wc = WebClient.create(endpointAddress);
        wc.accept("application/xml");
        Collection<? extends Book> collection = wc.getCollection(Book.class);
        assertEquals(1, collection.size());
        Book book = collection.iterator().next();
        assertEquals(123L, book.getId());
    }
View Full Code Here


    public void testGetBookXSLTHtml() throws Exception {

        String endpointAddress =
            "http://localhost:" + PORT + "/the/thebooks5/bookstore/books/xslt";
        WebClient wc = WebClient.create(endpointAddress);
        wc.accept("application/xhtml+xml").path(666).matrix("name2", 2).query("name", "Action - ");
        XMLSource source = wc.get(XMLSource.class);
        Map<String, String> namespaces = new HashMap<String, String>();
        namespaces.put("xhtml", "http://www.w3.org/1999/xhtml");
        Book2 b = source.getNode("xhtml:html/xhtml:body/xhtml:ul/xhtml:Book", namespaces, Book2.class);
        assertEquals(666, b.getId());
View Full Code Here

        WebClient client = WebClient.create(endpointAddress,
            Collections.singletonList(new AegisElementProvider()));
        if (mHeader != null) {
            client = client.header("X-HTTP-Method-Override", mHeader);
        }
        Book book = client.accept(type).get(Book.class);

        assertEquals(124L, book.getId());
        assertEquals("CXF in Action - 2", book.getName());
    }
   
View Full Code Here

    @Test
    public void testGetBookXSLTXml() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/the/thebooks5/bookstore/books/xslt";
        WebClient wc = WebClient.create(endpointAddress);
        wc.accept("application/xml").path(666).matrix("name2", 2).query("name", "Action - ");
        Book b = wc.get(Book.class);
        assertEquals(666, b.getId());
        assertEquals("CXF in Action - 2", b.getName());
    }
   
View Full Code Here

                                          Collections.singletonMap("ns", "http://www.w3.org/1999/xhtml"));
            WebClient wc2 = WebClient.create(link);
            HTTPConduit conduit2 = WebClient.getConfig(wc2).getHttpConduit();
            conduit2.getClient().setReceiveTimeout(1000000);
            conduit2.getClient().setConnectionTimeout(1000000);
            InputStream is = wc2.accept("application/zip").get(InputStream.class);
            String tmpdir = System.getProperty("java.io.tmpdir");
            File classes = new File(tmpdir, "cxf-jaxrs-test-compiled-src");
            if (!classes.mkdir()) {
                fail();
            }
View Full Code Here

        checkUriInfo("http://localhost:9080/app/v1/bar", "\"bar\"", "bar");
    }
   
    private void checkUriInfo(String address, String path, String pathParam) {
        WebClient wc = WebClient.create(address);
        wc.accept("text/plain");
        String data = wc.get(String.class);
        assertEquals("http://localhost:9080/app/v1/," + path + "," + pathParam, data);
    }
   
    @Ignore
View Full Code Here

        Map<String, Object> props = new HashMap<String, Object>();
        props.put(FIStaxInInterceptor.FI_GET_SUPPORTED, Boolean.TRUE);
        bean.setProperties(props);
       
        WebClient client = bean.createWebClient();
        Book b = client.accept("application/fastinfoset").get(Book.class);
        assertEquals("CXF2", b.getName());
        assertEquals(2L, b.getId());
    }
   
    @Test
View Full Code Here

        WebClient wc = WebClient.create(baseAddress);
        MultivaluedMap<String, Object> map = new MetadataMap<String, Object>();
        map.putSingle("id", "679");
        map.putSingle("name", "CXF in Action - ");
        map.putSingle("nameid", "679");
        Book b = readBook((InputStream)wc.accept("application/xml")
                          .form((Map<String, List<Object>>)map).getEntity());
        assertEquals(679, b.getId());
        assertEquals("CXF in Action - 679", b.getName());
    }
   
View Full Code Here

        String baseAddress = "http://localhost:9092/test/services/rest/bookstore/books/679/subresource3";
        WebClient wc = WebClient.create(baseAddress);
        Form f = new Form();
        f.set("id", "679").set("name", "CXF in Action - ")
            .set("nameid", "679");
        Book b = readBook((InputStream)wc.accept("application/xml")
                          .form(f).getEntity());
        assertEquals(679, b.getId());
        assertEquals("CXF in Action - 679", b.getName());
    }
   
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());
    }
   
    public void testGetBookWithCustomHeader() throws Exception {
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.