Package org.springframework.web.client

Examples of org.springframework.web.client.RestClientException


        //for the third -- in this case the two items should have the new content but the third with the exception should
        //retain the old good cached content.
        String newContent = "new content from refresh";
        restTemplate = createNiceMock(RestTemplate.class);
        expect(restTemplate.getForObject(new URI(VALID_URL1), String.class)).andReturn(newContent);
        expect(restTemplate.getForObject(new URI(VALID_URL2), String.class)).andThrow(new RestClientException("Boom"));
        expect(restTemplate.getForObject(new URI(VALID_URL3), String.class)).andReturn(newContent);
        replay(restTemplate);
        //Use reflection to stuff the new RestTemplate instance into our existing content fetcher instance
        ReflectionTestUtils.setField(service, "restTemplate", restTemplate);
View Full Code Here


                        + requestType.getName() + "]";
                if (requestContentType != null) {
                    message += " and content type [" + requestContentType + "]";
                }

                throw new RestClientException(message);
            }
        }
View Full Code Here

        //for the third -- in this case the two items should have the new content but the third with the exception should
        //retain the old good cached content.
        String newContent = "new content from refresh";
        restTemplate = createNiceMock(RestTemplate.class);
        expect(restTemplate.getForObject(new URI(VALID_URL1), String.class)).andReturn(newContent);
        expect(restTemplate.getForObject(new URI(VALID_URL2), String.class)).andThrow(new RestClientException("Boom"));
        expect(restTemplate.getForObject(new URI(VALID_URL3), String.class)).andReturn(newContent);
        replay(restTemplate);
        //Use reflection to stuff the new RestTemplate instance into our existing content fetcher instance
        ReflectionTestUtils.setField(service, "restTemplate", restTemplate);
View Full Code Here

        public URI postForLocation(String url, Object request, Map<String, ?> uriVariables) throws RestClientException {
            setState(HttpMethod.POST, url);
            try {
                return new URI(url);
            } catch (URISyntaxException e) {
                throw new RestClientException("Failed to convert " + url + ": " + e.getMessage(), e);
            }
        }
View Full Code Here

    final String[] status = new String[1];
    final HttpStatus[] httpStatus = new HttpStatus[1];
    final Object[] headers = new Object[1];
    final String[] message = new String[1];
    T results = null;
    RestClientException exception = null;
    try {
      results = super.doExecute(url, method, requestCallback,
          new ResponseExtractor<T>() {
            @SuppressWarnings("rawtypes")
            public T extractData(ClientHttpResponse response) throws IOException {
View Full Code Here

      case CLIENT_ERROR:
        throw getException(response);
      case SERVER_ERROR:
        throw new HttpServerErrorException(statusCode, response.getStatusText());
      default:
        throw new RestClientException("Unknown status code [" + statusCode + "]");
    }
  }
View Full Code Here

        assertThat(((GettingStartedGuide) model.get("guide")), is(guide));
    }

    @Test(expected = RestClientException.class)
    public void viewGuide_fails() {
        given(guides.find("rest-service")).willThrow(new RestClientException("Is GitHub down?"));
        controller.viewGuide("rest-service", model);
    }
View Full Code Here

    public <T> T execute(URI url, HttpMethod method, RequestCallback callback, ResponseExtractor<T> extractor) throws RestClientException {
      try {
        extractor.extractData(this.responses.remove());
      }
      catch (Throwable t) {
        throw new RestClientException("Failed to invoke extractor", t);
      }
      return null;
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.client.RestClientException

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.