use of org.thymeleaf.web.servlet.JakartaServletWebApplication in project spring-boot by spring-projects.
the class ThymeleafServletAutoConfigurationTests method useSecurityDialect.
@Test
void useSecurityDialect() {
this.contextRunner.run((context) -> {
TemplateEngine engine = context.getBean(TemplateEngine.class);
MockServletContext servletContext = new MockServletContext();
JakartaServletWebApplication webApplication = JakartaServletWebApplication.buildApplication(servletContext);
WebContext attrs = new WebContext(webApplication.buildExchange(new MockHttpServletRequest(servletContext), new MockHttpServletResponse()));
try {
SecurityContextHolder.setContext(new SecurityContextImpl(new TestingAuthenticationToken("alice", "admin")));
String result = engine.process("security-dialect", attrs);
assertThat(result).isEqualTo("<html><body><div>alice</div></body></html>" + System.lineSeparator());
} finally {
SecurityContextHolder.clearContext();
}
});
}
Aggregations