Skip to content

Commit

Permalink
Drop exception handling test from AbstractInterceptorTest as its now …
Browse files Browse the repository at this point in the history
…better covered elsewhere.
  • Loading branch information
SamBarker committed Aug 9, 2024
1 parent e9e4b2c commit c49c1c5
Showing 1 changed file with 0 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,37 +239,6 @@ public void after(HttpRequest request, HttpResponse<?> response, Consumer<List<B
}
}

@Test
@DisplayName("afterConnectionFailure, completionExceptions are passed through")
public void afterConnectionFailureCompletionException() {
// Given
final CountDownLatch connectionFailureCallbackInvoked = new CountDownLatch(1);
final HttpClient.Builder builder = getHttpClientFactory().newBuilder()
.connectTimeout(1, TimeUnit.SECONDS)
.addOrReplaceInterceptor("test", new Interceptor() {
@Override
public void afterConnectionFailure(HttpRequest request, Throwable failure) {
connectionFailureCallbackInvoked.countDown();
}
});
// When
try (HttpClient client = builder.build()) {
final CompletableFuture<HttpResponse<String>> response = client.sendAsync(client.newHttpRequestBuilder()
.timeout(1, TimeUnit.SECONDS)
.uri(server.url("/intercepted-url"))
.method("POST", "application/json", new InputStream() {
@Override
public int read() {
throw new CompletionException("boom time", null); // gets propagated by jetty but gets wrapped by OkHttp
}
}, 1L).build(), String.class);

// Then
assertThat(response).failsWithin(FUTURE_COMPLETION_TIME);
assertThat(connectionFailureCallbackInvoked).extracting(CountDownLatch::getCount).isEqualTo(0L);
}
}

@Test
@DisplayName("afterFailure (HTTP), replaces the HttpResponse produced by HttpClient.consumeBytes")
public void afterHttpFailureReplacesResponseInConsumeBytes() throws Exception {
Expand Down

0 comments on commit c49c1c5

Please sign in to comment.