Adapt to WebClient's new exception wrapping

See spring-projects/spring-framework#23842
See gh-23170
pull/23304/head
Andy Wilkinson 4 years ago
parent 76bf89ecd2
commit 7562c4eb6f

@ -42,6 +42,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.test.web.reactive.server.HttpHandlerConnector.FailureAfterResponseCompletedException;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -303,7 +304,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests {
WebTestClient client = getWebClient(context);
assertThatExceptionOfType(RuntimeException.class)
.isThrownBy(() -> client.get().uri("/commit").exchange().expectStatus())
.withCauseInstanceOf(IllegalStateException.class)
.withCauseInstanceOf(FailureAfterResponseCompletedException.class)
.withMessageContaining("Error occurred after response was completed");
});
}

@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLException;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
@ -72,6 +71,7 @@ import org.springframework.util.SocketUtils;
import org.springframework.util.unit.DataSize;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientRequestException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@ -269,7 +269,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
Mono<String> result = client.post().uri("/test").contentType(MediaType.TEXT_PLAIN)
.body(BodyInserters.fromValue("Hello World")).exchange()
.flatMap((response) -> response.bodyToMono(String.class));
StepVerifier.create(result).expectError(SSLException.class).verify(Duration.ofSeconds(10));
StepVerifier.create(result).expectError(WebClientRequestException.class).verify(Duration.ofSeconds(10));
}
protected WebClient.Builder getWebClient(int port) {

Loading…
Cancel
Save