WebTestClient supports customer argument resolvers
Issue: SPR-15495
This commit is contained in:
@@ -35,6 +35,7 @@ import org.springframework.web.reactive.config.DelegatingWebFluxConfiguration;
|
||||
import org.springframework.web.reactive.config.PathMatchConfigurer;
|
||||
import org.springframework.web.reactive.config.ViewResolverRegistry;
|
||||
import org.springframework.web.reactive.config.WebFluxConfigurer;
|
||||
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;
|
||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
|
||||
/**
|
||||
@@ -77,6 +78,12 @@ class DefaultControllerSpec extends AbstractMockServerSpec<WebTestClient.Control
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultControllerSpec argumentResolvers(Consumer<ArgumentResolverConfigurer> consumer) {
|
||||
this.configurer.argumentResolverConsumer = consumer;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultControllerSpec pathMatching(Consumer<PathMatchConfigurer> consumer) {
|
||||
this.configurer.pathMatchConsumer = consumer;
|
||||
@@ -136,6 +143,8 @@ class DefaultControllerSpec extends AbstractMockServerSpec<WebTestClient.Control
|
||||
|
||||
private Consumer<CorsRegistry> corsRegistryConsumer;
|
||||
|
||||
private Consumer<ArgumentResolverConfigurer> argumentResolverConsumer;
|
||||
|
||||
private Consumer<PathMatchConfigurer> pathMatchConsumer;
|
||||
|
||||
private Consumer<ServerCodecConfigurer> messageCodecsConsumer;
|
||||
@@ -168,6 +177,13 @@ class DefaultControllerSpec extends AbstractMockServerSpec<WebTestClient.Control
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
|
||||
if (this.argumentResolverConsumer != null) {
|
||||
this.argumentResolverConsumer.accept(configurer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
|
||||
if (this.messageCodecsConsumer != null) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.springframework.web.reactive.function.client.ExchangeFunction;
|
||||
import org.springframework.web.reactive.function.client.ExchangeStrategies;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.util.UriBuilder;
|
||||
@@ -243,7 +244,13 @@ public interface WebTestClient {
|
||||
ControllerSpec pathMatching(Consumer<PathMatchConfigurer> consumer);
|
||||
|
||||
/**
|
||||
* Modify or extend the list of built-in message readers and writers.
|
||||
* Configure resolvers for custom controller method arguments.
|
||||
* @see WebFluxConfigurer#configureHttpMessageCodecs
|
||||
*/
|
||||
ControllerSpec argumentResolvers(Consumer<ArgumentResolverConfigurer> configurer);
|
||||
|
||||
/**
|
||||
* Configure custom HTTP message readers and writers or override built-in ones.
|
||||
* @see WebFluxConfigurer#configureHttpMessageCodecs
|
||||
*/
|
||||
ControllerSpec httpMessageCodecs(Consumer<ServerCodecConfigurer> configurer);
|
||||
|
||||
Reference in New Issue
Block a user