20
20
import org .springframework .batch .core .ExitStatus ;
21
21
import org .springframework .batch .core .Job ;
22
22
import org .springframework .batch .core .JobExecution ;
23
+ import org .springframework .batch .core .JobParameters ;
23
24
import org .springframework .batch .core .Step ;
24
25
import org .springframework .batch .core .StepContribution ;
25
26
import org .springframework .batch .core .configuration .annotation .EnableBatchProcessing ;
35
36
import org .springframework .context .annotation .Configuration ;
36
37
import org .springframework .lang .Nullable ;
37
38
39
+ import java .util .HashSet ;
40
+ import java .util .Set ;
41
+
38
42
import static org .junit .Assert .assertEquals ;
43
+ import static org .junit .Assert .assertFalse ;
39
44
40
45
/**
41
46
* @author mminella
@@ -53,6 +58,18 @@ public void testStepExecutionWithJavaConfig() {
53
58
assertEquals (ExitStatus .COMPLETED , execution .getExitStatus ());
54
59
}
55
60
61
+ @ Test
62
+ public void getUniqueJobParameters_doesNotRepeatJobParameters () {
63
+ ApplicationContext context = new AnnotationConfigApplicationContext (TestJobConfiguration .class );
64
+ JobLauncherTestUtils testUtils = context .getBean (JobLauncherTestUtils .class );
65
+ Set <JobParameters > jobParametersSeen = new HashSet <>();
66
+ for (int i = 0 ; i < 10_000 ; i ++) {
67
+ JobParameters jobParameters = testUtils .getUniqueJobParameters ();
68
+ assertFalse (jobParametersSeen .contains (jobParameters ));
69
+ jobParametersSeen .add (jobParameters );
70
+ }
71
+ }
72
+
56
73
@ Configuration
57
74
@ EnableBatchProcessing
58
75
public static class TestJobConfiguration {
0 commit comments