2424import org .springframework .batch .core .JobExecution ;
2525import org .springframework .batch .core .configuration .annotation .EnableBatchProcessing ;
2626import org .springframework .batch .test .JobLauncherTestUtils ;
27- import org .springframework .beans .factory .ObjectProvider ;
2827import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
2928import org .springframework .context .annotation .Bean ;
3029import org .springframework .context .annotation .Configuration ;
3837
3938/**
4039 * @author Henning Pöttker
40+ * @author Mahmoud Ben Hassine
4141 */
42- class BatchTestContextBeanPostProcessorTest {
42+ class BatchTestContextBeanPostProcessorTests {
4343
4444 private GenericApplicationContext applicationContext ;
4545
4646 @ BeforeEach
4747 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 );
5050 }
5151
5252 @ AfterEach
5353 void tearDown () {
54- if (applicationContext != null ) {
55- applicationContext .close ();
54+ if (this . applicationContext != null ) {
55+ this . applicationContext .close ();
5656 }
5757 }
5858
5959 @ Test
6060 void testContextWithoutJobBean () {
61- var jobLauncherTestUtils = applicationContext .getBean (JobLauncherTestUtils .class );
61+ var jobLauncherTestUtils = this . applicationContext .getBean (JobLauncherTestUtils .class );
6262 assertNotNull (jobLauncherTestUtils );
6363 assertNull (jobLauncherTestUtils .getJob ());
6464 }
6565
6666 @ Test
6767 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 );
7070 assertNotNull (jobLauncherTestUtils .getJob ());
7171 }
7272
7373 @ Test
7474 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 );
7777 var jobLauncherTestUtils = applicationContext .getBean (JobLauncherTestUtils .class );
7878 assertNotNull (jobLauncherTestUtils );
7979 assertNull (jobLauncherTestUtils .getJob ());
8080 }
8181
82- static class MockJob implements Job {
82+ static class StubJob implements Job {
8383
8484 @ Override
8585 public String getName () {
@@ -100,7 +100,7 @@ static class BatchConfiguration {
100100 DataSource dataSource () {
101101 return new EmbeddedDatabaseBuilder ().setType (EmbeddedDatabaseType .HSQL )
102102 .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 ();
104104 }
105105
106106 @ Bean
0 commit comments