15
15
*/
16
16
package org .springframework .batch .sample ;
17
17
18
+ import javax .sql .DataSource ;
19
+
18
20
import org .apache .activemq .broker .BrokerService ;
19
21
import org .junit .After ;
20
22
import org .junit .Assert ;
29
31
import org .springframework .beans .factory .annotation .Value ;
30
32
import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
31
33
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 ;
34
36
import org .springframework .test .context .junit4 .SpringRunner ;
35
37
36
38
/**
@@ -50,9 +52,10 @@ public abstract class RemotePartitioningJobFunctionalTests {
50
52
@ Autowired
51
53
protected JobLauncherTestUtils jobLauncherTestUtils ;
52
54
53
- private BrokerService brokerService ;
55
+ @ Autowired
56
+ private DataSource dataSource ;
54
57
55
- private EmbeddedDatabase embeddedDatabase ;
58
+ private BrokerService brokerService ;
56
59
57
60
private AnnotationConfigApplicationContext workerApplicationContext ;
58
61
@@ -64,11 +67,10 @@ public void setUp() throws Exception {
64
67
this .brokerService .addConnector (this .brokerUrl );
65
68
this .brokerService .setDataDirectory (BROKER_DATA_DIRECTORY );
66
69
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 );
72
74
this .workerApplicationContext = new AnnotationConfigApplicationContext (getWorkerConfigurationClass ());
73
75
}
74
76
@@ -86,7 +88,6 @@ public void testRemotePartitioningJob() throws Exception {
86
88
public void tearDown () throws Exception {
87
89
this .workerApplicationContext .close ();
88
90
this .brokerService .stop ();
89
- this .embeddedDatabase .shutdown ();
90
91
}
91
92
92
93
}
0 commit comments