Fix @AutoConfigureTestDatabase imports

Update `@AutoConfigureTestDatabase` so that it always imports
`DataSourceAutoConfiguration`. Prior to this commit the annotation
could only be applied if something else also imported DataSource
auto-configuration.

Fixes gh-6897
This commit is contained in:
Phillip Webb
2016-09-16 16:49:36 -07:00
parent 825dd0a26c
commit 2c621f4094
2 changed files with 5 additions and 1 deletions

View File

@@ -39,7 +39,8 @@ org.springframework.boot.test.autoconfigure.restdocs.RestDocsAutoConfiguration
# AutoConfigureTestDatabase auto-configuration imports
org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestDatabase=\
org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfiguration
org.springframework.boot.test.autoconfigure.orm.jpa.TestDatabaseAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
# AutoConfigureTestEntityManager auto-configuration imports
org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager=\

View File

@@ -16,6 +16,8 @@
package org.springframework.boot.test.autoconfigure.orm.jpa;
import javax.sql.DataSource;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,6 +44,7 @@ public class AutoConfigureTestDatabaseWithNoDatabaseIntegrationTests {
public void testContextLoades() throws Exception {
// gh-6897
assertThat(this.context).isNotNull();
assertThat(this.context.getBeanNamesForType(DataSource.class)).isNotEmpty();
}
@TestConfiguration