Polish
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,26 +64,28 @@ public class FreeMarkerAutoConfiguration {
|
||||
|
||||
@PostConstruct
|
||||
public void checkTemplateLocationExists() {
|
||||
if (logger.isWarnEnabled()) {
|
||||
if (this.properties.isCheckTemplateLocation()) {
|
||||
TemplateLocation templatePathLocation = null;
|
||||
List<TemplateLocation> locations = new ArrayList<>();
|
||||
for (String templateLoaderPath : this.properties.getTemplateLoaderPath()) {
|
||||
TemplateLocation location = new TemplateLocation(templateLoaderPath);
|
||||
locations.add(location);
|
||||
if (location.exists(this.applicationContext)) {
|
||||
templatePathLocation = location;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (templatePathLocation == null) {
|
||||
logger.warn("Cannot find template location(s): " + locations
|
||||
+ " (please add some templates, "
|
||||
+ "check your FreeMarker configuration, or set "
|
||||
+ "spring.freemarker.checkTemplateLocation=false)");
|
||||
}
|
||||
if (logger.isWarnEnabled() && this.properties.isCheckTemplateLocation()) {
|
||||
List<TemplateLocation> locations = getLocations();
|
||||
if (locations.stream().noneMatch(this::locationExists)) {
|
||||
logger.warn("Cannot find template location(s): " + locations
|
||||
+ " (please add some templates, "
|
||||
+ "check your FreeMarker configuration, or set "
|
||||
+ "spring.freemarker.checkTemplateLocation=false)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<TemplateLocation> getLocations() {
|
||||
List<TemplateLocation> locations = new ArrayList<>();
|
||||
for (String templateLoaderPath : this.properties.getTemplateLoaderPath()) {
|
||||
TemplateLocation location = new TemplateLocation(templateLoaderPath);
|
||||
locations.add(location);
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
private boolean locationExists(TemplateLocation location) {
|
||||
return location.exists(this.applicationContext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,14 +51,13 @@ public class QuartzDataSourceInitializerTests {
|
||||
@Test
|
||||
public void commentPrefixCanBeCustomized() {
|
||||
this.contextRunner.withUserConfiguration(TestConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"spring.quartz.jdbc.comment-prefix=##",
|
||||
.withPropertyValues("spring.quartz.jdbc.comment-prefix=##",
|
||||
"spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_@@platform@@.sql")
|
||||
.run((context) -> {
|
||||
JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
|
||||
assertThat(jdbcTemplate.queryForObject(
|
||||
"SELECT COUNT(*) FROM QRTZ_TEST_TABLE", Integer.class))
|
||||
.isEqualTo(0);
|
||||
.isEqualTo(0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -69,7 +68,8 @@ public class QuartzDataSourceInitializerTests {
|
||||
@Bean
|
||||
public QuartzDataSourceInitializer initializer(DataSource dataSource,
|
||||
ResourceLoader resourceLoader, QuartzProperties properties) {
|
||||
return new QuartzDataSourceInitializer(dataSource, resourceLoader, properties);
|
||||
return new QuartzDataSourceInitializer(dataSource, resourceLoader,
|
||||
properties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user