Search in sources :

Example 1 with FixedContentTypeResolver

use of org.springframework.web.reactive.accept.FixedContentTypeResolver in project spring-framework by spring-projects.

the class HandlerResultHandlerTests method usesContentTypeResolver.

@Test
public void usesContentTypeResolver() throws Exception {
    TestResultHandler resultHandler = new TestResultHandler(new FixedContentTypeResolver(IMAGE_GIF));
    List<MediaType> mediaTypes = Arrays.asList(IMAGE_JPEG, IMAGE_GIF, IMAGE_PNG);
    MockServerWebExchange exchange = MockServerHttpRequest.get("/path").toExchange();
    MediaType actual = resultHandler.selectMediaType(exchange, () -> mediaTypes);
    assertEquals(IMAGE_GIF, actual);
}
Also used : FixedContentTypeResolver(org.springframework.web.reactive.accept.FixedContentTypeResolver) MediaType(org.springframework.http.MediaType) MockServerWebExchange(org.springframework.mock.http.server.reactive.test.MockServerWebExchange) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 MediaType (org.springframework.http.MediaType)1 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)1 FixedContentTypeResolver (org.springframework.web.reactive.accept.FixedContentTypeResolver)1