From 511e6c0f128394f7a9a6476c5a2c3c1455cb4985 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Tue, 19 May 2020 10:16:28 +0200 Subject: [PATCH] Polish 670b6408daf80e15d1311671252d728c70bdaa3f * Update year in license headers * Update Javadoc * Remove unused field JOB_PARAMETER_MAXIMUM * Make SecureRandom an instance variable --- .../batch/test/JobLauncherTestUtils.java | 14 +++++++------- .../batch/test/JobLauncherTestUtilsTests.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java index 05440c466..b4b844630 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobLauncherTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,8 +57,8 @@ import org.springframework.lang.Nullable; *

* It should be noted that using any of the methods that don't contain * {@link JobParameters} in their signature, will result in one being created - * with the current system time as a parameter. This will ensure restartability - * when no parameters are provided. + * with a random number of type {@code long} as a parameter. This will ensure + * restartability when no parameters are provided. *

* * @author Lucas Ward @@ -69,7 +69,7 @@ import org.springframework.lang.Nullable; */ public class JobLauncherTestUtils { - private static final long JOB_PARAMETER_MAXIMUM = 1000000; + private SecureRandom secureRandom = new SecureRandom(); /** Logger */ protected final Log logger = LogFactory.getLog(getClass()); @@ -156,12 +156,12 @@ public class JobLauncherTestUtils { } /** - * @return a new JobParameters object containing only a parameter for the - * current timestamp, to ensure that the job instance will be unique. + * @return a new JobParameters object containing only a parameter with a + * random number of type {@code long}, to ensure that the job instance will be unique. */ public JobParameters getUniqueJobParameters() { Map parameters = new HashMap<>(); - parameters.put("random", new JobParameter(new SecureRandom().nextLong())); + parameters.put("random", new JobParameter(this.secureRandom.nextLong())); return new JobParameters(parameters); } diff --git a/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java b/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java index 536e61a37..7722482ab 100644 --- a/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java +++ b/spring-batch-test/src/test/java/org/springframework/batch/test/JobLauncherTestUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.