Commit f52b0b97 authored by Andy Wilkinson's avatar Andy Wilkinson

Update WebFlux auto-configuration following recent API changes

parent 99aa1554
...@@ -62,6 +62,7 @@ import org.springframework.web.reactive.resource.GzipResourceResolver; ...@@ -62,6 +62,7 @@ import org.springframework.web.reactive.resource.GzipResourceResolver;
import org.springframework.web.reactive.resource.ResourceResolver; import org.springframework.web.reactive.resource.ResourceResolver;
import org.springframework.web.reactive.resource.VersionResourceResolver; import org.springframework.web.reactive.resource.VersionResourceResolver;
import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver; import org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;
import org.springframework.web.reactive.result.view.ViewResolver; import org.springframework.web.reactive.result.view.ViewResolver;
/** /**
...@@ -70,6 +71,7 @@ import org.springframework.web.reactive.result.view.ViewResolver; ...@@ -70,6 +71,7 @@ import org.springframework.web.reactive.result.view.ViewResolver;
* @author Brian Clozel * @author Brian Clozel
* @author Rob Winch * @author Rob Winch
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Andy Wilkinson
* @since 2.0.0 * @since 2.0.0
*/ */
@Configuration @Configuration
...@@ -114,9 +116,9 @@ public class WebFluxAnnotationAutoConfiguration { ...@@ -114,9 +116,9 @@ public class WebFluxAnnotationAutoConfiguration {
} }
@Override @Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
if (this.argumentResolvers != null) { if (this.argumentResolvers != null) {
resolvers.addAll(this.argumentResolvers); this.argumentResolvers.stream().forEach(configurer::addCustomResolver);
} }
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.web.reactive; package org.springframework.boot.autoconfigure.web.reactive;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import javax.validation.ValidatorFactory; import javax.validation.ValidatorFactory;
...@@ -34,6 +35,7 @@ import org.springframework.core.Ordered; ...@@ -34,6 +35,7 @@ import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.validation.Validator; import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.validation.beanvalidation.SpringValidatorAdapter; import org.springframework.validation.beanvalidation.SpringValidatorAdapter;
...@@ -59,6 +61,7 @@ import static org.mockito.Mockito.mock; ...@@ -59,6 +61,7 @@ import static org.mockito.Mockito.mock;
* Tests for {@link WebFluxAnnotationAutoConfiguration}. * Tests for {@link WebFluxAnnotationAutoConfiguration}.
* *
* @author Brian Clozel * @author Brian Clozel
* @author Andy Wilkinson
*/ */
public class WebFluxAnnotationAutoConfigurationTests { public class WebFluxAnnotationAutoConfigurationTests {
...@@ -86,16 +89,19 @@ public class WebFluxAnnotationAutoConfigurationTests { ...@@ -86,16 +89,19 @@ public class WebFluxAnnotationAutoConfigurationTests {
.isNotNull(); .isNotNull();
} }
@SuppressWarnings("unchecked")
@Test @Test
public void shouldRegisterCustomHandlerMethodArgumentResolver() throws Exception { public void shouldRegisterCustomHandlerMethodArgumentResolver() throws Exception {
load(CustomArgumentResolvers.class); load(CustomArgumentResolvers.class);
RequestMappingHandlerAdapter adapter = this.context RequestMappingHandlerAdapter adapter = this.context
.getBean(RequestMappingHandlerAdapter.class); .getBean(RequestMappingHandlerAdapter.class);
assertThat(adapter.getCustomArgumentResolvers()).contains( assertThat((List<HandlerMethodArgumentResolver>) ReflectionTestUtils
this.context.getBean("firstResolver", .getField(adapter.getArgumentResolverConfigurer(), "customResolvers"))
HandlerMethodArgumentResolver.class), .contains(
this.context.getBean("secondResolver", this.context.getBean("firstResolver",
HandlerMethodArgumentResolver.class)); HandlerMethodArgumentResolver.class),
this.context.getBean("secondResolver",
HandlerMethodArgumentResolver.class));
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment