18
18
import java .util .Arrays ;
19
19
import java .util .List ;
20
20
import java .util .UUID ;
21
+ import java .util .stream .Collectors ;
21
22
22
23
import javax .sql .DataSource ;
23
24
29
30
30
31
import org .springframework .batch .core .ExitStatus ;
31
32
import org .springframework .batch .core .Job ;
33
+ import org .springframework .batch .core .JobExecution ;
32
34
import org .springframework .batch .core .JobParameters ;
33
35
import org .springframework .batch .core .configuration .annotation .EnableBatchProcessing ;
34
36
import org .springframework .batch .core .configuration .annotation .JobBuilderFactory ;
39
41
import org .springframework .context .annotation .Bean ;
40
42
import org .springframework .context .annotation .Configuration ;
41
43
import org .springframework .core .io .DefaultResourceLoader ;
44
+ import org .springframework .core .io .Resource ;
42
45
import org .springframework .jdbc .core .JdbcTemplate ;
43
46
import org .springframework .jdbc .datasource .SimpleDriverDataSource ;
44
47
import org .springframework .jdbc .datasource .init .DatabasePopulatorUtils ;
45
48
import org .springframework .jdbc .datasource .init .ResourceDatabasePopulator ;
46
49
47
50
/**
48
51
* @author Henning Pöttker
52
+ * @author Mahmoud Ben Hassine
49
53
*/
50
54
@ RunWith (Parameterized .class )
51
55
public class H2CompatibilityModeJobRepositoryIntegrationTests {
@@ -58,31 +62,31 @@ public H2CompatibilityModeJobRepositoryIntegrationTests(String compatibilityMode
58
62
59
63
@ Test
60
64
public void testJobExecution () throws Exception {
61
- var context = new AnnotationConfigApplicationContext ();
65
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext ();
62
66
context .register (TestConfiguration .class );
63
67
context .registerBean (DataSource .class , this ::buildDataSource );
64
68
context .refresh ();
65
- var jobLauncher = context .getBean (JobLauncher .class );
66
- var job = context .getBean (Job .class );
69
+ JobLauncher jobLauncher = context .getBean (JobLauncher .class );
70
+ Job job = context .getBean (Job .class );
67
71
68
- var jobExecution = jobLauncher .run (job , new JobParameters ());
72
+ JobExecution jobExecution = jobLauncher .run (job , new JobParameters ());
69
73
70
74
Assert .assertNotNull (jobExecution );
71
75
Assert .assertEquals (ExitStatus .COMPLETED , jobExecution .getExitStatus ());
72
76
73
- var jdbcTemplate = new JdbcTemplate (context .getBean (DataSource .class ));
77
+ JdbcTemplate jdbcTemplate = new JdbcTemplate (context .getBean (DataSource .class ));
74
78
jdbcTemplate .execute ("SHUTDOWN" );
75
79
}
76
80
77
81
private DataSource buildDataSource () {
78
- var connectionUrl = String .format (
82
+ String connectionUrl = String .format (
79
83
"jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false;MODE=%s" ,
80
84
UUID .randomUUID (),
81
85
this .compatibilityMode
82
86
);
83
- var dataSource = new SimpleDriverDataSource (new org .h2 .Driver (), connectionUrl , "sa" , "" );
84
- var populator = new ResourceDatabasePopulator ();
85
- var resource = new DefaultResourceLoader ()
87
+ DataSource dataSource = new SimpleDriverDataSource (new org .h2 .Driver (), connectionUrl , "sa" , "" );
88
+ ResourceDatabasePopulator populator = new ResourceDatabasePopulator ();
89
+ Resource resource = new DefaultResourceLoader ()
86
90
.getResource ("/org/springframework/batch/core/schema-h2.sql" );
87
91
populator .addScript (resource );
88
92
DatabasePopulatorUtils .execute (populator , dataSource );
@@ -106,6 +110,6 @@ Job job(JobBuilderFactory jobs, StepBuilderFactory steps) {
106
110
public static List <Object []> data () throws Exception {
107
111
return Arrays .stream (org .h2 .engine .Mode .ModeEnum .values ())
108
112
.map (mode -> new Object []{mode .toString ()})
109
- .toList ();
113
+ .collect ( Collectors . toList () );
110
114
}
111
115
}
0 commit comments