Package javax.ws.rs.core

Examples of javax.ws.rs.core.Response


            Thread.sleep(1000);   
        }
    }
    private static boolean checkReplica(String address) {
        try {
            Response r = WebClient.create(address).query("_wadl").get();
            return r.getStatus() == 200;
        } catch (Exception ex) {
            return false;
        }
    }
View Full Code Here


                                 String newReplica,
                                 boolean notAvailableOnly) throws Exception {
        WebClient bookStore = getWebClient(currentReplica, feature);
        verifyStrategy(bookStore, SequentialStrategy.class);
        bookStore.path("bookstore/webappexceptionXML");
        Response r = bookStore.get();
        assertEquals(406, r.getStatus());
        String currEndpoint = getCurrentEndpointAddress(bookStore);
        if (notAvailableOnly) {
            assertTrue(currEndpoint.equals(currentReplica));
        } else {
            assertTrue(currEndpoint.equals(newReplica));
View Full Code Here

        return doc;
    }
   
    protected void throwFault(String error, Exception ex) {
        LOG.warning(error);
        Response response = JAXRSUtils.toResponseBuilder(400).entity(error).build();
        throw ExceptionUtils.toBadRequestException(null, response);
    }
View Full Code Here

   
    protected void throwFault(String error, Exception ex) {
        // TODO: get bundle resource message once this filter is moved
        // to rt/rs/security
        LOG.warning(error);
        Response response = JAXRSUtils.toResponseBuilder(401).entity(error).build();
        throw ExceptionUtils.toNotAuthorizedException(null, response);
    }
View Full Code Here

   
    @Test
    public void testGetBookQueryDefault() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/books/query/default";
        WebClient wc = WebClient.create(address);
        Response r = wc.get();
        Book book = r.readEntity(Book.class);
        assertEquals(123L, book.getId());
    }
View Full Code Here

        String address = "http://localhost:" + PORT + "/bookstore/redirect?sameuri=true";
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getHttpConduit().getClient().setAutoRedirect(true);
        WebClient.getConfig(wc).getRequestContext().put(
            org.apache.cxf.message.Message.MAINTAIN_SESSION, Boolean.TRUE);
        Response r = wc.get();
        Book book = r.readEntity(Book.class);
        assertEquals(123L, book.getId());
        String requestUri = r.getStringHeaders().getFirst("RequestURI");
        assertEquals("http://localhost:" + PORT + "/bookstore/redirect?redirect=true", requestUri);
        String theCookie = r.getStringHeaders().getFirst("TheCookie");
        assertEquals("b", theCookie);
    }
View Full Code Here

    public void testGetBookRelativeUriAutoRedirect() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/redirect/relative?loop=false";
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getRequestContext().put("http.redirect.relative.uri", "true");
        WebClient.getConfig(wc).getHttpConduit().getClient().setAutoRedirect(true);
        Response r = wc.get();
        Book book = r.readEntity(Book.class);
        assertEquals(124L, book.getId());
    }
View Full Code Here

   
    @Test
    public void testPostEmptyForm() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/emptyform";
        WebClient wc = WebClient.create(address);
        Response r = wc.form(new org.apache.cxf.jaxrs.ext.form.Form());
        assertEquals("empty form", r.readEntity(String.class));
    }
View Full Code Here

    public void testPostEmptyFormAsInStream() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/emptyform";
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.empty.request", true);
        wc.type(MediaType.APPLICATION_FORM_URLENCODED);
        Response r = wc.post(new ByteArrayInputStream("".getBytes()));
        assertEquals("empty form", r.readEntity(String.class));
    }
View Full Code Here

    @Test
    public void testGetBookDescriptionHttpResponse() throws Exception {
        String address = "http://localhost:" + PORT + "/bookstore/httpresponse";
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getInInterceptors().add(new LoggingInInterceptor());
        Response r = wc.get();
        assertEquals("text/plain", r.getMediaType().toString());
        assertEquals("Good Book", r.readEntity(String.class));
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Response

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.