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 b8b79d4
Showing 1 changed file with 0 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.io.InputStream;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
Expand All @@ -32,7 +31,6 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -239,37 +237,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 b8b79d4

Please sign in to comment.