Add BlockingExecutionConfigurer to WebFlux config

Closes gh-30678
This commit is contained in:
rstoyanchev
2023-07-12 16:54:45 +01:00
parent f40d1f2329
commit b016f385e1
10 changed files with 334 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.Validator;
import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder;
import org.springframework.web.reactive.config.BlockingExecutionConfigurer;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.DelegatingWebFluxConfiguration;
import org.springframework.web.reactive.config.PathMatchConfigurer;
@@ -122,6 +123,11 @@ class DefaultControllerSpec extends AbstractMockServerSpec<WebTestClient.Control
return this;
}
@Override
public WebTestClient.ControllerSpec blockingExecution(Consumer<BlockingExecutionConfigurer> consumer) {
this.configurer.executionConsumer = consumer;
return this;
}
@Override
protected WebHttpHandlerBuilder initHttpHandlerBuilder() {
@@ -145,7 +151,7 @@ class DefaultControllerSpec extends AbstractMockServerSpec<WebTestClient.Control
}
private class TestWebFluxConfigurer implements WebFluxConfigurer {
private static class TestWebFluxConfigurer implements WebFluxConfigurer {
@Nullable
private Consumer<RequestedContentTypeResolverBuilder> contentTypeResolverConsumer;
@@ -171,6 +177,9 @@ class DefaultControllerSpec extends AbstractMockServerSpec<WebTestClient.Control
@Nullable
private Consumer<ViewResolverRegistry> viewResolversConsumer;
@Nullable
private Consumer<BlockingExecutionConfigurer> executionConsumer;
@Override
public void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder) {
if (this.contentTypeResolverConsumer != null) {
@@ -225,6 +234,13 @@ class DefaultControllerSpec extends AbstractMockServerSpec<WebTestClient.Control
this.viewResolversConsumer.accept(registry);
}
}
@Override
public void configureBlockingExecution(BlockingExecutionConfigurer configurer) {
if (this.executionConsumer != null) {
this.executionConsumer.accept(configurer);
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ import org.springframework.lang.Nullable;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.Validator;
import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder;
import org.springframework.web.reactive.config.BlockingExecutionConfigurer;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.PathMatchConfigurer;
import org.springframework.web.reactive.config.ViewResolverRegistry;
@@ -353,6 +354,13 @@ public interface WebTestClient {
* @see WebFluxConfigurer#configureViewResolvers
*/
ControllerSpec viewResolvers(Consumer<ViewResolverRegistry> consumer);
/**
* Configure blocking execution options.
* @since 6.1
* @see WebFluxConfigurer#configureBlockingExecution
*/
ControllerSpec blockingExecution(Consumer<BlockingExecutionConfigurer> consumer);
}