Search in sources :

Example 6 with RequestMappingHandlerAdapter

use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.

the class DelegatingWebFluxConfigurationIntegrationTests method requestMappingHandlerAdapterWithPrimaryUsesQualifiedConversionService.

@Test
void requestMappingHandlerAdapterWithPrimaryUsesQualifiedConversionService() {
    load(registerPrimaryBean("testConversionService", FormattingConversionService.class));
    RequestMappingHandlerAdapter mappingHandlerAdapter = this.context.getBean(RequestMappingHandlerAdapter.class);
    assertThat(mappingHandlerAdapter.getWebBindingInitializer()).hasFieldOrPropertyWithValue("conversionService", this.context.getBean("webFluxConversionService"));
    assertThat(this.context.getBeansOfType(FormattingConversionService.class)).containsOnlyKeys("webFluxConversionService", "testConversionService");
}
Also used : FormattingConversionService(org.springframework.format.support.FormattingConversionService) RequestMappingHandlerAdapter(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter) Test(org.junit.jupiter.api.Test)

Example 7 with RequestMappingHandlerAdapter

use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-boot by spring-projects.

the class WebFluxAutoConfigurationTests method shouldRegisterCustomHandlerMethodArgumentResolver.

@SuppressWarnings("unchecked")
@Test
void shouldRegisterCustomHandlerMethodArgumentResolver() {
    this.contextRunner.withUserConfiguration(CustomArgumentResolvers.class).run((context) -> {
        RequestMappingHandlerAdapter adapter = context.getBean(RequestMappingHandlerAdapter.class);
        List<HandlerMethodArgumentResolver> customResolvers = (List<HandlerMethodArgumentResolver>) ReflectionTestUtils.getField(adapter.getArgumentResolverConfigurer(), "customResolvers");
        assertThat(customResolvers).contains(context.getBean("firstResolver", HandlerMethodArgumentResolver.class), context.getBean("secondResolver", HandlerMethodArgumentResolver.class));
    });
}
Also used : List(java.util.List) HandlerMethodArgumentResolver(org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver) RequestMappingHandlerAdapter(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with RequestMappingHandlerAdapter

use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-boot by spring-projects.

the class WebFluxAnnotationAutoConfigurationTests method shouldRegisterCustomHandlerMethodArgumentResolver.

@Test
public void shouldRegisterCustomHandlerMethodArgumentResolver() throws Exception {
    load(CustomArgumentResolvers.class);
    RequestMappingHandlerAdapter adapter = this.context.getBean(RequestMappingHandlerAdapter.class);
    assertThat(adapter.getArgumentResolvers()).contains(this.context.getBean("firstResolver", HandlerMethodArgumentResolver.class), this.context.getBean("secondResolver", HandlerMethodArgumentResolver.class));
}
Also used : HandlerMethodArgumentResolver(org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver) RequestMappingHandlerAdapter(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter) Test(org.junit.Test)

Example 9 with RequestMappingHandlerAdapter

use of org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.

the class DelegatingWebFluxConfigurationIntegrationTests method requestMappingHandlerAdapterWithPrimaryUsesQualifiedReactiveAdapterRegistry.

@Test
void requestMappingHandlerAdapterWithPrimaryUsesQualifiedReactiveAdapterRegistry() {
    load(registerPrimaryBean("testReactiveAdapterRegistry", ReactiveAdapterRegistry.class));
    RequestMappingHandlerAdapter mappingHandlerAdapter = this.context.getBean(RequestMappingHandlerAdapter.class);
    assertThat(mappingHandlerAdapter.getReactiveAdapterRegistry()).isSameAs(this.context.getBean("webFluxAdapterRegistry"));
    assertThat(this.context.getBeansOfType(ReactiveAdapterRegistry.class)).containsOnlyKeys("webFluxAdapterRegistry", "testReactiveAdapterRegistry");
}
Also used : ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) RequestMappingHandlerAdapter(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter) Test(org.junit.jupiter.api.Test)

Example 10 with RequestMappingHandlerAdapter

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(@Qualifier("webFluxAdapterRegistry") ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, @Qualifier("webFluxConversionService") FormattingConversionService conversionService, @Qualifier("webFluxValidator") Validator validator) {
    RequestMappingHandlerAdapter adapter = createRequestMappingHandlerAdapter();
    adapter.setMessageReaders(serverCodecConfigurer.getReaders());
    adapter.setWebBindingInitializer(getConfigurableWebBindingInitializer(conversionService, validator));
    adapter.setReactiveAdapterRegistry(reactiveAdapterRegistry);
    ArgumentResolverConfigurer configurer = new ArgumentResolverConfigurer();
    configureArgumentResolvers(configurer);
    adapter.setArgumentResolverConfigurer(configurer);
    return adapter;
}
Also used : RequestMappingHandlerAdapter(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter) ArgumentResolverConfigurer(org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer) Bean(org.springframework.context.annotation.Bean)

Aggregations

RequestMappingHandlerAdapter (org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter)10 Test (org.junit.jupiter.api.Test)7 HandlerMethodArgumentResolver (org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver)3 ApplicationContext (org.springframework.context.ApplicationContext)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 Bean (org.springframework.context.annotation.Bean)2 HttpMessageReader (org.springframework.http.codec.HttpMessageReader)2 Validator (org.springframework.validation.Validator)2 Message (com.google.protobuf.Message)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)1 ResolvableType (org.springframework.core.ResolvableType)1 ConversionService (org.springframework.core.convert.ConversionService)1 Resource (org.springframework.core.io.Resource)1 FormattingConversionService (org.springframework.format.support.FormattingConversionService)1 MediaType (org.springframework.http.MediaType)1