Merge branch '1.3.x'

pull/5128/head
Andy Wilkinson 9 years ago
commit ecf11e0230

@ -151,6 +151,7 @@ public class ThymeleafAutoConfiguration {
protected static class ThymeleafWebLayoutConfiguration { protected static class ThymeleafWebLayoutConfiguration {
@Bean @Bean
@ConditionalOnMissingBean
public LayoutDialect layoutDialect() { public LayoutDialect layoutDialect() {
return new LayoutDialect(); return new LayoutDialect();
} }

@ -20,6 +20,8 @@ import java.io.File;
import java.util.Collections; import java.util.Collections;
import java.util.Locale; import java.util.Locale;
import nz.net.ultraq.thymeleaf.LayoutDialect;
import nz.net.ultraq.thymeleaf.decorators.strategies.GroupingStrategy;
import org.junit.After; import org.junit.After;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -31,12 +33,16 @@ import org.thymeleaf.templateresolver.ITemplateResolver;
import org.thymeleaf.templateresolver.TemplateResolver; import org.thymeleaf.templateresolver.TemplateResolver;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.test.ImportAutoConfiguration;
import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.boot.test.OutputCapture; import org.springframework.boot.test.OutputCapture;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext; import org.springframework.mock.web.MockServletContext;
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.resource.ResourceUrlEncodingFilter;
@ -230,4 +236,24 @@ public class ThymeleafAutoConfigurationTests {
assertThat(this.context.getBean(ResourceUrlEncodingFilter.class)).isNotNull(); assertThat(this.context.getBean(ResourceUrlEncodingFilter.class)).isNotNull();
} }
@Test
public void layoutDialectCanBeCustomized() throws Exception {
this.context.register(LayoutDialectConfiguration.class);
this.context.refresh();
LayoutDialect layoutDialect = this.context.getBean(LayoutDialect.class);
assertThat(ReflectionTestUtils.getField(layoutDialect, "sortingStrategy"))
.isInstanceOf(GroupingStrategy.class);
}
@Configuration
@ImportAutoConfiguration({ ThymeleafAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class })
static class LayoutDialectConfiguration {
@Bean
public LayoutDialect layoutDialect() {
return new LayoutDialect(new GroupingStrategy());
}
}
} }

Loading…
Cancel
Save