|
|
@ -18,8 +18,11 @@ package org.springframework.boot.autoconfigure.thymeleaf;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.DispatcherType;
|
|
|
|
|
|
|
|
|
|
|
|
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
|
|
|
import nz.net.ultraq.thymeleaf.LayoutDialect;
|
|
|
|
import nz.net.ultraq.thymeleaf.decorators.strategies.GroupingStrategy;
|
|
|
|
import nz.net.ultraq.thymeleaf.decorators.strategies.GroupingStrategy;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.After;
|
|
|
@ -37,6 +40,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
|
|
|
import org.springframework.boot.test.rule.OutputCapture;
|
|
|
|
import org.springframework.boot.test.rule.OutputCapture;
|
|
|
|
import org.springframework.boot.test.util.TestPropertyValues;
|
|
|
|
import org.springframework.boot.test.util.TestPropertyValues;
|
|
|
|
|
|
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
@ -47,7 +51,6 @@ import org.springframework.mock.web.MockServletContext;
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
|
|
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
|
|
|
import org.springframework.web.servlet.ViewResolver;
|
|
|
|
import org.springframework.web.servlet.ViewResolver;
|
|
|
|
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
|
|
|
|
|
|
|
|
import org.springframework.web.servlet.support.RequestContext;
|
|
|
|
import org.springframework.web.servlet.support.RequestContext;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
@ -61,6 +64,7 @@ import static org.hamcrest.Matchers.containsString;
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
* @author Brian Clozel
|
|
|
|
* @author Brian Clozel
|
|
|
|
* @author Kazuki Shimizu
|
|
|
|
* @author Kazuki Shimizu
|
|
|
|
|
|
|
|
* @author Artsiom Yudovin
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ThymeleafServletAutoConfigurationTests {
|
|
|
|
public class ThymeleafServletAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
@ -205,14 +209,17 @@ public class ThymeleafServletAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void registerResourceHandlingFilterDisabledByDefault() {
|
|
|
|
public void registerResourceHandlingFilterDisabledByDefault() {
|
|
|
|
load(BaseConfiguration.class);
|
|
|
|
load(BaseConfiguration.class);
|
|
|
|
assertThat(this.context.getBeansOfType(ResourceUrlEncodingFilter.class))
|
|
|
|
assertThat(this.context.getBeansOfType(FilterRegistrationBean.class)).isEmpty();
|
|
|
|
.isEmpty();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() {
|
|
|
|
public void registerResourceHandlingFilterOnlyIfResourceChainIsEnabled() {
|
|
|
|
load(BaseConfiguration.class, "spring.resources.chain.enabled:true");
|
|
|
|
load(BaseConfiguration.class, "spring.resources.chain.enabled:true");
|
|
|
|
assertThat(this.context.getBean(ResourceUrlEncodingFilter.class)).isNotNull();
|
|
|
|
FilterRegistrationBean<?> registration = this.context
|
|
|
|
|
|
|
|
.getBean(FilterRegistrationBean.class);
|
|
|
|
|
|
|
|
assertThat(registration).isNotNull();
|
|
|
|
|
|
|
|
assertThat(registration).hasFieldOrPropertyWithValue("dispatcherTypes",
|
|
|
|
|
|
|
|
EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|