use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.
the class WebFluxConfigurationSupport method requestMappingHandlerAdapter.
@Bean
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
RequestMappingHandlerAdapter adapter = createRequestMappingHandlerAdapter();
adapter.setMessageReaders(getMessageReaders());
adapter.setWebBindingInitializer(getConfigurableWebBindingInitializer());
adapter.setReactiveAdapterRegistry(webFluxAdapterRegistry());
List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
addArgumentResolvers(resolvers);
if (!resolvers.isEmpty()) {
adapter.setCustomArgumentResolvers(resolvers);
}
return adapter;
}
use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.
the class WebFluxConfigurationSupportTests method requestMappingHandlerAdapter.
@Test
public void requestMappingHandlerAdapter() {
ApplicationContext context = loadConfig(WebFluxConfig.class);
String name = "requestMappingHandlerAdapter";
RequestMappingHandlerAdapter adapter = context.getBean(name, RequestMappingHandlerAdapter.class);
assertThat(adapter).isNotNull();
List<HttpMessageReader<?>> readers = adapter.getMessageReaders();
assertThat(readers.size()).isEqualTo(14);
ResolvableType multiValueMapType = forClassWithGenerics(MultiValueMap.class, String.class, String.class);
assertHasMessageReader(readers, forClass(byte[].class), APPLICATION_OCTET_STREAM);
assertHasMessageReader(readers, forClass(ByteBuffer.class), APPLICATION_OCTET_STREAM);
assertHasMessageReader(readers, forClass(String.class), TEXT_PLAIN);
assertHasMessageReader(readers, forClass(Resource.class), IMAGE_PNG);
assertHasMessageReader(readers, forClass(Message.class), new MediaType("application", "x-protobuf"));
assertHasMessageReader(readers, multiValueMapType, APPLICATION_FORM_URLENCODED);
assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_XML);
assertHasMessageReader(readers, forClass(TestBean.class), APPLICATION_JSON);
assertHasMessageReader(readers, forClass(TestBean.class), new MediaType("application", "x-jackson-smile"));
assertHasMessageReader(readers, forClass(TestBean.class), null);
WebBindingInitializer bindingInitializer = adapter.getWebBindingInitializer();
assertThat(bindingInitializer).isNotNull();
WebExchangeDataBinder binder = new WebExchangeDataBinder(new Object());
bindingInitializer.initBinder(binder);
name = "webFluxConversionService";
ConversionService service = context.getBean(name, ConversionService.class);
assertThat(binder.getConversionService()).isSameAs(service);
name = "webFluxValidator";
Validator validator = context.getBean(name, Validator.class);
assertThat(binder.getValidator()).isSameAs(validator);
}
use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.
the class WebFluxConfigurationSupportTests method customMessageConverterConfig.
@Test
public void customMessageConverterConfig() {
ApplicationContext context = loadConfig(CustomMessageConverterConfig.class);
String name = "requestMappingHandlerAdapter";
RequestMappingHandlerAdapter adapter = context.getBean(name, RequestMappingHandlerAdapter.class);
assertThat(adapter).isNotNull();
List<HttpMessageReader<?>> messageReaders = adapter.getMessageReaders();
assertThat(messageReaders.size()).isEqualTo(2);
assertHasMessageReader(messageReaders, forClass(String.class), TEXT_PLAIN);
assertHasMessageReader(messageReaders, forClass(TestBean.class), APPLICATION_XML);
}
use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.
the class DelegatingWebFluxConfigurationIntegrationTests method requestMappingHandlerAdapterWithPrimaryUsesQualifiedValidator.
@Test
void requestMappingHandlerAdapterWithPrimaryUsesQualifiedValidator() {
load(registerPrimaryBean("testValidator", Validator.class));
RequestMappingHandlerAdapter mappingHandlerAdapter = this.context.getBean(RequestMappingHandlerAdapter.class);
assertThat(mappingHandlerAdapter.getWebBindingInitializer()).hasFieldOrPropertyWithValue("validator", this.context.getBean("webFluxValidator"));
assertThat(this.context.getBeansOfType(Validator.class)).containsOnlyKeys("webFluxValidator", "testValidator");
}
use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.
the class DelegatingWebFluxConfigurationIntegrationTests method requestMappingHandlerAdapterUsesWebFluxInfrastructureByDefault.
@Test
void requestMappingHandlerAdapterUsesWebFluxInfrastructureByDefault() {
load(context -> {
});
RequestMappingHandlerAdapter mappingHandlerAdapter = this.context.getBean(RequestMappingHandlerAdapter.class);
assertThat(mappingHandlerAdapter.getReactiveAdapterRegistry()).isSameAs(this.context.getBean("webFluxAdapterRegistry"));
assertThat(mappingHandlerAdapter.getWebBindingInitializer()).hasFieldOrPropertyWithValue("conversionService", this.context.getBean("webFluxConversionService"));
assertThat(mappingHandlerAdapter.getWebBindingInitializer()).hasFieldOrPropertyWithValue("validator", this.context.getBean("webFluxValidator"));
}
Aggregations