Skip to content

Commit b9790d1

Browse files
committed
Fix datasource initialization in remote partitioning samples
1 parent 7bbbd4f commit b9790d1

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

spring-batch-samples/src/test/java/org/springframework/batch/sample/RemotePartitioningJobFunctionalTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.batch.sample;
1717

18+
import javax.sql.DataSource;
19+
1820
import org.apache.activemq.broker.BrokerService;
1921
import org.junit.After;
2022
import org.junit.Assert;
@@ -29,8 +31,8 @@
2931
import org.springframework.beans.factory.annotation.Value;
3032
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3133
import org.springframework.context.annotation.PropertySource;
32-
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
33-
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
34+
import org.springframework.core.io.ClassPathResource;
35+
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
3436
import org.springframework.test.context.junit4.SpringRunner;
3537

3638
/**
@@ -50,9 +52,10 @@ public abstract class RemotePartitioningJobFunctionalTests {
5052
@Autowired
5153
protected JobLauncherTestUtils jobLauncherTestUtils;
5254

53-
private BrokerService brokerService;
55+
@Autowired
56+
private DataSource dataSource;
5457

55-
private EmbeddedDatabase embeddedDatabase;
58+
private BrokerService brokerService;
5659

5760
private AnnotationConfigApplicationContext workerApplicationContext;
5861

@@ -64,11 +67,10 @@ public void setUp() throws Exception {
6467
this.brokerService.addConnector(this.brokerUrl);
6568
this.brokerService.setDataDirectory(BROKER_DATA_DIRECTORY);
6669
this.brokerService.start();
67-
this.embeddedDatabase = new EmbeddedDatabaseBuilder()
68-
.addScript("/org/springframework/batch/core/schema-drop-hsqldb.sql")
69-
.addScript("/org/springframework/batch/core/schema-hsqldb.sql")
70-
.generateUniqueName(true)
71-
.build();
70+
ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator();
71+
databasePopulator.addScript(new ClassPathResource("/org/springframework/batch/core/schema-drop-hsqldb.sql"));
72+
databasePopulator.addScript(new ClassPathResource("/org/springframework/batch/core/schema-hsqldb.sql"));
73+
databasePopulator.execute(this.dataSource);
7274
this.workerApplicationContext = new AnnotationConfigApplicationContext(getWorkerConfigurationClass());
7375
}
7476

@@ -86,7 +88,6 @@ public void testRemotePartitioningJob() throws Exception {
8688
public void tearDown() throws Exception {
8789
this.workerApplicationContext.close();
8890
this.brokerService.stop();
89-
this.embeddedDatabase.shutdown();
9091
}
9192

9293
}

0 commit comments

Comments
 (0)