Java 类org.springframework.web.client.UnknownHttpStatusCodeException 实例源码

项目:incubator-servicecomb-java-chassis    文件:SpringMvcIntegrationTestBase.java   
@Test
public void blowsUpWhenFileNameDoesNotMatch() throws IOException {
  String file1Content = "hello world";
  String file2Content = "bonjour";

  MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
  map.add("file1", new FileSystemResource(newFile(file1Content).getAbsolutePath()));
  map.add("unmatched name", new FileSystemResource(newFile(file2Content).getAbsolutePath()));

  HttpHeaders headers = new HttpHeaders();
  headers.setContentType(MediaType.MULTIPART_FORM_DATA);

  try {
    restTemplate.postForObject(
        codeFirstUrl + "uploadWithoutAnnotation",
        new HttpEntity<>(map, headers),
        String.class);
    expectFailing(UnknownHttpStatusCodeException.class);
  } catch (RestClientException ignored) {
  }
}
项目:incubator-servicecomb-java-chassis    文件:SpringMvcIntegrationTestBase.java   
@Test
public void ensureServerBlowsUp() {
  try {
    restTemplate.getForObject(
        controllerUrl + "sayhi?name=throwexception",
        String.class);
    fail("Exception expected, but threw nothing");
  } catch (UnknownHttpStatusCodeException e) {
    assertThat(e.getRawStatusCode(), is(590));
  }
}
项目:FastBootWeixin    文件:WxResponseErrorHandler.java   
protected HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
    try {
        return response.getStatusCode();
    } catch (IllegalArgumentException ex) {
        throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(),
                response.getHeaders(), getResponseBody(response), getCharset(response));
    }
}
项目:sdk-rest    文件:CustomResponseErrorHandler.java   
private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode;
    try {
        statusCode = response.getStatusCode();
    } catch (IllegalArgumentException ex) {
        throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(),
                response.getHeaders(), getResponseBody(response), getCharset(response));
    }
    return statusCode;
}
项目:sinavi-jfw    文件:RestClientResponseErrorHandler.java   
private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode;
    try {
        statusCode = response.getStatusCode();
    } catch (IllegalArgumentException ex) {
        if (L.isDebugEnabled()) {
            L.debug(R.getString("D-SPRINGMVC-REST-CLIENT-HANDLER#0014"), ex);
        }
        throw new UnknownHttpStatusCodeException(response.getRawStatusCode(), response.getStatusText(),
            response.getHeaders(), getResponseBody(response), getCharset(response));
    }
    return statusCode;
}
项目:bitcoind-client    文件:BitcoindJsonRpcErrorHandler.java   
private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode;
    try {
        statusCode = response.getStatusCode();
    }
    catch (IllegalArgumentException ex) {
        throw new UnknownHttpStatusCodeException(response.getRawStatusCode(),
                response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response));
    }
    return statusCode;
}
项目:jsonrpc4j    文件:JsonRpcResponseErrorHandler.java   
private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
    final HttpStatus statusCode;
    try {
        statusCode = response.getStatusCode();
    } catch (IllegalArgumentException ex) {
        throw new UnknownHttpStatusCodeException(response.getRawStatusCode(),
                response.getStatusText(), response.getHeaders(), getResponseBody(response), getCharset(response));
    }
    return statusCode;
}
项目:backstopper    文件:ClientfacingErrorITest.java   
@RequestMapping("/throwServerUnknownHttpStatusCodeException")
public void throwServerUnknownHttpStatusCodeException() {
    UnknownHttpStatusCodeException serverResponseEx = new UnknownHttpStatusCodeException(42, null, null, null, null);
    throw new ServerUnknownHttpStatusCodeException(new Exception("Intentional test exception"), "FOO", serverResponseEx, serverResponseEx.getRawStatusCode(), serverResponseEx.getResponseHeaders(), serverResponseEx.getResponseBodyAsString());
}