Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.ClientRequest$Builder


    }

    private void tryRestApi() throws Exception {
        final String url = getHttpBaseUri() + "graphs/gratefulgraph/vertices/";
        for (int ix = 1; ix < 801; ix++) {
            final ClientRequest request = ClientRequest.create().build(URI.create(url + String.valueOf(ix)), "GET");
            final ClientResponse response = httpClient.handle(request);
            final JSONObject json = response.getEntity(JSONObject.class);
            Assert.assertEquals(ix, json.optJSONObject("results").optInt("_id"));
        }
    }
View Full Code Here


    }

    private void tryRestGremlin() throws Exception {
        final String url = getHttpBaseUri() + "graphs/emptygraph/tp/gremlin?script=" + URLEncoder.encode("g.addVertex([someId:x])") + "&params.x=";
        for (int ix = 1; ix < 1001; ix++) {
            final ClientRequest request = ClientRequest.create().build(URI.create(url + String.valueOf(ix)), "GET");
            final ClientResponse response = httpClient.handle(request);
            final JSONObject json = response.getEntity(JSONObject.class);
            Assert.assertTrue(json.optBoolean("success"));
        }
    }
View Full Code Here

    }

    private void tryRestApi() throws Exception {
        final String url = getHttpBaseUri() + "graphs/emptygraph/vertices/";
        for (int ix = 1; ix < 1001; ix++) {
            final ClientRequest request = ClientRequest.create().build(URI.create(url), "POST");

            final Map<String, Integer> postData = new HashMap<String, Integer>();
            postData.put("someId", ix);
            request.setEntity(new JSONObject(postData));

            final ClientResponse response = httpClient.handle(request);
            final JSONObject json = response.getEntity(JSONObject.class);
            final JSONObject result = json.optJSONObject("results");
            Assert.assertEquals(ix, result.optInt("someId"));
View Full Code Here

        Assert.assertEquals(2, results.get(0).intValue());
    }

    private void tryRestGremlin() throws Exception {
        final String url = getHttpBaseUri() + "graphs/emptygraph/tp/gremlin?script=" + URLEncoder.encode("1+1");
        final ClientRequest request = ClientRequest.create().build(URI.create(url), "GET");
        final ClientResponse response = httpClient.handle(request);
        final JSONObject json = response.getEntity(JSONObject.class);
        Assert.assertEquals(2, json.optJSONArray("results").optInt(0));
    }
View Full Code Here

    private void tryRestGremlin() throws Exception {
        String traversal = traversals[0];
        for (int iy = 1; iy < 26; iy++) {
            final String url = getHttpBaseUri() + "graphs/gratefulgraph/tp/gremlin?script=" + URLEncoder.encode(traversal) + "&rexster.offset.end=" + Long.MAX_VALUE + "&params.x=";
            final ClientRequest request = ClientRequest.create().build(URI.create(url + String.valueOf(iy * 8)), "GET");
            final ClientResponse response = httpClient.handle(request);
            final JSONObject json = response.getEntity(JSONObject.class);
            Assert.assertTrue(json.optBoolean("success"));
        }

        traversal = traversals[1];
        for (int ix = 0; ix < 25; ix++) {
            final String url = getHttpBaseUri() + "graphs/gratefulgraph/tp/gremlin?script=" + URLEncoder.encode(traversal) + "&rexster.offset.end=" + Long.MAX_VALUE + "&params.x=";
            final ClientRequest request = ClientRequest.create().build(URI.create(url + String.valueOf(artists[ix])), "GET");
            final ClientResponse response = httpClient.handle(request);
            final JSONObject json = response.getEntity(JSONObject.class);
            Assert.assertTrue(json.optBoolean("success"));
        }

        traversal = traversals[2];
        for (int ix = 100; ix < 125; ix++) {
            final String url = getHttpBaseUri() + "graphs/gratefulgraph/tp/gremlin?script=" + URLEncoder.encode(traversal) + "&rexster.offset.end=" + Long.MAX_VALUE + "&params.x=";
            final ClientRequest request = ClientRequest.create().build(URI.create(url + String.valueOf(songs[ix])), "GET");
            final ClientResponse response = httpClient.handle(request);
            final JSONObject json = response.getEntity(JSONObject.class);
            Assert.assertTrue(json.optBoolean("success"));
        }
    }
View Full Code Here

        // Handle a redirect
        if (response.getClientResponseStatus() == ClientResponse.Status.FOUND) {
            if (response.getHeaders().containsKey(HttpHeaders.LOCATION)) {
                String location = response.getHeaders().getFirst(HttpHeaders.LOCATION);

                final ClientRequest newRequest = ClientRequest.create().build(URI.create(location), request.getMethod());

                // Handle the token from the existing response, add to this new request
                checkResponseForToken(response);
                addTokenToRequest(newRequest);
View Full Code Here

    }

    @Override
    public ClientResponse handle(ClientRequest clientRequest) {

        final ClientRequest cr = clientRequest;
        try {
            ServiceResponseContext resp = filter.handle(
                    new JerseyServiceRequestContext(clientRequest),
                    new ServiceFilter.Next() {
                        @Override
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.client.ClientRequest$Builder

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.