Search in sources :

Example 1 with ISpringWebFluxTemplateEngine

use of org.thymeleaf.spring5.ISpringWebFluxTemplateEngine in project thymeleaf-tests by thymeleaf.

the class AbstractSpring5ReactiveTest method createThymeleafReactiveView.

private static ThymeleafReactiveView createThymeleafReactiveView(final ISpringWebFluxTemplateEngine templateEngine, final String viewName, final Set<String> markupSelectors, final Locale locale, final int responseMaxChunkSizeBytes) {
    if (markupSelectors != null && markupSelectors.size() > 1) {
        throw new RuntimeException("Cannot execute SpringView-based test with more than 1 markup selector");
    }
    final ThymeleafReactiveView view = new ThymeleafReactiveView();
    view.setTemplateName(viewName);
    if (markupSelectors != null) {
        view.setMarkupSelector(markupSelectors.iterator().next());
    }
    view.setResponseMaxChunkSizeBytes(responseMaxChunkSizeBytes);
    try {
        thymeleafReactiveViewTemplateEngineSetter.setAccessible(true);
        thymeleafReactiveViewTemplateEngineSetter.invoke(view, templateEngine);
        thymeleafReactiveViewTemplateEngineSetter.setAccessible(false);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
    try {
        thymeleafReactiveViewLocaleSetter.setAccessible(true);
        thymeleafReactiveViewLocaleSetter.invoke(view, locale);
        thymeleafReactiveViewLocaleSetter.setAccessible(false);
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
    view.setApplicationContext(applicationContext);
    return view;
}
Also used : ThymeleafReactiveView(org.thymeleaf.spring5.view.reactive.ThymeleafReactiveView) TemplateProcessingException(org.thymeleaf.exceptions.TemplateProcessingException)

Aggregations

TemplateProcessingException (org.thymeleaf.exceptions.TemplateProcessingException)1 ThymeleafReactiveView (org.thymeleaf.spring5.view.reactive.ThymeleafReactiveView)1