Package org.springframework.http.client

Examples of org.springframework.http.client.ClientHttpRequest.execute()


                Image image = null;
                Closer closer = Closer.create();
                try {
                    checkCancelState(context);
                    final ClientHttpRequest request = clientHttpRequestFactory.createRequest(icon.toURI(), HttpMethod.GET);
                    final ClientHttpResponse httpResponse = closer.register(request.execute());
                    if (httpResponse.getStatusCode() == HttpStatus.OK) {
                        image = ImageIO.read(httpResponse.getBody());
                        if (image == null) {
                            LOGGER.warn("The URL: " + icon + " is NOT an image format that can be decoded");
                        }
View Full Code Here


        if (urlMatcher.matches() && urlMatcher.group(this.urlGroup) != null) {
            final String uriString = urlMatcher.group(this.urlGroup);
            try {
                URI url = new URI(uriString);
                final ClientHttpRequest request = requestFactory.createRequest(url, HttpMethod.GET);
                final ClientHttpResponse response = request.execute();
                if (response.getStatusCode() == HttpStatus.OK) {
                    try {
                        final BufferedImage image = ImageIO.read(response.getBody());
                        if (image == null) {
                            LOGGER.warn("The URL: " + url + " is NOT an image format that can be decoded");
View Full Code Here

public class OldPrintApiTest extends AbstractApiTest {
   
    @Test
    public void testInfo() throws Exception {
        ClientHttpRequest request = getPrintRequest("info.json", HttpMethod.GET);
        response = request.execute();
        assertEquals(HttpStatus.OK, response.getStatusCode());
        assertEquals(getJsonMediaType(), response.getHeaders().getContentType());
       
        JSONObject info = new JSONObject(getBodyAsText(response));
        assertTrue(info.has("scales"));
View Full Code Here

   
    @Test
    public void testInfoVarAndUrl() throws Exception {
        ClientHttpRequest request = getPrintRequest(
                "info.json?var=printConfig&url=http://demo.mapfish.org/2.2/print/dep/info.json", HttpMethod.GET);
        response = request.execute();
        assertEquals(HttpStatus.OK, response.getStatusCode());
        assertEquals(getJsonMediaType(), response.getHeaders().getContentType());

        final String result = getBodyAsText(response);
        assertTrue(result.startsWith("var printConfig="));
View Full Code Here

    @Test
    public void testInfoUrl2() throws Exception {
        ClientHttpRequest request = getPrintRequest(
                "info.json?var=printConfig&url=http%3A%2F%2Fref.geoview.bl.ch%2Fprint3%2Fwsgi%2Fprintproxy", HttpMethod.GET);
        response = request.execute();
        assertEquals(HttpStatus.OK, response.getStatusCode());
        assertEquals(getJsonMediaType(), response.getHeaders().getContentType());

        final String result = getBodyAsText(response);
        assertTrue(result.startsWith("var printConfig="));
View Full Code Here

    @Test
    public void testCreate() throws Exception {
        ClientHttpRequest request = getPrintRequest("create.json", HttpMethod.POST);
        setPrintSpec(getPrintSpec("examples/verboseExample/old-api-requestData.json"), request);
        response = request.execute();
        assertEquals(HttpStatus.OK, response.getStatusCode());
        assertEquals(getJsonMediaType(), response.getHeaders().getContentType());

        final JSONObject result = new JSONObject(getBodyAsText(response));
        response.close();
View Full Code Here

        final String prefix = "/print-servlet/print/dep/";
        assertTrue(String.format("Start of url is not as expected: \n'%s'\n'%s'", prefix, getUrl), getUrl.startsWith(prefix));
        assertTrue("Report url should end with .printout: " + getUrl, getUrl.endsWith(".printout"));
         
        ClientHttpRequest requestGetPdf = getRequest(getUrl.replace("/print-servlet/", ""), HttpMethod.GET);
        response = requestGetPdf.execute();
        assertEquals(response.getStatusText(), HttpStatus.OK, response.getStatusCode());
        assertEquals(new MediaType("application", "pdf"), response.getHeaders().getContentType());
        assertTrue(response.getBody().read() >= 0);
    }
View Full Code Here

    }

    @Test
    public void testCreate_MissingSpec() throws Exception {
        ClientHttpRequest request = getPrintRequest("create.json", HttpMethod.POST);
        response = request.execute();
        assertEquals(HttpStatus.UNSUPPORTED_MEDIA_TYPE, response.getStatusCode());
    }

    @Test
    public void testCreate_InvalidSpec() throws Exception {
View Full Code Here

    @Test
    public void testCreate_InvalidSpec() throws Exception {
        ClientHttpRequest request = getPrintRequest("create.json", HttpMethod.POST);
        setPrintSpec("{}", request);
        response = request.execute();
        assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
    }

    @Test
    public void testCreate_Var() throws Exception {
View Full Code Here

    public void testCreate_Var() throws Exception {
        String url = "create.json?url=" +
                URLEncoder.encode("http://localhost:8080/print-servlet/print/dep/create.json", Constants.DEFAULT_ENCODING);
        ClientHttpRequest request = getPrintRequest(url, HttpMethod.POST);
        setPrintSpec(getPrintSpec("examples/verboseExample/old-api-requestData.json"), request);
        response = request.execute();
        assertEquals(HttpStatus.OK, response.getStatusCode());
        assertEquals(getJsonMediaType(), response.getHeaders().getContentType());

        final JSONObject result = new JSONObject(getBodyAsText(response));
        response.close();
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.