24
24
import org .springframework .batch .core .JobExecution ;
25
25
import org .springframework .batch .core .configuration .annotation .EnableBatchProcessing ;
26
26
import org .springframework .batch .test .JobLauncherTestUtils ;
27
- import org .springframework .beans .factory .ObjectProvider ;
28
27
import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
29
28
import org .springframework .context .annotation .Bean ;
30
29
import org .springframework .context .annotation .Configuration ;
38
37
39
38
/**
40
39
* @author Henning Pöttker
40
+ * @author Mahmoud Ben Hassine
41
41
*/
42
- class BatchTestContextBeanPostProcessorTest {
42
+ class BatchTestContextBeanPostProcessorTests {
43
43
44
44
private GenericApplicationContext applicationContext ;
45
45
46
46
@ BeforeEach
47
47
void setUp () {
48
- applicationContext = new AnnotationConfigApplicationContext (BatchConfiguration .class );
49
- applicationContext .registerBean (JobLauncherTestUtils .class );
48
+ this . applicationContext = new AnnotationConfigApplicationContext (BatchConfiguration .class );
49
+ this . applicationContext .registerBean (JobLauncherTestUtils .class );
50
50
}
51
51
52
52
@ AfterEach
53
53
void tearDown () {
54
- if (applicationContext != null ) {
55
- applicationContext .close ();
54
+ if (this . applicationContext != null ) {
55
+ this . applicationContext .close ();
56
56
}
57
57
}
58
58
59
59
@ Test
60
60
void testContextWithoutJobBean () {
61
- var jobLauncherTestUtils = applicationContext .getBean (JobLauncherTestUtils .class );
61
+ var jobLauncherTestUtils = this . applicationContext .getBean (JobLauncherTestUtils .class );
62
62
assertNotNull (jobLauncherTestUtils );
63
63
assertNull (jobLauncherTestUtils .getJob ());
64
64
}
65
65
66
66
@ Test
67
67
void testContextWithUniqueJobBean () {
68
- applicationContext .registerBean (MockJob .class );
69
- var jobLauncherTestUtils = applicationContext .getBean (JobLauncherTestUtils .class );
68
+ applicationContext .registerBean (StubJob .class );
69
+ var jobLauncherTestUtils = this . applicationContext .getBean (JobLauncherTestUtils .class );
70
70
assertNotNull (jobLauncherTestUtils .getJob ());
71
71
}
72
72
73
73
@ Test
74
74
void testContextWithTwoJobBeans () {
75
- applicationContext .registerBean ("jobA" , MockJob .class );
76
- applicationContext .registerBean ("jobB" , MockJob .class );
75
+ this . applicationContext .registerBean ("jobA" , StubJob .class );
76
+ this . applicationContext .registerBean ("jobB" , StubJob .class );
77
77
var jobLauncherTestUtils = applicationContext .getBean (JobLauncherTestUtils .class );
78
78
assertNotNull (jobLauncherTestUtils );
79
79
assertNull (jobLauncherTestUtils .getJob ());
80
80
}
81
81
82
- static class MockJob implements Job {
82
+ static class StubJob implements Job {
83
83
84
84
@ Override
85
85
public String getName () {
@@ -100,7 +100,7 @@ static class BatchConfiguration {
100
100
DataSource dataSource () {
101
101
return new EmbeddedDatabaseBuilder ().setType (EmbeddedDatabaseType .HSQL )
102
102
.addScript ("/org/springframework/batch/core/schema-drop-hsqldb.sql" )
103
- .addScript ("/org/springframework/batch/core/schema-hsqldb.sql" ).build ();
103
+ .addScript ("/org/springframework/batch/core/schema-hsqldb.sql" ).generateUniqueName ( true ). build ();
104
104
}
105
105
106
106
@ Bean
0 commit comments