Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.WebResource.header()


    public void testAuthorizationUserPositive() {
        String credentials = userCredentials("newuser", "newpass");
        for (int i = 0; i < NEWUSER_POSITIVE_URIS.length; i++) {
            WebResource resource = resource(NEWUSER_POSITIVE_URIS[i]);
            try {
                Object result = resource.
                  header("Authorization", credentials).
                  get(NEWUSER_POSITIVE_CLASSES[i]);
            } catch (UniformInterfaceException e) {
                fail("Status was " + e.getResponse().getStatus() + " instead of 200 for path '" + path(NEWUSER_POSITIVE_URIS[i]) + "'");
            }
View Full Code Here


        Assert.assertEquals(200, response.getStatus());
        Customer cust = response.getEntity(Customer.class);

        String etag = response.getHeaders().getFirst("ETag");
        System.out.println("Doing a conditional GET with ETag: " + etag);
        response = wr.header("If-None-Match", etag).get(ClientResponse.class);
        Assert.assertEquals(304, response.getStatus());

        cust.setCity("Bedford");
        response = wr.header("If-Match", "JUNK").type(MediaType.APPLICATION_XML).put(ClientResponse.class, cust);
//        Assert.assertEquals(412, response.getStatus()); // original test is not passing
View Full Code Here

        System.out.println("Doing a conditional GET with ETag: " + etag);
        response = wr.header("If-None-Match", etag).get(ClientResponse.class);
        Assert.assertEquals(304, response.getStatus());

        cust.setCity("Bedford");
        response = wr.header("If-Match", "JUNK").type(MediaType.APPLICATION_XML).put(ClientResponse.class, cust);
//        Assert.assertEquals(412, response.getStatus()); // original test is not passing
        Assert.assertTrue(response.getStatus() >= 400 && response.getStatus() < 500);
    }
}
View Full Code Here

    WebResource resource = client.resource(url);

    // Provide filter that will rebuild exception that is sent from server
    resource.addFilter(serverExceptionFilter);

    return resource
      // Provide name of user executing request.
      .header(SqoopProtocolConstants.HEADER_SQOOP_USERNAME, System.getProperty("user.name"))
      // Sqoop is using JSON for data transfers
      .accept(MediaType.APPLICATION_JSON_TYPE)
      // Transfer client locale to return client specific data
View Full Code Here

        WebResource resource = service.path(entities.path)
                .path(entityType).path(entityName);
        if (colo != null) {
            resource = resource.queryParam("colo", colo);
        }
        ClientResponse clientResponse = resource.header(REMOTE_USER, USER)
                .accept(entities.mimeType).type(MediaType.TEXT_XML)
                .method(entities.method, ClientResponse.class);

        checkIfSuccessfull(clientResponse);
View Full Code Here

        WebResource resource = service.path(entities.path)
                .path(entityType);
        if (colo != null) {
            resource = resource.queryParam("colo", colo);
        }
        ClientResponse clientResponse = resource.header(REMOTE_USER, USER)
                .accept(entities.mimeType).type(MediaType.TEXT_XML)
                .method(entities.method, ClientResponse.class, requestObject);

        checkIfSuccessfull(clientResponse);
View Full Code Here

        if (end != null) {
            resource = resource.queryParam("end", end);
        }
        resource = resource.queryParam("colo", colo);

        return resource.header(REMOTE_USER, USER)
                .accept(instances.mimeType)
                .method(instances.method, InstancesResult.class);
    }

    //SUSPEND CHECKSTYLE CHECK VisibilityModifierCheck
View Full Code Here

            resource = resource.queryParam("colo", colo);
        }

        ClientResponse clientResponse;
        if (props == null) {
            clientResponse = resource.header(REMOTE_USER, USER)
                    .accept(instances.mimeType)
                    .method(instances.method, ClientResponse.class);
        } else {
            clientResponse = resource.header(REMOTE_USER, USER)
                    .accept(instances.mimeType)
View Full Code Here

        if (props == null) {
            clientResponse = resource.header(REMOTE_USER, USER)
                    .accept(instances.mimeType)
                    .method(instances.method, ClientResponse.class);
        } else {
            clientResponse = resource.header(REMOTE_USER, USER)
                    .accept(instances.mimeType)
                    .method(instances.method, ClientResponse.class, props);
        }
        checkIfSuccessfull(clientResponse);
View Full Code Here

            contentType = MediaType.APPLICATION_JSON;
        }
        if (payload instanceof Map) {
            payload = buildMultivalueMap((Map<String, Object>)payload);
        }
        ClientResponse cr = webResource.header("Content-Type", contentType)
                .cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken()))
//                .header("Content-type", MediaType.APPLICATION_FORM_URLENCODED)
                .accept(RESPONSE_TYPE).post(ClientResponse.class, payload);
        RestResponse rr = RestResponse.getRestResponse(cr);
        return rr;
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.