Examples of ClientHttpRequest


Examples of org.springframework.http.client.ClientHttpRequest

        assertRequiresAuth("sec/print" + MapPrinterServlet.CAPABILITIES_URL);
        assertRequiresAuth("sec/print/dep/info.json");
    }

    private void assertRequiresAuth(String path) throws IOException, URISyntaxException {
        ClientHttpRequest request = getRequest(path, HttpMethod.GET);
        HttpURLConnection urlConnection = (HttpURLConnection) request.getURI().toURL().openConnection();
        assertEquals(HttpStatus.FOUND.value(), urlConnection.getResponseCode());
        assertEquals("https://localhost:8443/print-servlet/"+path, urlConnection.getHeaderField("Location"));
        urlConnection.disconnect();
    }
View Full Code Here

Examples of org.springframework.http.client.ClientHttpRequest

        urlConnection.disconnect();
    }

    @Test
    public void testSecuredTemplate_CreateMap() throws Exception {
        ClientHttpRequest request = getPrintRequest("secured_templates" + MapPrinterServlet.CREATE_AND_GET_URL + ".pdf", HttpMethod.POST);
        final String printSpec = getPrintSpec("examples/secured_templates/requestData.json").replace("\"A4 landscape\"", "\"secured\"");
        setPrintSpec(printSpec, request);
        response = request.execute();
        assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode());
        response.close();

        execCreateRequestWithAuth("jimi:jimi", HttpStatus.OK, printSpec);
        execCreateRequestWithAuth("bob:bob", HttpStatus.FORBIDDEN, printSpec);
View Full Code Here

Examples of org.springframework.http.client.ClientHttpRequest

        execCreateRequestWithAuth("bob:bob", HttpStatus.FORBIDDEN, printSpec);

    }

    private JSONArray execCapabilitiesRequestWithAut(int expectedNumberOfLayouts, String credentials) throws IOException, URISyntaxException, JSONException {
        ClientHttpRequest request = getPrintRequest("secured_templates" + MapPrinterServlet.CAPABILITIES_URL, HttpMethod.GET);
        if (credentials != null) {
            addAuthHeader(request, credentials);
        }
        response = request.execute();
        assertEquals(HttpStatus.OK, response.getStatusCode());

        String responseAsText = getBodyAsText(response);
        response.close();
View Full Code Here

Examples of org.springframework.http.client.ClientHttpRequest

        assertEquals(expectedNumberOfLayouts, layouts.length());
        return layouts;
    }

    private void execCreateRequestWithAuth(String credentials, HttpStatus expectedStatus, String printSpec) throws IOException, URISyntaxException {
        ClientHttpRequest request = getPrintRequest("secured_templates" + MapPrinterServlet.CREATE_AND_GET_URL + ".pdf", HttpMethod.POST);
        setPrintSpec(printSpec, request);
        addAuthHeader(request, credentials);
        response = request.execute();
        assertEquals(response.getStatusText(), expectedStatus, response.getStatusCode());
        response.close();
    }
View Full Code Here

Examples of org.springframework.http.client.ClientHttpRequest

        boolean done = false;
        do {
            ClientHttpResponse response = null;

            try {
                ClientHttpRequest request = getPrintRequest(
                        MapPrinterServlet.STATUS_URL + "/" + ref + ".json", HttpMethod.GET);
                response = request.execute();
                final JSONObject statusResult = new JSONObject(
                        getBodyAsText(response));
                done = statusResult.getBoolean(MapPrinterServlet.JSON_DONE);

                if (!done) {
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.