mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '3.5.x'
Closes gh-47143
This commit is contained in:
+42
-1
@@ -25,6 +25,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import groovy.text.markup.BaseTemplate;
|
||||
import groovy.text.markup.DelegatingIndentWriter;
|
||||
import groovy.text.markup.MarkupTemplateEngine;
|
||||
import groovy.text.markup.TemplateConfiguration;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@@ -159,9 +160,16 @@ class GroovyTemplateAutoConfigurationTests {
|
||||
assertThat(result).contains("suffixed");
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultResourceLoaderPath() throws Exception {
|
||||
registerAndRefreshContext();
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).getResourceLoaderPath())
|
||||
.isEqualTo(GroovyTemplateProperties.DEFAULT_RESOURCE_LOADER_PATH);
|
||||
}
|
||||
|
||||
@Test
|
||||
@WithResource(name = "custom-templates/custom.tpl", content = "yield \"custom\"")
|
||||
void customTemplateLoaderPath() throws Exception {
|
||||
void customResourceLoaderPath() throws Exception {
|
||||
registerAndRefreshContext("spring.groovy.template.resource-loader-path:classpath:/custom-templates/");
|
||||
MockHttpServletResponse response = render("custom");
|
||||
String result = response.getContentAsString();
|
||||
@@ -199,6 +207,13 @@ class GroovyTemplateAutoConfigurationTests {
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).isAutoIndent()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultAutoIndentString() {
|
||||
registerAndRefreshContext();
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).getAutoIndentString())
|
||||
.isEqualTo(DelegatingIndentWriter.SPACES);
|
||||
}
|
||||
|
||||
@Test
|
||||
void customAutoIndentString() {
|
||||
registerAndRefreshContext("spring.groovy.template.auto-indent-string:\\t");
|
||||
@@ -211,6 +226,13 @@ class GroovyTemplateAutoConfigurationTests {
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).isAutoNewLine()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultBaseTemplateClass() {
|
||||
registerAndRefreshContext();
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).getBaseTemplateClass())
|
||||
.isEqualTo(BaseTemplate.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void customBaseTemplateClass() {
|
||||
registerAndRefreshContext("spring.groovy.template.base-template-class:" + CustomBaseTemplate.class.getName());
|
||||
@@ -218,6 +240,12 @@ class GroovyTemplateAutoConfigurationTests {
|
||||
.isEqualTo(CustomBaseTemplate.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultDeclarationEncoding() {
|
||||
registerAndRefreshContext();
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).getDeclarationEncoding()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void customDeclarationEncoding() {
|
||||
registerAndRefreshContext("spring.groovy.template.declaration-encoding:UTF-8");
|
||||
@@ -230,12 +258,25 @@ class GroovyTemplateAutoConfigurationTests {
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).isExpandEmptyElements()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultLocale() {
|
||||
registerAndRefreshContext();
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).getLocale()).isEqualTo(Locale.getDefault());
|
||||
}
|
||||
|
||||
@Test
|
||||
void customLocale() {
|
||||
registerAndRefreshContext("spring.groovy.template.locale:en_US");
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).getLocale()).isEqualTo(Locale.US);
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultNewLineString() {
|
||||
registerAndRefreshContext();
|
||||
assertThat(this.context.getBean(GroovyMarkupConfigurer.class).getNewLineString())
|
||||
.isEqualTo(System.lineSeparator());
|
||||
}
|
||||
|
||||
@Test
|
||||
void customNewLineString() {
|
||||
registerAndRefreshContext("spring.groovy.template.new-line-string:\\r\\n");
|
||||
|
||||
Reference in New Issue
Block a user