Search in sources :

Example 1 with ViewResolutionResultHandler

use of org.springframework.web.reactive.result.view.ViewResolutionResultHandler in project spring-boot by spring-projects.

the class WebFluxAnnotationAutoConfigurationTests method shouldRegisterViewResolvers.

@Test
public void shouldRegisterViewResolvers() throws Exception {
    load(ViewResolvers.class);
    ViewResolutionResultHandler resultHandler = this.context.getBean(ViewResolutionResultHandler.class);
    assertThat(resultHandler.getViewResolvers()).containsExactly(this.context.getBean("aViewResolver", ViewResolver.class), this.context.getBean("anotherViewResolver", ViewResolver.class));
}
Also used : ViewResolutionResultHandler(org.springframework.web.reactive.result.view.ViewResolutionResultHandler) ViewResolver(org.springframework.web.reactive.result.view.ViewResolver) Test(org.junit.Test)

Example 2 with ViewResolutionResultHandler

use of org.springframework.web.reactive.result.view.ViewResolutionResultHandler in project spring-framework by spring-projects.

the class WebFluxConfigurationSupport method viewResolutionResultHandler.

@Bean
public ViewResolutionResultHandler viewResolutionResultHandler() {
    ViewResolverRegistry registry = new ViewResolverRegistry(getApplicationContext());
    configureViewResolvers(registry);
    List<ViewResolver> resolvers = registry.getViewResolvers();
    ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, webFluxContentTypeResolver(), webFluxAdapterRegistry());
    handler.setDefaultViews(registry.getDefaultViews());
    handler.setOrder(registry.getOrder());
    return handler;
}
Also used : ViewResolutionResultHandler(org.springframework.web.reactive.result.view.ViewResolutionResultHandler) ViewResolver(org.springframework.web.reactive.result.view.ViewResolver) Bean(org.springframework.context.annotation.Bean)

Example 3 with ViewResolutionResultHandler

use of org.springframework.web.reactive.result.view.ViewResolutionResultHandler in project spring-framework by spring-projects.

the class WebFluxConfigurationSupportTests method viewResolutionResultHandler.

@Test
public void viewResolutionResultHandler() throws Exception {
    ApplicationContext context = loadConfig(CustomViewResolverConfig.class);
    String name = "viewResolutionResultHandler";
    ViewResolutionResultHandler handler = context.getBean(name, ViewResolutionResultHandler.class);
    assertNotNull(handler);
    assertEquals(Ordered.LOWEST_PRECEDENCE, handler.getOrder());
    List<ViewResolver> resolvers = handler.getViewResolvers();
    assertEquals(1, resolvers.size());
    assertEquals(FreeMarkerViewResolver.class, resolvers.get(0).getClass());
    List<View> views = handler.getDefaultViews();
    assertEquals(1, views.size());
    MimeType type = MimeTypeUtils.parseMimeType("application/json;charset=UTF-8");
    assertEquals(type, views.get(0).getSupportedMediaTypes().get(0));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ViewResolutionResultHandler(org.springframework.web.reactive.result.view.ViewResolutionResultHandler) FreeMarkerViewResolver(org.springframework.web.reactive.result.view.freemarker.FreeMarkerViewResolver) ViewResolver(org.springframework.web.reactive.result.view.ViewResolver) HttpMessageWriterView(org.springframework.web.reactive.result.view.HttpMessageWriterView) View(org.springframework.web.reactive.result.view.View) MimeType(org.springframework.util.MimeType) Test(org.junit.Test)

Aggregations

ViewResolutionResultHandler (org.springframework.web.reactive.result.view.ViewResolutionResultHandler)3 ViewResolver (org.springframework.web.reactive.result.view.ViewResolver)3 Test (org.junit.Test)2 ApplicationContext (org.springframework.context.ApplicationContext)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1 MimeType (org.springframework.util.MimeType)1 HttpMessageWriterView (org.springframework.web.reactive.result.view.HttpMessageWriterView)1 View (org.springframework.web.reactive.result.view.View)1 FreeMarkerViewResolver (org.springframework.web.reactive.result.view.freemarker.FreeMarkerViewResolver)1