Skip to content

Commit

Permalink
Polish contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Mar 17, 2020
1 parent 2fb13d4 commit 17140c8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -103,9 +103,8 @@ public void handleError(ClientHttpResponse response) throws IOException {
HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode());
if (statusCode == null) {
byte[] body = getResponseBody(response);
String message = getErrorMessage(
response.getRawStatusCode(), response.getStatusText(),
body, getCharset(response));
String message = getErrorMessage(response.getRawStatusCode(),
response.getStatusText(), body, getCharset(response));
throw new UnknownHttpStatusCodeException(message,
response.getRawStatusCode(), response.getStatusText(),
response.getHeaders(), body, getCharset(response));
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -183,6 +183,7 @@ public void handleErrorForCustomClientError() throws Exception {
assertThat(actualUnknownHttpStatusCodeException.getRawStatusCode()).isEqualTo(statusCode);
assertThat(actualUnknownHttpStatusCodeException.getStatusText()).isEqualTo(statusText);
assertThat(actualUnknownHttpStatusCodeException.getResponseHeaders()).isEqualTo(headers);
assertThat(actualUnknownHttpStatusCodeException.getMessage()).contains(responseBody);
assertThat(actualUnknownHttpStatusCodeException.getResponseBodyAsString()).isEqualTo(responseBody);
}

Expand Down Expand Up @@ -222,6 +223,7 @@ public void handleErrorForCustomServerError() throws Exception {
assertThat(actualUnknownHttpStatusCodeException.getRawStatusCode()).isEqualTo(statusCode);
assertThat(actualUnknownHttpStatusCodeException.getStatusText()).isEqualTo(statusText);
assertThat(actualUnknownHttpStatusCodeException.getResponseHeaders()).isEqualTo(headers);
assertThat(actualUnknownHttpStatusCodeException.getMessage()).contains(responseBody);
assertThat(actualUnknownHttpStatusCodeException.getResponseBodyAsString()).isEqualTo(responseBody);
}

Expand All @@ -241,6 +243,7 @@ public void bodyAvailableAfterHasErrorForUnknownStatusCode() throws Exception {
assertThat(StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8)).isEqualTo("Hello World");
}


private static class TestByteArrayInputStream extends ByteArrayInputStream {

private boolean closed;
Expand Down

0 comments on commit 17140c8

Please sign in to comment.