|
|
@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
|
|
|
|
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
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,16 +48,31 @@ class QuartzDataSourceInitializerTests {
|
|
|
|
.withPropertyValues("spring.datasource.url=" + String.format(
|
|
|
|
.withPropertyValues("spring.datasource.url=" + String.format(
|
|
|
|
"jdbc:h2:mem:test-%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", UUID.randomUUID().toString()));
|
|
|
|
"jdbc:h2:mem:test-%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", UUID.randomUUID().toString()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void hashIsUsedAsACommentPrefixByDefault() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration.class).withPropertyValues(
|
|
|
|
|
|
|
|
"spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_#_comments.sql")
|
|
|
|
|
|
|
|
.run(this::assertThatDataSourceHasBeenInitialized);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void doubleDashIsUsedAsACommentPrefixByDefault() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration.class).withPropertyValues(
|
|
|
|
|
|
|
|
"spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_--_comments.sql")
|
|
|
|
|
|
|
|
.run(this::assertThatDataSourceHasBeenInitialized);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void commentPrefixCanBeCustomized() {
|
|
|
|
void commentPrefixCanBeCustomized() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration.class).withPropertyValues(
|
|
|
|
this.contextRunner.withUserConfiguration(TestConfiguration.class).withPropertyValues(
|
|
|
|
"spring.quartz.jdbc.comment-prefix=##",
|
|
|
|
"spring.quartz.jdbc.comment-prefix=##",
|
|
|
|
"spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_@@platform@@.sql")
|
|
|
|
"spring.quartz.jdbc.schema=classpath:org/springframework/boot/autoconfigure/quartz/tables_@@platform@@.sql")
|
|
|
|
.run((context) -> {
|
|
|
|
.run(this::assertThatDataSourceHasBeenInitialized);
|
|
|
|
JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
|
|
|
|
}
|
|
|
|
assertThat(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM QRTZ_TEST_TABLE", Integer.class))
|
|
|
|
|
|
|
|
.isEqualTo(0);
|
|
|
|
private void assertThatDataSourceHasBeenInitialized(AssertableApplicationContext context) {
|
|
|
|
});
|
|
|
|
JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
|
|
|
|
|
|
|
|
assertThat(jdbcTemplate.queryForObject("SELECT COUNT(*) FROM QRTZ_TEST_TABLE", Integer.class)).isEqualTo(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|