|
1 | 1 | /*
|
2 |
| - * Copyright 2006-2018 the original author or authors. |
| 2 | + * Copyright 2006-2020 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.
|
|
57 | 57 | * <p>
|
58 | 58 | * It should be noted that using any of the methods that don't contain
|
59 | 59 | * {@link JobParameters} in their signature, will result in one being created
|
60 |
| - * with the current system time as a parameter. This will ensure restartability |
61 |
| - * when no parameters are provided. |
| 60 | + * with a random number of type {@code long} as a parameter. This will ensure |
| 61 | + * restartability when no parameters are provided. |
62 | 62 | * </p>
|
63 | 63 | *
|
64 | 64 | * @author Lucas Ward
|
|
69 | 69 | */
|
70 | 70 | public class JobLauncherTestUtils {
|
71 | 71 |
|
72 |
| - private static final long JOB_PARAMETER_MAXIMUM = 1000000; |
| 72 | + private SecureRandom secureRandom = new SecureRandom(); |
73 | 73 |
|
74 | 74 | /** Logger */
|
75 | 75 | protected final Log logger = LogFactory.getLog(getClass());
|
@@ -156,12 +156,12 @@ public JobExecution launchJob(JobParameters jobParameters) throws Exception {
|
156 | 156 | }
|
157 | 157 |
|
158 | 158 | /**
|
159 |
| - * @return a new JobParameters object containing only a parameter for the |
160 |
| - * current timestamp, to ensure that the job instance will be unique. |
| 159 | + * @return a new JobParameters object containing only a parameter with a |
| 160 | + * random number of type {@code long}, to ensure that the job instance will be unique. |
161 | 161 | */
|
162 | 162 | public JobParameters getUniqueJobParameters() {
|
163 | 163 | Map<String, JobParameter> parameters = new HashMap<>();
|
164 |
| - parameters.put("random", new JobParameter(new SecureRandom().nextLong())); |
| 164 | + parameters.put("random", new JobParameter(this.secureRandom.nextLong())); |
165 | 165 | return new JobParameters(parameters);
|
166 | 166 | }
|
167 | 167 |
|
|
0 commit comments