use of org.thymeleaf.spring5.view.reactive.ThymeleafReactiveViewResolver in project thymeleaf-tests by thymeleaf.
the class ThymeleafReactiveViewTest method testSeveralConversionServices.
@Test
public void testSeveralConversionServices() throws Exception {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring5/view/applicationContextConversionService.xml");
final SpringWebFluxTemplateEngine templateEngine = new SpringWebFluxTemplateEngine();
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix("spring5/view/");
templateResolver.setSuffix(".html");
templateEngine.setTemplateResolver(templateResolver);
final ThymeleafReactiveViewResolver resolver = new ThymeleafReactiveViewResolver();
resolver.setApplicationContext(context);
resolver.setTemplateEngine(templateEngine);
resolver.setSupportedMediaTypes(Collections.singletonList(MediaType.TEXT_HTML));
// testview2 does not exist as a declared bean at the application context
final Mono<View> view = resolver.resolveViewName("testSeveralConversionServices", Locale.US);
final Map<String, Object> model = new ModelMap();
model.put("one", "one");
final TestingServerWebExchange exchange = new TestingServerWebExchange("/testing", new HashMap<>(), new HashMap<>(), new HashMap<>());
view.flatMap(v -> v.render(model, MediaType.TEXT_HTML, exchange)).block();
}
Aggregations