Examples of WebClient


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

        }
    }
   
    @Test
    public void testServerWebApplicationExceptionResponse() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/webappexception");
        wc.accept("application/xml");
        try {
            Response r = wc.get(Response.class);
            assertEquals(500, r.getStatus());
        } catch (WebApplicationException ex) {
            fail("Unexpected exception");
        }
    }
View Full Code Here

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

        }
    }
   
    @Test
    public void testServerWebApplicationExceptionXML() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/webappexceptionXML");
        wc.accept("application/xml");
        try {
            wc.get(Book.class);
            fail("Exception expected");
        } catch (NotAcceptableException ex) {
            assertEquals(406, ex.getResponse().getStatus());
            Book exBook = ex.getResponse().readEntity(Book.class);
            assertEquals("Exception", exBook.getName());
View Full Code Here

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

                               "application/xml", 200);
    }
   
    @Test
    public void testHeadBookByURL() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:" + PORT
                             + "/bookstore/bookurl/http%3A%2F%2Ftest.com%2Frss%2F123");
        Response response = wc.head();
        assertTrue(response.getMetadata().size() != 0);
        assertEquals(0, ((InputStream)response.getEntity()).available());
    }
View Full Code Here

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

   
    @Test
    public void testWebClientUnwrapBookWithXslt() throws Exception {
        XSLTJaxbProvider<Book> provider = new XSLTJaxbProvider<Book>();
        provider.setInTemplate("classpath:/org/apache/cxf/systest/jaxrs/resources/unwrapbook.xsl");
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/books/wrapper",
                             Collections.singletonList(provider));
        wc.path("{id}", 123);
        Book book = wc.get(Book.class);
        assertNotNull(book);
        assertEquals(123L, book.getId());
       
    }
View Full Code Here

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

       
    }
   
    @Test
    public void testOptions() throws Exception {
        WebClient wc =
            WebClient.create("http://localhost:"
                             + PORT + "/bookstore/bookurl/http%3A%2F%2Ftest.com%2Frss%2F123");
        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

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

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

        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

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

        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

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

        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

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

        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
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.