Reduce naming collisions in consecutive tests
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
792278d073
commit
0ad68037b6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,9 +19,8 @@ import org.springframework.batch.core.Step;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -32,9 +31,6 @@ import javax.sql.DataSource;
|
||||
@Configuration
|
||||
public class DataSourceConfiguration {
|
||||
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
@Autowired
|
||||
private ResourceLoader resourceLoader;
|
||||
|
||||
@@ -48,7 +44,9 @@ public class DataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
return new EmbeddedDatabaseFactory().getDatabase();
|
||||
return new EmbeddedDatabaseBuilder()
|
||||
.generateUniqueName(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,6 +64,7 @@ public abstract class TransactionManagerConfigurationTests {
|
||||
return new EmbeddedDatabaseBuilder()
|
||||
.addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql")
|
||||
.addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql")
|
||||
.generateUniqueName(true)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,6 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -74,9 +73,6 @@ public class RegisterMultiListenerTests {
|
||||
@Autowired
|
||||
private CallChecker callChecker;
|
||||
|
||||
@Autowired
|
||||
private EmbeddedDatabase dataSource;
|
||||
|
||||
private GenericApplicationContext context;
|
||||
|
||||
@After
|
||||
@@ -206,6 +202,7 @@ public class RegisterMultiListenerTests {
|
||||
.addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql")
|
||||
.addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql")
|
||||
.setType(EmbeddedDatabaseType.HSQL)
|
||||
.generateUniqueName(true)
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -236,6 +233,7 @@ public class RegisterMultiListenerTests {
|
||||
.addScript("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql")
|
||||
.addScript("classpath:org/springframework/batch/core/schema-hsqldb.sql")
|
||||
.setType(EmbeddedDatabaseType.HSQL)
|
||||
.generateUniqueName(true)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -68,7 +67,6 @@ import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = ConcurrentTransactionTests.ConcurrentJobConfiguration.class)
|
||||
@Ignore // FIXME https://github.com/spring-projects/spring-batch/issues/3851
|
||||
public class ConcurrentTransactionTests {
|
||||
|
||||
@Autowired
|
||||
@@ -149,6 +147,7 @@ public class ConcurrentTransactionTests {
|
||||
databasePopulator.addScript(defaultResourceLoader.getResource("classpath:org/springframework/batch/core/schema-drop-hsqldb.sql"));
|
||||
databasePopulator.addScript(defaultResourceLoader.getResource("classpath:org/springframework/batch/core/schema-hsqldb.sql"));
|
||||
embeddedDatabaseFactory.setDatabasePopulator(databasePopulator);
|
||||
embeddedDatabaseFactory.setGenerateUniqueDatabaseName(true);
|
||||
|
||||
return embeddedDatabaseFactory.getDatabase();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user