Skip to content

Commit aba70b4

Browse files
committed
Changing DataSourceBuilder to EmbeddedDatabaseBuilder.
1 parent 00b8aca commit aba70b4

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

spring-cloud-task-core/src/test/java/org/springframework/cloud/task/configuration/RepositoryTransactionManagerConfigurationTests.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import org.springframework.boot.autoconfigure.AutoConfigurations;
2727
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
28-
import org.springframework.boot.jdbc.DataSourceBuilder;
2928
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3029
import org.springframework.cloud.task.listener.TaskLifecycleListener;
3130
import org.springframework.cloud.task.repository.TaskExecution;
@@ -34,6 +33,8 @@
3433
import org.springframework.context.annotation.Configuration;
3534
import org.springframework.jdbc.core.JdbcTemplate;
3635
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
36+
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
37+
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
3738
import org.springframework.test.jdbc.JdbcTestUtils;
3839
import org.springframework.test.util.ReflectionTestUtils;
3940
import org.springframework.transaction.PlatformTransactionManager;
@@ -118,10 +119,7 @@ public TaskConfigurer taskConfigurer(DataSource dataSource) {
118119

119120
@Bean
120121
public DataSource dataSource() {
121-
DataSourceBuilder dsb = DataSourceBuilder.create()
122-
.url("jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE");
123-
dsb.driverClassName("org.h2.Driver");
124-
return dsb.build();
122+
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
125123
}
126124

127125
}
@@ -143,10 +141,7 @@ public PlatformTransactionManager getTransactionManager() {
143141

144142
@Bean
145143
public DataSource dataSource() {
146-
DataSourceBuilder dsb = DataSourceBuilder.create()
147-
.url("jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE");
148-
dsb.driverClassName("org.h2.Driver");
149-
return dsb.build();
144+
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
150145
}
151146

152147
@Bean
@@ -173,10 +168,7 @@ public PlatformTransactionManager getTransactionManager() {
173168

174169
@Bean
175170
public DataSource dataSource() {
176-
DataSourceBuilder dsb = DataSourceBuilder.create()
177-
.url("jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE");
178-
dsb.driverClassName("org.h2.Driver");
179-
return dsb.build();
171+
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
180172
}
181173

182174
@Bean
@@ -186,10 +178,7 @@ public DataSourceTransactionManager transactionManager(DataSource dataSource) {
186178

187179
@Bean
188180
public DataSource dataSource2() {
189-
DataSourceBuilder dsb = DataSourceBuilder.create()
190-
.url("jdbc:h2:mem:testdb2;DB_CLOSE_ON_EXIT=FALSE");
191-
dsb.driverClassName("org.h2.Driver");
192-
return dsb.build();
181+
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
193182
}
194183

195184
@Bean

0 commit comments

Comments
 (0)