use of org.thymeleaf.spring5.SpringWebFluxTemplateEngine in project thymeleaf-tests by thymeleaf.
the class AbstractSpring5ReactiveTest method initTemplateEngine.
@BeforeClass
public static void initTemplateEngine() {
final ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix(ReactiveTestUtils.TEMPLATE_PATH_BASE);
templateResolver.setSuffix(".html");
templateEngine = new SpringWebFluxTemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
bufferFactory = new DefaultDataBufferFactory();
htmlMediaType = MediaType.TEXT_HTML;
sseMediaType = MediaType.TEXT_EVENT_STREAM;
charset = Charset.forName("UTF-8");
}
use of org.thymeleaf.spring5.SpringWebFluxTemplateEngine 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