Package org.apache.cxf.jaxrs.client

Examples of org.apache.cxf.jaxrs.client.WebClient


        assertEquals(1, date.size());
    }
   
    @Test
    public void testExplicitOptions() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/options");
        WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split", true);
        Response response = wc.options();
        List<Object> values = response.getMetadata().get("Allow");
        assertNotNull(values);
        assertTrue(values.contains("POST") && values.contains("GET")
                   && values.contains("DELETE") && values.contains("PUT"));
        assertEquals(0, ((InputStream)response.getEntity()).available());
View Full Code Here


        assertNotNull(date);
        assertEquals(1, date.size());
    }
   
    public void testExplicitOptionsNoSplitByDefault() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/options");
        Response response = wc.options();
        List<String> values = Arrays.asList(response.getHeaderString("Allow").split(","));
        assertNotNull(values);
        assertTrue(values.contains("POST") && values.contains("GET")
                   && values.contains("DELETE") && values.contains("PUT"));
        assertEquals(0, ((InputStream)response.getEntity()).available());
View Full Code Here

        assertEquals(1, date.size());
    }

    @Test
    public void testOptionsOnSubresource() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/booksubresource/123");
        WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split", true);
        Response response = wc.options();
        List<Object> values = response.getMetadata().get("Allow");
        assertNotNull(values);
        assertTrue(!values.contains("POST") && values.contains("GET")
                   && !values.contains("DELETE") && values.contains("PUT"));
        assertEquals(0, ((InputStream)response.getEntity()).available());
View Full Code Here

        assertEquals(1, date.size());
    }
   
    @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"));
    }
View Full Code Here

        assertNull(response.getMetadata().getFirst("Content-Type"));
    }
   
    @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"));
    }
View Full Code Here

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

        checkBook("http://localhost:" + PORT + "/bookstore/books/check/125", false)
    }
   
    @Test
    public void testBookExistsWebClientPrimitiveBoolean() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/check/123");
        wc.accept("text/plain");
        assertTrue(wc.get(boolean.class));
    }
View Full Code Here

        assertTrue(store.checkBook(123L));
    }
   
    @Test
    public void testBookExistsWebClientBooleanObject() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/check/123");
        wc.accept("text/plain");
        assertTrue(wc.get(Boolean.class));
    }
View Full Code Here

        assertTrue(wc.get(Boolean.class));
    }
   
    @Test
    public void testBookExistsMalformedMt() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:" + PORT + "/bookstore/books/check/malformedmt/123");
        wc.accept(MediaType.TEXT_PLAIN);
        WebClient.getConfig(wc).getInInterceptors().add(new ReplaceContentTypeInterceptor());
        assertTrue(wc.get(Boolean.class));
    }
View Full Code Here

    }
   
    @Test
    public void testGetHeadBook123WebClient() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/getheadbook/";
        WebClient client = WebClient.create(address);
        Response r = client.head();
        assertEquals("HEAD_HEADER_VALUE", r.getMetadata().getFirst("HEAD_HEADER"));
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.client.WebClient

Copyright © 2018 www.massapicom. 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.