Skip to content

Commit

Permalink
test (kubernetes-client-api) : Add test in AbstractHttpLoggingInterce…
Browse files Browse the repository at this point in the history
…ptor to not consume response bytes (#5251)

Add a unit test in AbstractHttpLoggingInterceptor to verify response
bytes are not consumed after they've been processed by
HttpLoggingInterceptor.

I've verified that test fails when I revert #5250
in httpclient-okhttp and httpclient-vertx modules

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia authored and manusa committed Nov 9, 2023
1 parent b3a03d8 commit fdce3ca
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.Queue;
import java.util.concurrent.TimeUnit;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -181,6 +182,18 @@ public void httpResponseBodyLogged() throws Exception {
inOrder.verify(logger).trace("-HTTP END-");
}

@Test
@DisplayName("Interceptor doesn't consume response bytes")
public void responseBodyIsNotConsumed() throws Exception {
server.expect().withPath("/response-body")
.andReturn(200, "This is the response body")
.always();
HttpResponse<String> httpResponse = httpClient.sendAsync(httpClient.newHttpRequestBuilder()
.uri(server.url("/response-body"))
.build(), String.class).get(10, TimeUnit.SECONDS);
assertThat(httpResponse.bodyString()).isEqualTo("This is the response body");
}

@Test
@DisplayName("HTTP large response body is logged")
public void httpLargeResponseBodyLogged() throws Exception {
Expand Down

0 comments on commit fdce3ca

Please sign in to comment.