Rename classes and methods containing "WebReactive"
Issue: SPR-15190
This commit is contained in:
parent
123ee5f2da
commit
7399956708
|
|
@ -30,23 +30,23 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuild
|
|||
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver;
|
||||
|
||||
/**
|
||||
* A subclass of {@code WebReactiveConfigurationSupport} that detects and delegates
|
||||
* to all beans of type {@link WebReactiveConfigurer} allowing them to customize the
|
||||
* configuration provided by {@code WebReactiveConfigurationSupport}. This is the
|
||||
* class actually imported by {@link EnableWebReactive @EnableWebReactive}.
|
||||
* A subclass of {@code WebFluxConfigurationSupport} that detects and delegates
|
||||
* to all beans of type {@link WebFluxConfigurer} allowing them to customize the
|
||||
* configuration provided by {@code WebFluxConfigurationSupport}. This is the
|
||||
* class actually imported by {@link EnableWebFlux @EnableWebFlux}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 5.0
|
||||
*/
|
||||
@Configuration
|
||||
public class DelegatingWebReactiveConfiguration extends WebReactiveConfigurationSupport {
|
||||
public class DelegatingWebFluxConfiguration extends WebFluxConfigurationSupport {
|
||||
|
||||
private final WebReactiveConfigurerComposite configurers = new WebReactiveConfigurerComposite();
|
||||
private final WebFluxConfigurerComposite configurers = new WebFluxConfigurerComposite();
|
||||
|
||||
@Autowired(required = false)
|
||||
public void setConfigurers(List<WebReactiveConfigurer> configurers) {
|
||||
public void setConfigurers(List<WebFluxConfigurer> configurers) {
|
||||
if (!CollectionUtils.isEmpty(configurers)) {
|
||||
this.configurers.addWebReactiveConfigurers(configurers);
|
||||
this.configurers.addWebFluxConfigurers(configurers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -26,11 +26,11 @@ import org.springframework.context.annotation.Import;
|
|||
|
||||
/**
|
||||
* Adding this annotation to an {@code @Configuration} class imports the Spring Web
|
||||
* Reactive configuration from {@link WebReactiveConfigurationSupport}, e.g.:
|
||||
* Reactive configuration from {@link WebFluxConfigurationSupport}, e.g.:
|
||||
*
|
||||
* <pre class="code">
|
||||
* @Configuration
|
||||
* @EnableWebReactive
|
||||
* @EnableWebFlux
|
||||
* @ComponentScan(basePackageClasses = MyConfiguration.class)
|
||||
* public class MyConfiguration {
|
||||
*
|
||||
|
|
@ -38,13 +38,13 @@ import org.springframework.context.annotation.Import;
|
|||
* </pre>
|
||||
*
|
||||
* <p>To customize the imported configuration implement
|
||||
* {@link WebReactiveConfigurer} and override individual methods as shown below:
|
||||
* {@link WebFluxConfigurer} and override individual methods as shown below:
|
||||
*
|
||||
* <pre class="code">
|
||||
* @Configuration
|
||||
* @EnableWebReactive
|
||||
* @EnableWebFlux
|
||||
* @ComponentScan(basePackageClasses = MyConfiguration.class)
|
||||
* public class MyConfiguration implements WebReactiveConfigurer {
|
||||
* public class MyConfiguration implements WebFluxConfigurer {
|
||||
*
|
||||
* @Override
|
||||
* public void addFormatters(FormatterRegistry formatterRegistry) {
|
||||
|
|
@ -60,26 +60,26 @@ import org.springframework.context.annotation.Import;
|
|||
* </pre>
|
||||
*
|
||||
* <p><strong>Note:</strong> only one {@code @Configuration} class may have the
|
||||
* {@code @EnableWebReactive} annotation to import the Spring Web Reactive
|
||||
* {@code @EnableWebFlux} annotation to import the Spring Web Reactive
|
||||
* configuration. There can however be multiple {@code @Configuration} classes
|
||||
* implementing {@code WebReactiveConfigurer} in order to customize the provided
|
||||
* implementing {@code WebFluxConfigurer} in order to customize the provided
|
||||
* configuration.
|
||||
*
|
||||
* <p>If {@link WebReactiveConfigurer} does not expose some more advanced setting
|
||||
* that needs to be configured consider removing the {@code @EnableWebReactive}
|
||||
* annotation and extending directly from {@link WebReactiveConfigurationSupport}
|
||||
* or {@link DelegatingWebReactiveConfiguration} if you still want to allow
|
||||
* {@link WebReactiveConfigurer} instances to customize the configuration.
|
||||
* <p>If {@link WebFluxConfigurer} does not expose some more advanced setting
|
||||
* that needs to be configured consider removing the {@code @EnableWebFlux}
|
||||
* annotation and extending directly from {@link WebFluxConfigurationSupport}
|
||||
* or {@link DelegatingWebFluxConfiguration} if you still want to allow
|
||||
* {@link WebFluxConfigurer} instances to customize the configuration.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
* @see WebReactiveConfigurer
|
||||
* @see WebReactiveConfigurationSupport
|
||||
* @see WebFluxConfigurer
|
||||
* @see WebFluxConfigurationSupport
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Documented
|
||||
@Import(DelegatingWebReactiveConfiguration.class)
|
||||
public @interface EnableWebReactive {
|
||||
@Import(DelegatingWebFluxConfiguration.class)
|
||||
public @interface EnableWebFlux {
|
||||
}
|
||||
|
|
@ -90,16 +90,16 @@ import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
*/
|
||||
public class WebReactiveConfigurationSupport implements ApplicationContextAware {
|
||||
public class WebFluxConfigurationSupport implements ApplicationContextAware {
|
||||
|
||||
private static final boolean jackson2Present =
|
||||
ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper",
|
||||
WebReactiveConfigurationSupport.class.getClassLoader()) &&
|
||||
WebFluxConfigurationSupport.class.getClassLoader()) &&
|
||||
ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator",
|
||||
WebReactiveConfigurationSupport.class.getClassLoader());
|
||||
WebFluxConfigurationSupport.class.getClassLoader());
|
||||
|
||||
private static final boolean jaxb2Present =
|
||||
ClassUtils.isPresent("javax.xml.bind.Binder", WebReactiveConfigurationSupport.class.getClassLoader());
|
||||
ClassUtils.isPresent("javax.xml.bind.Binder", WebFluxConfigurationSupport.class.getClassLoader());
|
||||
|
||||
|
||||
private Map<String, CorsConfiguration> corsConfigurations;
|
||||
|
|
@ -138,7 +138,7 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
|
||||
RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping();
|
||||
mapping.setOrder(0);
|
||||
mapping.setContentTypeResolver(webReactiveContentTypeResolver());
|
||||
mapping.setContentTypeResolver(webFluxContentTypeResolver());
|
||||
mapping.setCorsConfigurations(getCorsConfigurations());
|
||||
|
||||
PathMatchConfigurer configurer = getPathMatchConfigurer();
|
||||
|
|
@ -169,7 +169,7 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
}
|
||||
|
||||
@Bean
|
||||
public CompositeContentTypeResolver webReactiveContentTypeResolver() {
|
||||
public CompositeContentTypeResolver webFluxContentTypeResolver() {
|
||||
RequestedContentTypeResolverBuilder builder = new RequestedContentTypeResolverBuilder();
|
||||
builder.mediaTypes(getDefaultMediaTypeMappings());
|
||||
configureContentTypeResolver(builder);
|
||||
|
|
@ -240,7 +240,7 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
@Bean
|
||||
public HandlerMapping resourceHandlerMapping() {
|
||||
ResourceHandlerRegistry registry =
|
||||
new ResourceHandlerRegistry(this.applicationContext, webReactiveContentTypeResolver());
|
||||
new ResourceHandlerRegistry(this.applicationContext, webFluxContentTypeResolver());
|
||||
addResourceHandlers(registry);
|
||||
|
||||
AbstractHandlerMapping handlerMapping = registry.getHandlerMapping();
|
||||
|
|
@ -271,7 +271,7 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
RequestMappingHandlerAdapter adapter = createRequestMappingHandlerAdapter();
|
||||
adapter.setMessageReaders(getMessageReaders());
|
||||
adapter.setWebBindingInitializer(getConfigurableWebBindingInitializer());
|
||||
adapter.setReactiveAdapterRegistry(webReactiveAdapterRegistry());
|
||||
adapter.setReactiveAdapterRegistry(webFluxAdapterRegistry());
|
||||
|
||||
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
|
||||
addArgumentResolvers(resolvers);
|
||||
|
|
@ -357,14 +357,14 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
*/
|
||||
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() {
|
||||
ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
|
||||
initializer.setConversionService(webReactiveConversionService());
|
||||
initializer.setValidator(webReactiveValidator());
|
||||
initializer.setConversionService(webFluxConversionService());
|
||||
initializer.setValidator(webFluxValidator());
|
||||
initializer.setMessageCodesResolver(getMessageCodesResolver());
|
||||
return initializer;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FormattingConversionService webReactiveConversionService() {
|
||||
public FormattingConversionService webFluxConversionService() {
|
||||
FormattingConversionService service = new DefaultFormattingConversionService();
|
||||
addFormatters(service);
|
||||
return service;
|
||||
|
|
@ -380,7 +380,7 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
* Return a {@link ReactiveAdapterRegistry} to adapting reactive types.
|
||||
*/
|
||||
@Bean
|
||||
public ReactiveAdapterRegistry webReactiveAdapterRegistry() {
|
||||
public ReactiveAdapterRegistry webFluxAdapterRegistry() {
|
||||
return new ReactiveAdapterRegistry();
|
||||
}
|
||||
|
||||
|
|
@ -393,7 +393,7 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
* implementation is not available, a "no-op" {@link Validator} is returned.
|
||||
*/
|
||||
@Bean
|
||||
public Validator webReactiveValidator() {
|
||||
public Validator webFluxValidator() {
|
||||
Validator validator = getValidator();
|
||||
if (validator == null) {
|
||||
if (ClassUtils.isPresent("javax.validation.Validator", getClass().getClassLoader())) {
|
||||
|
|
@ -439,13 +439,13 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
@Bean
|
||||
public ResponseEntityResultHandler responseEntityResultHandler() {
|
||||
return new ResponseEntityResultHandler(
|
||||
getMessageWriters(), webReactiveContentTypeResolver(), webReactiveAdapterRegistry());
|
||||
getMessageWriters(), webFluxContentTypeResolver(), webFluxAdapterRegistry());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ResponseBodyResultHandler responseBodyResultHandler() {
|
||||
return new ResponseBodyResultHandler(
|
||||
getMessageWriters(), webReactiveContentTypeResolver(), webReactiveAdapterRegistry());
|
||||
getMessageWriters(), webFluxContentTypeResolver(), webFluxAdapterRegistry());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -512,7 +512,7 @@ public class WebReactiveConfigurationSupport implements ApplicationContextAware
|
|||
configureViewResolvers(registry);
|
||||
List<ViewResolver> resolvers = registry.getViewResolvers();
|
||||
ViewResolutionResultHandler handler = new ViewResolutionResultHandler(
|
||||
resolvers, webReactiveContentTypeResolver(), webReactiveAdapterRegistry());
|
||||
resolvers, webFluxContentTypeResolver(), webFluxAdapterRegistry());
|
||||
handler.setDefaultViews(registry.getDefaultViews());
|
||||
handler.setOrder(registry.getOrder());
|
||||
return handler;
|
||||
|
|
@ -33,9 +33,9 @@ import org.springframework.web.reactive.result.method.HandlerMethodArgumentResol
|
|||
|
||||
/**
|
||||
* Defines callback methods to customize the configuration for Web Reactive
|
||||
* applications enabled via {@code @EnableWebReactive}.
|
||||
* applications enabled via {@code @EnableWebFlux}.
|
||||
*
|
||||
* <p>{@code @EnableWebReactive}-annotated configuration classes may implement
|
||||
* <p>{@code @EnableWebFlux}-annotated configuration classes may implement
|
||||
* this interface to be called back and given a chance to customize the
|
||||
* default configuration. Consider implementing this interface and
|
||||
* overriding the relevant methods for your needs.
|
||||
|
|
@ -44,7 +44,7 @@ import org.springframework.web.reactive.result.method.HandlerMethodArgumentResol
|
|||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
*/
|
||||
public interface WebReactiveConfigurer {
|
||||
public interface WebFluxConfigurer {
|
||||
|
||||
/**
|
||||
* Configure how the content type requested for the response is resolved.
|
||||
|
|
@ -92,7 +92,7 @@ public interface WebReactiveConfigurer {
|
|||
* Configure the message readers to use for decoding the request body where
|
||||
* {@code @RequestBody} and {@code HttpEntity} controller method arguments
|
||||
* are used. If none are specified, default ones are added based on
|
||||
* {@link WebReactiveConfigurationSupport#addDefaultHttpMessageReaders}.
|
||||
* {@link WebFluxConfigurationSupport#addDefaultHttpMessageReaders}.
|
||||
* <p>See {@link #extendMessageReaders(List)} for adding readers
|
||||
* in addition to the default ones.
|
||||
* @param readers an empty list to add message readers to
|
||||
|
|
@ -136,7 +136,7 @@ public interface WebReactiveConfigurer {
|
|||
* Configure the message writers to use to encode the response body based on
|
||||
* the return values of {@code @ResponseBody}, and {@code ResponseEntity}
|
||||
* controller methods. If none are specified, default ones are added based on
|
||||
* {@link WebReactiveConfigurationSupport#addDefaultHttpMessageWriters(List)}.
|
||||
* {@link WebFluxConfigurationSupport#addDefaultHttpMessageWriters(List)}.
|
||||
* <p>See {@link #extendMessageWriters(List)} for adding writers
|
||||
* in addition to the default ones.
|
||||
* @param writers a empty list to add message writers to
|
||||
|
|
@ -32,18 +32,18 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuild
|
|||
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver;
|
||||
|
||||
/**
|
||||
* A {@link WebReactiveConfigurer} that delegates to one or more others.
|
||||
* A {@link WebFluxConfigurer} that delegates to one or more others.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
*/
|
||||
public class WebReactiveConfigurerComposite implements WebReactiveConfigurer {
|
||||
public class WebFluxConfigurerComposite implements WebFluxConfigurer {
|
||||
|
||||
private final List<WebReactiveConfigurer> delegates = new ArrayList<>();
|
||||
private final List<WebFluxConfigurer> delegates = new ArrayList<>();
|
||||
|
||||
|
||||
public void addWebReactiveConfigurers(List<WebReactiveConfigurer> configurers) {
|
||||
public void addWebFluxConfigurers(List<WebFluxConfigurer> configurers) {
|
||||
if (!CollectionUtils.isEmpty(configurers)) {
|
||||
this.delegates.addAll(configurers);
|
||||
}
|
||||
|
|
@ -92,12 +92,12 @@ public class WebReactiveConfigurerComposite implements WebReactiveConfigurer {
|
|||
|
||||
@Override
|
||||
public Optional<Validator> getValidator() {
|
||||
return createSingleBean(WebReactiveConfigurer::getValidator, Validator.class);
|
||||
return createSingleBean(WebFluxConfigurer::getValidator, Validator.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<MessageCodesResolver> getMessageCodesResolver() {
|
||||
return createSingleBean(WebReactiveConfigurer::getMessageCodesResolver, MessageCodesResolver.class);
|
||||
return createSingleBean(WebFluxConfigurer::getMessageCodesResolver, MessageCodesResolver.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -115,7 +115,7 @@ public class WebReactiveConfigurerComposite implements WebReactiveConfigurer {
|
|||
this.delegates.stream().forEach(delegate -> delegate.configureViewResolvers(registry));
|
||||
}
|
||||
|
||||
private <T> Optional<T> createSingleBean(Function<WebReactiveConfigurer, Optional<T>> factory,
|
||||
private <T> Optional<T> createSingleBean(Function<WebFluxConfigurer, Optional<T>> factory,
|
||||
Class<T> beanType) {
|
||||
|
||||
List<Optional<T>> result = this.delegates.stream()
|
||||
|
|
@ -128,7 +128,7 @@ public class WebReactiveConfigurerComposite implements WebReactiveConfigurer {
|
|||
return result.get(0);
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("More than one WebReactiveConfigurer implements " +
|
||||
throw new IllegalStateException("More than one WebFluxConfigurer implements " +
|
||||
beanType.getSimpleName() + " factory method.");
|
||||
}
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ import org.springframework.web.server.ServerWebExchange;
|
|||
* <p>In order to serve manifest files with the proper {@code "text/manifest"} content type,
|
||||
* it is required to configure it with
|
||||
* {@code requestedContentTypeResolverBuilder.mediaType("appcache", MediaType.valueOf("text/manifest")}
|
||||
* in {@code WebReactiveConfiguration.configureContentTypeResolver()}.
|
||||
* in {@code WebFluxConfigurer.configureContentTypeResolver()}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
|
|
|
|||
|
|
@ -46,16 +46,16 @@ import static org.mockito.BDDMockito.given;
|
|||
import static org.mockito.BDDMockito.verify;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link DelegatingWebReactiveConfiguration} tests.
|
||||
* Test fixture for {@link DelegatingWebFluxConfiguration} tests.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class DelegatingWebReactiveConfigurationTests {
|
||||
public class DelegatingWebFluxConfigurationTests {
|
||||
|
||||
private DelegatingWebReactiveConfiguration delegatingConfig;
|
||||
private DelegatingWebFluxConfiguration delegatingConfig;
|
||||
|
||||
@Mock
|
||||
private WebReactiveConfigurer webReactiveConfigurer;
|
||||
private WebFluxConfigurer webFluxConfigurer;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<List<HttpMessageReader<?>>> readers;
|
||||
|
|
@ -70,38 +70,38 @@ public class DelegatingWebReactiveConfigurationTests {
|
|||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
delegatingConfig = new DelegatingWebReactiveConfiguration();
|
||||
delegatingConfig = new DelegatingWebFluxConfiguration();
|
||||
delegatingConfig.setApplicationContext(new StaticApplicationContext());
|
||||
given(webReactiveConfigurer.getValidator()).willReturn(Optional.empty());
|
||||
given(webReactiveConfigurer.getMessageCodesResolver()).willReturn(Optional.empty());
|
||||
given(webFluxConfigurer.getValidator()).willReturn(Optional.empty());
|
||||
given(webFluxConfigurer.getMessageCodesResolver()).willReturn(Optional.empty());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void requestMappingHandlerMapping() throws Exception {
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webReactiveConfigurer));
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer));
|
||||
delegatingConfig.requestMappingHandlerMapping();
|
||||
|
||||
verify(webReactiveConfigurer).configureContentTypeResolver(any(RequestedContentTypeResolverBuilder.class));
|
||||
verify(webReactiveConfigurer).addCorsMappings(any(CorsRegistry.class));
|
||||
verify(webReactiveConfigurer).configurePathMatching(any(PathMatchConfigurer.class));
|
||||
verify(webFluxConfigurer).configureContentTypeResolver(any(RequestedContentTypeResolverBuilder.class));
|
||||
verify(webFluxConfigurer).addCorsMappings(any(CorsRegistry.class));
|
||||
verify(webFluxConfigurer).configurePathMatching(any(PathMatchConfigurer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestMappingHandlerAdapter() throws Exception {
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webReactiveConfigurer));
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer));
|
||||
RequestMappingHandlerAdapter adapter = delegatingConfig.requestMappingHandlerAdapter();
|
||||
|
||||
ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) adapter.getWebBindingInitializer();
|
||||
ConversionService initializerConversionService = initializer.getConversionService();
|
||||
assertTrue(initializer.getValidator() instanceof LocalValidatorFactoryBean);
|
||||
|
||||
verify(webReactiveConfigurer).configureMessageReaders(readers.capture());
|
||||
verify(webReactiveConfigurer).extendMessageReaders(readers.capture());
|
||||
verify(webReactiveConfigurer).getValidator();
|
||||
verify(webReactiveConfigurer).getMessageCodesResolver();
|
||||
verify(webReactiveConfigurer).addFormatters(formatterRegistry.capture());
|
||||
verify(webReactiveConfigurer).addArgumentResolvers(any());
|
||||
verify(webFluxConfigurer).configureMessageReaders(readers.capture());
|
||||
verify(webFluxConfigurer).extendMessageReaders(readers.capture());
|
||||
verify(webFluxConfigurer).getValidator();
|
||||
verify(webFluxConfigurer).getMessageCodesResolver();
|
||||
verify(webFluxConfigurer).addFormatters(formatterRegistry.capture());
|
||||
verify(webFluxConfigurer).addArgumentResolvers(any());
|
||||
|
||||
assertSame(formatterRegistry.getValue(), initializerConversionService);
|
||||
assertEquals(7, readers.getValue().size());
|
||||
|
|
@ -109,34 +109,34 @@ public class DelegatingWebReactiveConfigurationTests {
|
|||
|
||||
@Test
|
||||
public void resourceHandlerMapping() throws Exception {
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webReactiveConfigurer));
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer));
|
||||
doAnswer(invocation -> {
|
||||
ResourceHandlerRegistry registry = invocation.getArgument(0);
|
||||
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static");
|
||||
return null;
|
||||
}).when(webReactiveConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class));
|
||||
}).when(webFluxConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class));
|
||||
|
||||
delegatingConfig.resourceHandlerMapping();
|
||||
verify(webReactiveConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class));
|
||||
verify(webReactiveConfigurer).configurePathMatching(any(PathMatchConfigurer.class));
|
||||
verify(webFluxConfigurer).addResourceHandlers(any(ResourceHandlerRegistry.class));
|
||||
verify(webFluxConfigurer).configurePathMatching(any(PathMatchConfigurer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void responseBodyResultHandler() throws Exception {
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webReactiveConfigurer));
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer));
|
||||
delegatingConfig.responseBodyResultHandler();
|
||||
|
||||
verify(webReactiveConfigurer).configureMessageWriters(writers.capture());
|
||||
verify(webReactiveConfigurer).extendMessageWriters(writers.capture());
|
||||
verify(webReactiveConfigurer).configureContentTypeResolver(any(RequestedContentTypeResolverBuilder.class));
|
||||
verify(webFluxConfigurer).configureMessageWriters(writers.capture());
|
||||
verify(webFluxConfigurer).extendMessageWriters(writers.capture());
|
||||
verify(webFluxConfigurer).configureContentTypeResolver(any(RequestedContentTypeResolverBuilder.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void viewResolutionResultHandler() throws Exception {
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webReactiveConfigurer));
|
||||
delegatingConfig.setConfigurers(Collections.singletonList(webFluxConfigurer));
|
||||
delegatingConfig.viewResolutionResultHandler();
|
||||
|
||||
verify(webReactiveConfigurer).configureViewResolvers(any(ViewResolverRegistry.class));
|
||||
verify(webFluxConfigurer).configureViewResolvers(any(ViewResolverRegistry.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -78,10 +78,10 @@ import static org.springframework.http.MediaType.IMAGE_PNG;
|
|||
import static org.springframework.http.MediaType.TEXT_PLAIN;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link WebReactiveConfigurationSupport}.
|
||||
* Unit tests for {@link WebFluxConfigurationSupport}.
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class WebReactiveConfigurationSupportTests {
|
||||
public class WebFluxConfigurationSupportTests {
|
||||
|
||||
private MockServerHttpRequest request;
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
|
||||
@Test
|
||||
public void requestMappingHandlerMapping() throws Exception {
|
||||
ApplicationContext context = loadConfig(WebReactiveConfig.class);
|
||||
ApplicationContext context = loadConfig(WebFluxConfig.class);
|
||||
|
||||
String name = "requestMappingHandlerMapping";
|
||||
RequestMappingHandlerMapping mapping = context.getBean(name, RequestMappingHandlerMapping.class);
|
||||
|
|
@ -106,7 +106,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
assertTrue(mapping.useTrailingSlashMatch());
|
||||
assertTrue(mapping.useRegisteredSuffixPatternMatch());
|
||||
|
||||
name = "webReactiveContentTypeResolver";
|
||||
name = "webFluxContentTypeResolver";
|
||||
RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
|
||||
assertSame(resolver, mapping.getContentTypeResolver());
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
|
||||
@Test
|
||||
public void requestMappingHandlerAdapter() throws Exception {
|
||||
ApplicationContext context = loadConfig(WebReactiveConfig.class);
|
||||
ApplicationContext context = loadConfig(WebFluxConfig.class);
|
||||
|
||||
String name = "requestMappingHandlerAdapter";
|
||||
RequestMappingHandlerAdapter adapter = context.getBean(name, RequestMappingHandlerAdapter.class);
|
||||
|
|
@ -154,11 +154,11 @@ public class WebReactiveConfigurationSupportTests {
|
|||
WebExchangeDataBinder binder = new WebExchangeDataBinder(new Object());
|
||||
bindingInitializer.initBinder(binder);
|
||||
|
||||
name = "webReactiveConversionService";
|
||||
name = "webFluxConversionService";
|
||||
ConversionService service = context.getBean(name, ConversionService.class);
|
||||
assertSame(service, binder.getConversionService());
|
||||
|
||||
name = "webReactiveValidator";
|
||||
name = "webFluxValidator";
|
||||
Validator validator = context.getBean(name, Validator.class);
|
||||
assertSame(validator, binder.getValidator());
|
||||
}
|
||||
|
|
@ -180,7 +180,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
|
||||
@Test
|
||||
public void responseEntityResultHandler() throws Exception {
|
||||
ApplicationContext context = loadConfig(WebReactiveConfig.class);
|
||||
ApplicationContext context = loadConfig(WebFluxConfig.class);
|
||||
|
||||
String name = "responseEntityResultHandler";
|
||||
ResponseEntityResultHandler handler = context.getBean(name, ResponseEntityResultHandler.class);
|
||||
|
|
@ -199,14 +199,14 @@ public class WebReactiveConfigurationSupportTests {
|
|||
assertHasMessageWriter(writers, TestBean.class, APPLICATION_JSON);
|
||||
assertHasMessageWriter(writers, TestBean.class, MediaType.parseMediaType("text/event-stream"));
|
||||
|
||||
name = "webReactiveContentTypeResolver";
|
||||
name = "webFluxContentTypeResolver";
|
||||
RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
|
||||
assertSame(resolver, handler.getContentTypeResolver());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void responseBodyResultHandler() throws Exception {
|
||||
ApplicationContext context = loadConfig(WebReactiveConfig.class);
|
||||
ApplicationContext context = loadConfig(WebFluxConfig.class);
|
||||
|
||||
String name = "responseBodyResultHandler";
|
||||
ResponseBodyResultHandler handler = context.getBean(name, ResponseBodyResultHandler.class);
|
||||
|
|
@ -225,7 +225,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
assertHasMessageWriter(writers, TestBean.class, APPLICATION_JSON);
|
||||
assertHasMessageWriter(writers, TestBean.class, null);
|
||||
|
||||
name = "webReactiveContentTypeResolver";
|
||||
name = "webFluxContentTypeResolver";
|
||||
RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
|
||||
assertSame(resolver, handler.getContentTypeResolver());
|
||||
}
|
||||
|
|
@ -298,12 +298,12 @@ public class WebReactiveConfigurationSupportTests {
|
|||
return context;
|
||||
}
|
||||
|
||||
@EnableWebReactive
|
||||
static class WebReactiveConfig {
|
||||
@EnableWebFlux
|
||||
static class WebFluxConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomPatchMatchConfig extends WebReactiveConfigurationSupport {
|
||||
static class CustomPatchMatchConfig extends WebFluxConfigurationSupport {
|
||||
|
||||
@Override
|
||||
public void configurePathMatching(PathMatchConfigurer configurer) {
|
||||
|
|
@ -313,7 +313,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomMessageConverterConfig extends WebReactiveConfigurationSupport {
|
||||
static class CustomMessageConverterConfig extends WebFluxConfigurationSupport {
|
||||
|
||||
@Override
|
||||
protected void configureMessageReaders(List<HttpMessageReader<?>> messageReaders) {
|
||||
|
|
@ -338,7 +338,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
|
||||
@Configuration
|
||||
@SuppressWarnings("unused")
|
||||
static class CustomViewResolverConfig extends WebReactiveConfigurationSupport {
|
||||
static class CustomViewResolverConfig extends WebFluxConfigurationSupport {
|
||||
|
||||
@Override
|
||||
protected void configureViewResolvers(ViewResolverRegistry registry) {
|
||||
|
|
@ -354,7 +354,7 @@ public class WebReactiveConfigurationSupportTests {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
static class CustomResourceHandlingConfig extends WebReactiveConfigurationSupport {
|
||||
static class CustomResourceHandlingConfig extends WebFluxConfigurationSupport {
|
||||
|
||||
@Override
|
||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
|
|
@ -41,7 +41,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
import org.springframework.web.reactive.DispatcherHandler;
|
||||
import org.springframework.web.reactive.HandlerAdapter;
|
||||
import org.springframework.web.reactive.HandlerMapping;
|
||||
import org.springframework.web.reactive.config.WebReactiveConfigurationSupport;
|
||||
import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
|
||||
import org.springframework.web.reactive.function.server.support.HandlerFunctionAdapter;
|
||||
import org.springframework.web.reactive.function.server.support.ServerResponseResultHandler;
|
||||
import org.springframework.web.reactive.result.view.ViewResolver;
|
||||
|
|
@ -105,7 +105,7 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr
|
|||
|
||||
|
||||
@Configuration
|
||||
static class TestConfiguration extends WebReactiveConfigurationSupport {
|
||||
static class TestConfiguration extends WebFluxConfigurationSupport {
|
||||
|
||||
@Bean
|
||||
public PersonHandler personHandler() {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.support.WebExchangeDataBinder;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.reactive.BindingContext;
|
||||
import org.springframework.web.reactive.config.WebReactiveConfigurationSupport;
|
||||
import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
|
||||
import org.springframework.web.reactive.result.ResolvableMethod;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.adapter.DefaultServerWebExchange;
|
||||
|
|
@ -58,7 +58,7 @@ public class BindingContextFactoryTests {
|
|||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
WebReactiveConfigurationSupport configurationSupport = new WebReactiveConfigurationSupport();
|
||||
WebFluxConfigurationSupport configurationSupport = new WebFluxConfigurationSupport();
|
||||
configurationSupport.setApplicationContext(new StaticApplicationContext());
|
||||
RequestMappingHandlerAdapter adapter = configurationSupport.requestMappingHandlerAdapter();
|
||||
adapter.afterPropertiesSet();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.reactive.DispatcherHandler;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ public class ContextPathIntegrationTests {
|
|||
}
|
||||
|
||||
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@Configuration
|
||||
static class WebApp1Config {
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ public class ContextPathIntegrationTests {
|
|||
}
|
||||
}
|
||||
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@Configuration
|
||||
static class WebApp2Config {
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -222,7 +222,7 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin
|
|||
|
||||
|
||||
@Configuration
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@ComponentScan(resourcePattern = "**/CrossOriginAnnotationIntegrationTests*")
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.reactive.config.CorsRegistry;
|
||||
import org.springframework.web.reactive.config.WebReactiveConfigurationSupport;
|
||||
import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
|
@ -137,7 +137,7 @@ public class GlobalCorsConfigIntegrationTests extends AbstractRequestMappingInte
|
|||
@Configuration
|
||||
@ComponentScan(resourcePattern = "**/GlobalCorsConfigIntegrationTests*.class")
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig extends WebReactiveConfigurationSupport {
|
||||
static class WebConfig extends WebFluxConfigurationSupport {
|
||||
|
||||
@Override
|
||||
protected void addCorsMappings(CorsRegistry registry) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
/**
|
||||
* @author Sebastien Deleuze
|
||||
|
|
@ -93,7 +93,7 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat
|
|||
|
||||
@Configuration
|
||||
@ComponentScan(resourcePattern = "**/JacksonHintsIntegrationTests*.class")
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMa
|
|||
|
||||
|
||||
@Configuration
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@ComponentScan(resourcePattern = "**/RequestMappingDataBindingIntegrationTests*.class")
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
|
|||
|
||||
|
||||
@Configuration
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@ComponentScan(resourcePattern = "**/RequestMappingExceptionHandlingIntegrationTests$*.class")
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.springframework.http.MediaType;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -80,7 +80,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr
|
|||
|
||||
|
||||
@Configuration
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@ComponentScan(resourcePattern = "**/RequestMappingIntegrationTests$*.class")
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -380,7 +380,7 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq
|
|||
|
||||
|
||||
@Configuration
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@ComponentScan(resourcePattern = "**/RequestMappingMessageConversionIntegrationTests$*.class")
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.springframework.ui.Model;
|
|||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.reactive.config.ViewResolverRegistry;
|
||||
import org.springframework.web.reactive.config.WebReactiveConfigurationSupport;
|
||||
import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
|
||||
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
|
|||
@Configuration
|
||||
@ComponentScan(resourcePattern = "**/RequestMappingViewResolutionIntegrationTests$*.class")
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
static class WebConfig extends WebReactiveConfigurationSupport {
|
||||
static class WebConfig extends WebFluxConfigurationSupport {
|
||||
|
||||
@Override
|
||||
protected void configureViewResolvers(ViewResolverRegistry registry) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.springframework.http.server.reactive.HttpHandler;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.reactive.DispatcherHandler;
|
||||
import org.springframework.web.reactive.config.EnableWebReactive;
|
||||
import org.springframework.web.reactive.config.EnableWebFlux;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
@EnableWebReactive
|
||||
@EnableWebFlux
|
||||
@SuppressWarnings("unused")
|
||||
static class TestConfiguration {
|
||||
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ For the **annotation-based programming model** bootstrap with:
|
|||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(DelegatingWebReactiveConfiguration.class); // (1)
|
||||
ApplicationContext context = new AnnotationConfigApplicationContext(DelegatingWebFluxConfiguration.class); // (1)
|
||||
HttpHandler handler = DispatcherHandler.toHttpHandler(context); // (2)
|
||||
----
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue