DATAJPA-1284 - Use generated database names in tests with Java configuration.
Use a pseudo-random unique name for the embedded database as recommended in EmbeddedDatabaseBuilder#generateUniqueName for reusable configuration. Original pull request: #257.
This commit is contained in:
@@ -35,6 +35,7 @@ import org.springframework.transaction.PlatformTransactionManager;
|
||||
* Base class for integration tests for JPA 2.1 {@link AttributeConverter} integration.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public abstract class AbstractAttributeConverterIntegrationTests {
|
||||
@@ -63,7 +64,7 @@ public abstract class AbstractAttributeConverterIntegrationTests {
|
||||
|
||||
@Bean
|
||||
DataSource dataSource() {
|
||||
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).build();
|
||||
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).generateUniqueName(true).build();
|
||||
}
|
||||
|
||||
protected abstract String getPackageName();
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.ClassUtils;
|
||||
* Integration test for {@link JpaRepositoriesRegistrar}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@@ -65,7 +66,7 @@ public class JpaRepositoriesRegistrarIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
return new EmbeddedDatabaseBuilder().build();
|
||||
return new EmbeddedDatabaseBuilder().generateUniqueName(true).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.springframework.stereotype.Component;
|
||||
* Integration tests for {@link DefaultJpaContext}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Jens Schauder
|
||||
* @soundtrack Marcus Miller - Papa Was A Rolling Stone (Afrodeezia)
|
||||
*/
|
||||
public class DefaultJpaContextIntegrationTests {
|
||||
@@ -138,7 +139,8 @@ public class DefaultJpaContextIntegrationTests {
|
||||
|
||||
LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
|
||||
factoryBean.setPersistenceProvider(HibernateTestUtils.getPersistenceProvider());
|
||||
factoryBean.setDataSource(new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).build());
|
||||
factoryBean.setDataSource(
|
||||
new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL).generateUniqueName(true).build());
|
||||
factoryBean.setPersistenceUnitName(persistenceUnitName);
|
||||
|
||||
return factoryBean;
|
||||
|
||||
Reference in New Issue
Block a user