use of org.springframework.web.reactive.result.method.annotation.ResponseBodyResultHandler in project spring-framework by spring-projects.
the class WebFluxConfigurationSupportTests method responseBodyResultHandler.
@Test
public void responseBodyResultHandler() {
ApplicationContext context = loadConfig(WebFluxConfig.class);
String name = "responseBodyResultHandler";
ResponseBodyResultHandler handler = context.getBean(name, ResponseBodyResultHandler.class);
assertThat(handler).isNotNull();
assertThat(handler.getOrder()).isEqualTo(100);
List<HttpMessageWriter<?>> writers = handler.getMessageWriters();
assertThat(writers.size()).isEqualTo(13);
assertHasMessageWriter(writers, forClass(byte[].class), APPLICATION_OCTET_STREAM);
assertHasMessageWriter(writers, forClass(ByteBuffer.class), APPLICATION_OCTET_STREAM);
assertHasMessageWriter(writers, forClass(String.class), TEXT_PLAIN);
assertHasMessageWriter(writers, forClass(Resource.class), IMAGE_PNG);
assertHasMessageWriter(writers, forClass(Message.class), new MediaType("application", "x-protobuf"));
assertHasMessageWriter(writers, forClass(TestBean.class), APPLICATION_XML);
assertHasMessageWriter(writers, forClass(TestBean.class), APPLICATION_JSON);
assertHasMessageWriter(writers, forClass(TestBean.class), new MediaType("application", "x-jackson-smile"));
assertHasMessageWriter(writers, forClass(TestBean.class), null);
name = "webFluxContentTypeResolver";
RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
assertThat(handler.getContentTypeResolver()).isSameAs(resolver);
}
use of org.springframework.web.reactive.result.method.annotation.ResponseBodyResultHandler in project spring-framework by spring-projects.
the class DelegatingWebFluxConfigurationIntegrationTests method responseBodyResultHandlerWithPrimaryUsesQualifiedReactiveAdapterRegistry.
@Test
void responseBodyResultHandlerWithPrimaryUsesQualifiedReactiveAdapterRegistry() {
load(registerPrimaryBean("testReactiveAdapterRegistry", ReactiveAdapterRegistry.class));
ResponseBodyResultHandler responseBodyResultHandler = this.context.getBean(ResponseBodyResultHandler.class);
assertThat(responseBodyResultHandler.getAdapterRegistry()).isSameAs(this.context.getBean("webFluxAdapterRegistry"));
assertThat(this.context.getBeansOfType(ReactiveAdapterRegistry.class)).containsOnlyKeys("webFluxAdapterRegistry", "testReactiveAdapterRegistry");
}
use of org.springframework.web.reactive.result.method.annotation.ResponseBodyResultHandler in project spring-framework by spring-projects.
the class DelegatingWebFluxConfigurationIntegrationTests method responseBodyResultHandlerWithPrimaryUsesQualifiedRequestedContentTypeResolver.
@Test
void responseBodyResultHandlerWithPrimaryUsesQualifiedRequestedContentTypeResolver() {
load(registerPrimaryBean("testContentTypeResolver", RequestedContentTypeResolver.class));
ResponseBodyResultHandler responseBodyResultHandler = this.context.getBean(ResponseBodyResultHandler.class);
assertThat(responseBodyResultHandler.getContentTypeResolver()).isSameAs(this.context.getBean("webFluxContentTypeResolver"));
assertThat(this.context.getBeansOfType(RequestedContentTypeResolver.class)).containsOnlyKeys("webFluxContentTypeResolver", "testContentTypeResolver");
}
use of org.springframework.web.reactive.result.method.annotation.ResponseBodyResultHandler in project spring-framework by spring-projects.
the class DelegatingWebFluxConfigurationIntegrationTests method responseBodyResultHandlerUsesWebFluxInfrastructureByDefault.
@Test
void responseBodyResultHandlerUsesWebFluxInfrastructureByDefault() {
load(context -> {
});
ResponseBodyResultHandler responseBodyResultHandler = this.context.getBean(ResponseBodyResultHandler.class);
assertThat(responseBodyResultHandler.getAdapterRegistry()).isSameAs(this.context.getBean("webFluxAdapterRegistry"));
assertThat(responseBodyResultHandler.getContentTypeResolver()).isSameAs(this.context.getBean("webFluxContentTypeResolver"));
}
Aggregations