1
1
/*
2
- * Copyright 2006-2007 the original author or authors.
2
+ * Copyright 2006-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
28
28
import org .springframework .batch .core .JobExecution ;
29
29
import org .springframework .batch .core .JobParameters ;
30
30
import org .springframework .batch .core .JobParametersBuilder ;
31
+ import org .springframework .batch .core .launch .JobOperator ;
31
32
import org .springframework .batch .test .JobLauncherTestUtils ;
32
33
import org .springframework .beans .factory .annotation .Autowired ;
33
34
import org .springframework .test .context .ContextConfiguration ;
34
35
import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
35
36
36
37
/**
37
38
* Functional test for graceful shutdown. A batch container is started in a new
38
- * thread, then it's stopped using {@link JobExecution #stop()}.
39
+ * thread, then it's stopped using {@link JobOperator #stop(long )}.
39
40
*
40
41
* @author Lucas Ward
42
+ * @author Parikshit Dutta
41
43
*
42
44
*/
43
45
@ RunWith (SpringJUnit4ClassRunner .class )
@@ -50,6 +52,9 @@ public class GracefulShutdownFunctionalTests {
50
52
@ Autowired
51
53
private JobLauncherTestUtils jobLauncherTestUtils ;
52
54
55
+ @ Autowired
56
+ private JobOperator jobOperator ;
57
+
53
58
@ Test
54
59
public void testLaunchJob () throws Exception {
55
60
@@ -63,7 +68,7 @@ public void testLaunchJob() throws Exception {
63
68
assertEquals (BatchStatus .STARTED , jobExecution .getStatus ());
64
69
assertTrue (jobExecution .isRunning ());
65
70
66
- jobExecution .stop ();
71
+ jobOperator .stop (jobExecution . getId () );
67
72
68
73
int count = 0 ;
69
74
while (jobExecution .isRunning () && count <= 10 ) {
@@ -74,7 +79,5 @@ public void testLaunchJob() throws Exception {
74
79
75
80
assertFalse ("Timed out waiting for job to end." , jobExecution .isRunning ());
76
81
assertEquals (BatchStatus .STOPPED , jobExecution .getStatus ());
77
-
78
82
}
79
-
80
83
}
0 commit comments