Search in sources :

Example 1 with ResponseEntityResultHandler

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

the class WebFluxConfigurationSupportTests method responseEntityResultHandler.

@Test
public void responseEntityResultHandler() throws Exception {
    ApplicationContext context = loadConfig(WebFluxConfig.class);
    String name = "responseEntityResultHandler";
    ResponseEntityResultHandler handler = context.getBean(name, ResponseEntityResultHandler.class);
    assertNotNull(handler);
    assertEquals(0, handler.getOrder());
    List<HttpMessageWriter<?>> writers = handler.getMessageWriters();
    assertEquals(8, writers.size());
    assertHasMessageWriter(writers, byte[].class, APPLICATION_OCTET_STREAM);
    assertHasMessageWriter(writers, ByteBuffer.class, APPLICATION_OCTET_STREAM);
    assertHasMessageWriter(writers, String.class, TEXT_PLAIN);
    assertHasMessageWriter(writers, Resource.class, IMAGE_PNG);
    assertHasMessageWriter(writers, TestBean.class, APPLICATION_XML);
    assertHasMessageWriter(writers, TestBean.class, APPLICATION_JSON);
    assertHasMessageWriter(writers, TestBean.class, MediaType.parseMediaType("text/event-stream"));
    name = "webFluxContentTypeResolver";
    RequestedContentTypeResolver resolver = context.getBean(name, RequestedContentTypeResolver.class);
    assertSame(resolver, handler.getContentTypeResolver());
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) EncoderHttpMessageWriter(org.springframework.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(org.springframework.http.codec.HttpMessageWriter) ResponseEntityResultHandler(org.springframework.web.reactive.result.method.annotation.ResponseEntityResultHandler) RequestedContentTypeResolver(org.springframework.web.reactive.accept.RequestedContentTypeResolver) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ApplicationContext (org.springframework.context.ApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 EncoderHttpMessageWriter (org.springframework.http.codec.EncoderHttpMessageWriter)1 HttpMessageWriter (org.springframework.http.codec.HttpMessageWriter)1 RequestedContentTypeResolver (org.springframework.web.reactive.accept.RequestedContentTypeResolver)1 ResponseEntityResultHandler (org.springframework.web.reactive.result.method.annotation.ResponseEntityResultHandler)1