Package org.apache.cxf.jaxrs.client

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


       
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/name-in-query";
        WebClient wc = WebClient.create(endpointAddress);
        String name = "Many        spaces";
        wc.query("name", name);
        Book b = wc.get(Book.class);
        assertEquals(name, b.getName());
    }
   
    @Test
View Full Code Here


    public void testProcessingInstruction() throws Exception {
        String base = "http://localhost:" + PORT;
        String endpointAddress = base + "/bookstore/name-in-query";
        WebClient wc = WebClient.create(endpointAddress);
        String name = "Many        spaces";
        wc.query("name", name);
        String content = wc.get(String.class);
        assertTrue(content.contains("<!DOCTYPE Something SYSTEM 'my.dtd'>"));
        assertTrue(content.contains("<?xmlstylesheet href='" + base + "/common.css'?>"));
        assertTrue(content.contains("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""));
        assertTrue(content.contains("xsi:schemaLocation=\"" + base + "/book.xsd\""));
View Full Code Here

       
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/name-in-query";
        WebClient wc = WebClient.create(endpointAddress);
        String name = "Many        spaces";
        wc.query("name", name);
        Book b = wc.get(Book.class);
        assertEquals(name, b.getName());
    }
   
    @Test
View Full Code Here

    @Test
    public void testSearchBook123WithWebClient() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/books/search";
                         
        WebClient client = WebClient.create(address);
        Book b = client.query("_s", "name==CXF*;id=ge=123;id=lt=124").get(Book.class);
        assertEquals(b.getId(), 123L);
       
    }
   
    @Test
View Full Code Here

    @Test
    public void testGetBookJsonp() throws Exception {
        String url = "http://localhost:" + PORT + "/the/jsonp/books/123";
        WebClient client = WebClient.create(url);
        client.accept("application/json, application/x-javascript");
        client.query("_jsonp", "callback");
        Response r = client.get();
        assertEquals("application/x-javascript", r.getMetadata().getFirst("Content-Type"));
        assertEquals("callback({\"Book\":{\"id\":123,\"name\":\"CXF in Action\"}});",
                     IOUtils.readStringFromStream((InputStream)r.getEntity()));
    }
View Full Code Here

    @Test
    public void testGetBookJsonp() throws Exception {
        String url = "http://localhost:" + PORT + "/the/jsonp/books/123";
        WebClient client = WebClient.create(url);
        client.accept("application/json, application/x-javascript");
        client.query("_jsonp", "callback");
        Response r = client.get();
        assertEquals("application/x-javascript", r.getMetadata().getFirst("Content-Type"));
        assertEquals("callback({\"Book\":{\"id\":123,\"name\":\"CXF in Action\"}});",
                     IOUtils.readStringFromStream((InputStream)r.getEntity()));
    }
View Full Code Here

    public void testGetBookJsonpJackson() throws Exception {
        String url = "http://localhost:" + PORT + "/the/jsonp2/books/123";
        WebClient client = WebClient.create(url);
        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000);
        client.accept("application/json, application/x-javascript");
        client.query("_jsonp", "callback");
        Response r = client.get();
        assertEquals("application/x-javascript", r.getMetadata().getFirst("Content-Type"));
        String response = IOUtils.readStringFromStream((InputStream)r.getEntity());
        assertTrue(response.startsWith("callback({\"class\":\"org.apache.cxf.systest.jaxrs.Book\","));
        assertTrue(response.endsWith("});"));
View Full Code Here

    @Test
    public void testSearchBook123WithWebClient() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/books/search";
                         
        WebClient client = WebClient.create(address);
        Book b = client.query("_s", "name==CXF*;id=ge=123;id=lt=124").get(Book.class);
        assertEquals(b.getId(), 123L);
       
    }
   
    @Test
View Full Code Here

       
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/name-in-query";
        WebClient wc = WebClient.create(endpointAddress);
        String name = "Many        spaces";
        wc.query("name", name);
        Book b = wc.get(Book.class);
        assertEquals(name, b.getName());
    }
   
    @Test
View Full Code Here

    @Test
    public void testSearchBook123WithWebClient() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/books/search";
                         
        WebClient client = WebClient.create(address);
        Book b = client.query("_s", "name==CXF*;id=ge=123;id=lt=124").get(Book.class);
        assertEquals(b.getId(), 123L);
       
    }
   
    @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.