Merge branch '2.1.x'

Closes gh-17466
pull/17471/head
Andy Wilkinson 5 years ago
commit edff0f87e2

@ -35,12 +35,12 @@ import org.springframework.transaction.PlatformTransactionManager;
* @author Stephane Nicoll
*/
@ConditionalOnClass(PlatformTransactionManager.class)
@ConditionalOnBean(DataSource.class)
@ConditionalOnMissingBean(BatchConfigurer.class)
@Configuration(proxyBeanMethods = false)
class BatchConfigurerConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(DataSource.class)
@ConditionalOnMissingBean(name = "entityManagerFactory")
static class JdbcBatchConfiguration {

@ -63,6 +63,7 @@ import org.springframework.transaction.PlatformTransactionManager;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link BatchAutoConfiguration}.
@ -96,6 +97,12 @@ class BatchAutoConfigurationTests {
.run((context) -> assertThat(context).doesNotHaveBean(BatchConfigurer.class));
}
@Test
void whenThereIsAnEntityManagerFactoryButNoDataSourceAutoConfigurationBacksOff() {
this.contextRunner.withUserConfiguration(TestConfiguration.class, EntityManagerFactoryConfiguration.class)
.run((context) -> assertThat(context).doesNotHaveBean(BatchConfigurer.class));
}
@Test
void testCustomConfigurationWithNoDatabase() {
this.contextRunner.withUserConfiguration(TestCustomConfiguration.class).run((context) -> {
@ -283,6 +290,16 @@ class BatchAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
static class EntityManagerFactoryConfiguration {
@Bean
EntityManagerFactory entityManagerFactory() {
return mock(EntityManagerFactory.class);
}
}
@EnableBatchProcessing
@TestAutoConfigurationPackage(City.class)
static class TestCustomConfiguration implements BatchConfigurer {

Loading…
Cancel
Save