Search in sources :

Example 1 with SpringResourceTemplateResolver

use of org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method defaultPropertyCanBeOverriddenFromUserHomeProperties.

@Test
public void defaultPropertyCanBeOverriddenFromUserHomeProperties() throws Exception {
    String userHome = System.getProperty("user.home");
    System.setProperty("user.home", new File("src/test/resources/user-home").getAbsolutePath());
    try {
        this.context = initializeAndRun(Config.class);
        SpringResourceTemplateResolver resolver = this.context.getBean(SpringResourceTemplateResolver.class);
        assertThat(resolver.isCacheable()).isTrue();
    } finally {
        System.setProperty("user.home", userHome);
    }
}
Also used : SpringResourceTemplateResolver(org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver) File(java.io.File) Test(org.junit.Test)

Example 2 with SpringResourceTemplateResolver

use of org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver in project spring-boot by spring-projects.

the class ThymeleafAutoConfigurationTests method cachingCanBeDisabled.

@Test
public void cachingCanBeDisabled() {
    this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.cache:false");
    this.context.refresh();
    assertThat(this.context.getBean(ThymeleafViewResolver.class).isCache()).isFalse();
    SpringResourceTemplateResolver templateResolver = this.context.getBean(SpringResourceTemplateResolver.class);
    assertThat(templateResolver.isCacheable()).isFalse();
}
Also used : SpringResourceTemplateResolver(org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver) ThymeleafViewResolver(org.thymeleaf.spring5.view.ThymeleafViewResolver) Test(org.junit.Test)

Example 3 with SpringResourceTemplateResolver

use of org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver in project spring-security by spring-projects.

the class WebMvcConfiguration method templateResolver.

private SpringResourceTemplateResolver templateResolver() {
    SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
    resolver.setPrefix("classpath:/views/");
    resolver.setSuffix(".html");
    resolver.setTemplateMode(TemplateMode.HTML);
    resolver.setApplicationContext(applicationContext);
    return resolver;
}
Also used : SpringResourceTemplateResolver(org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver)

Example 4 with SpringResourceTemplateResolver

use of org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver in project spring-boot by spring-projects.

the class ThymeleafAutoConfigurationTests method overrideCharacterEncoding.

@Test
public void overrideCharacterEncoding() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.encoding:UTF-16");
    this.context.register(ThymeleafAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    ITemplateResolver resolver = this.context.getBean(ITemplateResolver.class);
    assertThat(resolver instanceof SpringResourceTemplateResolver).isTrue();
    assertThat(((SpringResourceTemplateResolver) resolver).getCharacterEncoding()).isEqualTo("UTF-16");
    ThymeleafViewResolver views = this.context.getBean(ThymeleafViewResolver.class);
    assertThat(views.getCharacterEncoding()).isEqualTo("UTF-16");
    assertThat(views.getContentType()).isEqualTo("text/html;charset=UTF-16");
}
Also used : SpringResourceTemplateResolver(org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver) ITemplateResolver(org.thymeleaf.templateresolver.ITemplateResolver) ThymeleafViewResolver(org.thymeleaf.spring5.view.ThymeleafViewResolver) Test(org.junit.Test)

Example 5 with SpringResourceTemplateResolver

use of org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver in project spring-boot by spring-projects.

the class LocalDevToolsAutoConfigurationTests method thymeleafCacheIsFalse.

@Test
public void thymeleafCacheIsFalse() throws Exception {
    this.context = initializeAndRun(Config.class);
    SpringResourceTemplateResolver resolver = this.context.getBean(SpringResourceTemplateResolver.class);
    assertThat(resolver.isCacheable()).isFalse();
}
Also used : SpringResourceTemplateResolver(org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 SpringResourceTemplateResolver (org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver)5 ThymeleafViewResolver (org.thymeleaf.spring5.view.ThymeleafViewResolver)2 File (java.io.File)1 SpringResourceTemplateResolver (org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver)1 ITemplateResolver (org.thymeleaf.templateresolver.ITemplateResolver)1