path->templateLoaderPath

This commit is contained in:
Dave Syer 2014-05-15 15:03:51 +01:00
parent 898250431a
commit 0a11459c3e
3 changed files with 10 additions and 10 deletions

View File

@ -66,7 +66,7 @@ public class FreeMarkerAutoConfiguration {
public void checkTemplateLocationExists() { public void checkTemplateLocationExists() {
if (this.properties.isCheckTemplateLocation()) { if (this.properties.isCheckTemplateLocation()) {
Resource resource = this.resourceLoader Resource resource = this.resourceLoader
.getResource(this.properties.getPath()); .getResource(this.properties.getTemplateLoaderPath());
Assert.state(resource.exists(), "Cannot find template location: " + resource Assert.state(resource.exists(), "Cannot find template location: " + resource
+ " (please add some templates " + " (please add some templates "
+ "or check your FreeMarker configuration)"); + "or check your FreeMarker configuration)");
@ -79,7 +79,7 @@ public class FreeMarkerAutoConfiguration {
protected FreeMarkerProperties properties; protected FreeMarkerProperties properties;
protected void applyProperties(FreeMarkerConfigurationFactory factory) { protected void applyProperties(FreeMarkerConfigurationFactory factory) {
factory.setTemplateLoaderPath(this.properties.getPath()); factory.setTemplateLoaderPath(this.properties.getTemplateLoaderPath());
factory.setDefaultEncoding(this.properties.getCharSet()); factory.setDefaultEncoding(this.properties.getCharSet());
Properties settings = new Properties(); Properties settings = new Properties();
settings.putAll(this.properties.getSettings()); settings.putAll(this.properties.getSettings());

View File

@ -39,7 +39,7 @@ public class FreeMarkerProperties {
private String suffix = DEFAULT_SUFFIX; private String suffix = DEFAULT_SUFFIX;
private String path = DEFAULT_TEMPLATE_LOADER_PATH; private String templateLoaderPath = DEFAULT_TEMPLATE_LOADER_PATH;
private boolean cache; private boolean cache;
@ -121,12 +121,12 @@ public class FreeMarkerProperties {
this.suffix = suffix; this.suffix = suffix;
} }
public String getPath() { public String getTemplateLoaderPath() {
return this.path; return this.templateLoaderPath;
} }
public void setPath(String path) { public void setTemplateLoaderPath(String templateLoaderPath) {
this.path = path; this.templateLoaderPath = templateLoaderPath;
} }
public String getRequestContextAttribute() { public String getRequestContextAttribute() {

View File

@ -72,14 +72,14 @@ public class FreeMarkerAutoConfigurationTests {
@Test(expected = BeanCreationException.class) @Test(expected = BeanCreationException.class)
public void nonExistentTemplateLocation() { public void nonExistentTemplateLocation() {
registerAndRefreshContext("spring.freemarker.path:" registerAndRefreshContext("spring.freemarker.templateLoaderPath:"
+ "classpath:/does-not-exist/"); + "classpath:/does-not-exist/");
} }
@Test @Test
public void emptyTemplateLocation() { public void emptyTemplateLocation() {
new File("target/test-classes/templates/empty-directory").mkdir(); new File("target/test-classes/templates/empty-directory").mkdir();
registerAndRefreshContext("spring.freemarker.path:" registerAndRefreshContext("spring.freemarker.templateLoaderPath:"
+ "classpath:/templates/empty-directory/"); + "classpath:/templates/empty-directory/");
} }
@ -119,7 +119,7 @@ public class FreeMarkerAutoConfigurationTests {
@Test @Test
public void customTemplateLoaderPath() throws Exception { public void customTemplateLoaderPath() throws Exception {
registerAndRefreshContext("spring.freemarker.path:classpath:/custom-templates/"); registerAndRefreshContext("spring.freemarker.templateLoaderPath:classpath:/custom-templates/");
MockHttpServletResponse response = render("custom"); MockHttpServletResponse response = render("custom");
String result = response.getContentAsString(); String result = response.getContentAsString();
assertThat(result, containsString("custom")); assertThat(result, containsString("custom"));