Package javax.ws.rs.client

Examples of javax.ws.rs.client.WebTarget.request()


    public static RestResponse
    post(String address, Map<String, Object> payload) {
        WebTarget target = getJerseyClient().target(address);
        MultivaluedMap formData = buildMultivalueMap(payload);
        Response cr = target
                //                .header("Content-type", MediaType.APPLICATION_FORM_URLENCODED)
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                .post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
View Full Code Here


    }

    public static RestResponse put(String address, Map<String, Object> payload) {
        WebTarget target = getJerseyClient().target(address);
        MultivaluedMap formData = buildMultivalueMap(payload);
        Response cr = target
                //                .header("Content-type", MediaType.APPLICATION_FORM_URLENCODED)
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                .put(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
View Full Code Here

        return RestResponse.getRestResponse(cr);
    }

    public static RestResponse options(String address, String responseType) {
        WebTarget target = getJerseyClient().target(address);
        Response cr = target
                .request(responseType)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
                .options(Response.class);
        return RestResponse.getRestResponse(cr);
    }
View Full Code Here

    public static void postRestRequestFromServlet(HttpServletRequest request, String endpoint, Map<String, Object> attrs, boolean quiet, boolean throwException) {
        String token = (String) request.getSession().getAttribute(AdminConsoleAuthModule.REST_TOKEN);
        WebTarget target = JERSEY_CLIENT.target(endpoint);
        MultivaluedMap formData = buildMultivalueMap(attrs);
        Response cr = target
                .request(RESPONSE_TYPE)
                .cookie(new Cookie(REST_TOKEN_COOKIE, token))
                .post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
        RestResponse rr = RestResponse.getRestResponse(cr);
        parseResponse(rr, null, endpoint, attrs, quiet, throwException);
View Full Code Here

                .register(new FpEntityCollectionReaderWriter())
                .register(new FpEntityReaderWriter());
        WebTarget target = client.target(url.toURI()).path("rest").path("posts");

        // Create Post
        Response response = target.request().accept(MediaType.APPLICATION_JSON).get();
        assertNotNull(response);
        assertNotNull(response.readEntity(String.class));
        Post post = new Post();
        post.setTitle("REST Test");
        post.setSlug("rest-test");
View Full Code Here

        assertNotNull(response.readEntity(String.class));
        Post post = new Post();
        post.setTitle("REST Test");
        post.setSlug("rest-test");

        response = target.request(MediaType.APPLICATION_JSON).post(Entity.entity(post, MediaType.APPLICATION_JSON));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());

        Post newPost = response.readEntity(Post.class);
        assertNotNull(newPost);
View Full Code Here

        builder.keyStore(keyStore, "password");
       
        Client client = builder.build();
       
        WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123");
        Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class);
        assertEquals(123, b.getId());
    }
   
    @Test
    public void testGetBookSslContext() throws Exception {
View Full Code Here

       
       
        Client client = builder.build();
       
        WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123");
        Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class);
        assertEquals(123, b.getId());
    }
   
    private KeyStore loadStore(String trustStoreFile, String password) throws Exception {
        KeyStore store = KeyStore.getInstance("JKS");
View Full Code Here

                if (authInfo != null) {
                    HttpBasicAuthFilter besicAuth = new HttpBasicAuthFilter(authInfo.getUser(), authInfo.getPassword() == null ? "" : authInfo.getPassword());
                    target.configuration().register(besicAuth);
                }
                Metrix.event("doRestCommand() - about to prepare request builder");
                Builder request = target.request(acceptedResponseTypes);
                Metrix.event("doRestCommand() - about to add headers");
                if (authToken != null) {
                    /*
                     * If this request is for metadata then we expect to reuse
                     * the auth token.
View Full Code Here

                bodyPart(bean, new MediaType("x-application", "x-format")).
                bodyPart("", MediaType.APPLICATION_OCTET_STREAM_TYPE);

        final String UNSENT_HEADER_CHANGES = "Unsent header changes";
        try {
            target.request("text/plain").put(Entity.entity(entity, "multipart/mixed"), String.class);
            assertFalse("BadRequestException can not be thrown just in case JERSEY-2341 is not fixed.",
                    messageLogged);
            LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES);
            assertNull(logRecord);
        } catch (BadRequestException brex) {
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.