Commit a023f308 authored by Andy Wilkinson's avatar Andy Wilkinson

Make JDBC-based batch configurer back off without a DataSource

Closes gh-17449
parent 7f85aba5
...@@ -40,6 +40,7 @@ import org.springframework.transaction.PlatformTransactionManager; ...@@ -40,6 +40,7 @@ import org.springframework.transaction.PlatformTransactionManager;
class BatchConfigurerConfiguration { class BatchConfigurerConfiguration {
@Configuration @Configuration
@ConditionalOnBean(DataSource.class)
@ConditionalOnMissingBean(name = "entityManagerFactory") @ConditionalOnMissingBean(name = "entityManagerFactory")
static class JdbcBatchConfiguration { static class JdbcBatchConfiguration {
......
...@@ -89,7 +89,13 @@ public class BatchAutoConfigurationTests { ...@@ -89,7 +89,13 @@ public class BatchAutoConfigurationTests {
} }
@Test @Test
public void testNoDatabase() { public void whenThereIsNoDataSourceAutoConfigurationBacksOff() {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean(BatchConfigurer.class));
}
@Test
public void testCustomConfigurationWithNoDatabase() {
this.contextRunner.withUserConfiguration(TestCustomConfiguration.class).run((context) -> { this.contextRunner.withUserConfiguration(TestCustomConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(JobLauncher.class); assertThat(context).hasSingleBean(JobLauncher.class);
JobExplorer explorer = context.getBean(JobExplorer.class); JobExplorer explorer = context.getBean(JobExplorer.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment