Make JDBC-based batch configurer back off without a DataSource

Closes gh-17449
pull/17511/head
Andy Wilkinson 5 years ago
parent 7f85aba546
commit a023f308ed

@ -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 {
} }
@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);

Loading…
Cancel
Save