Skip to content

Commit 24852e3

Browse files
committed
Added wait in JsrJobOperatorTests#testApplicationContextClosingAfterJobSuccessful to give application context a chance to shut down before re-running the job
1 parent 152abb1 commit 24852e3

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java

+31-29
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,6 @@
1515
*/
1616
package org.springframework.batch.core.jsr.launch;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertNotNull;
20-
import static org.junit.Assert.assertNull;
21-
import static org.junit.Assert.assertTrue;
22-
import static org.junit.Assert.fail;
23-
import static org.mockito.Mockito.verify;
24-
import static org.mockito.Mockito.when;
25-
import static org.springframework.batch.core.jsr.JsrTestUtils.restartJob;
26-
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
27-
28-
import java.util.ArrayList;
29-
import java.util.Date;
30-
import java.util.HashSet;
31-
import java.util.List;
32-
import java.util.Properties;
33-
import java.util.Set;
34-
35-
import javax.batch.api.AbstractBatchlet;
36-
import javax.batch.api.Batchlet;
37-
import javax.batch.operations.JobExecutionIsRunningException;
38-
import javax.batch.operations.JobOperator;
39-
import javax.batch.operations.JobRestartException;
40-
import javax.batch.operations.JobStartException;
41-
import javax.batch.operations.NoSuchJobException;
42-
import javax.batch.operations.NoSuchJobExecutionException;
43-
import javax.batch.operations.NoSuchJobInstanceException;
44-
import javax.batch.runtime.BatchRuntime;
45-
import javax.batch.runtime.BatchStatus;
46-
4718
import org.junit.Before;
4819
import org.junit.Test;
4920
import org.mockito.ArgumentCaptor;
@@ -64,6 +35,34 @@
6435
import org.springframework.core.task.AsyncTaskExecutor;
6536
import org.springframework.core.task.SyncTaskExecutor;
6637

38+
import javax.batch.api.AbstractBatchlet;
39+
import javax.batch.api.Batchlet;
40+
import javax.batch.operations.JobExecutionIsRunningException;
41+
import javax.batch.operations.JobOperator;
42+
import javax.batch.operations.JobRestartException;
43+
import javax.batch.operations.JobStartException;
44+
import javax.batch.operations.NoSuchJobException;
45+
import javax.batch.operations.NoSuchJobExecutionException;
46+
import javax.batch.operations.NoSuchJobInstanceException;
47+
import javax.batch.runtime.BatchRuntime;
48+
import javax.batch.runtime.BatchStatus;
49+
import java.util.ArrayList;
50+
import java.util.Date;
51+
import java.util.HashSet;
52+
import java.util.List;
53+
import java.util.Properties;
54+
import java.util.Set;
55+
56+
import static org.junit.Assert.assertEquals;
57+
import static org.junit.Assert.assertNotNull;
58+
import static org.junit.Assert.assertNull;
59+
import static org.junit.Assert.assertTrue;
60+
import static org.junit.Assert.fail;
61+
import static org.mockito.Mockito.verify;
62+
import static org.mockito.Mockito.when;
63+
import static org.springframework.batch.core.jsr.JsrTestUtils.restartJob;
64+
import static org.springframework.batch.core.jsr.JsrTestUtils.runJob;
65+
6766
public class JsrJobOperatorTests {
6867

6968
private JobOperator jsrJobOperator;
@@ -550,6 +549,9 @@ public void testApplicationContextClosingAfterJobSuccessful() throws Exception {
550549
javax.batch.runtime.JobExecution execution = runJob("contextClosingTests", new Properties(), TIMEOUT);
551550

552551
assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
552+
553+
// Added to allow time for the context to finish closing before running the job again
554+
Thread.sleep(1000l);
553555
}
554556
}
555557

0 commit comments

Comments
 (0)