diff --git a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractInterceptorTest.java b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractInterceptorTest.java index f85ded10834..158d64eeea3 100644 --- a/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractInterceptorTest.java +++ b/kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/http/AbstractInterceptorTest.java @@ -25,6 +25,8 @@ import java.net.URI; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.List; import java.util.Set; @@ -170,6 +172,28 @@ public CompletableFuture afterFailure(BasicBuilder builder, HttpRespons } } + @Test + @DisplayName("afterFailure (HTTP), invoked when remote server offline") + public void afterHttpFailureRemoteOffline() { + // Given + server.shutdown(); + final HttpClient.Builder builder = getHttpClientFactory().newBuilder() + .connectTimeout(1, TimeUnit.SECONDS) + .addOrReplaceInterceptor("test", new Interceptor() { + @Override + public CompletableFuture afterFailure(BasicBuilder builder, HttpResponse response, RequestTags tags) { + return CompletableFuture.completedFuture(false); + } + }); + // When + try (HttpClient client = builder.build()) { + final CompletableFuture> response = client.sendAsync(client.newHttpRequestBuilder().uri(server.url("/not-found")).build(), String.class); + + // Then + assertThat(response).succeedsWithin(Duration.of(10, ChronoUnit.SECONDS)); + } + } + @Test @DisplayName("afterFailure (HTTP), replaces the HttpResponse produced by HttpClient.consumeBytes") public void afterHttpFailureReplacesResponseInConsumeBytes() throws Exception {