This is an automated email from the ASF dual-hosted git repository. fschumacher pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jmeter.git
commit 9fb66c4ab00c8198b97f49962f262b46ce877438 Author: Felix Schumacher <[email protected]> AuthorDate: Mon Apr 18 17:11:15 2022 +0200 Use newer time API to make error prone happy --- .../apache/jmeter/threads/TestJMeterThread.java | 6 +-- .../functions/TestTimeRandomDateFunction.java | 46 +++++++++++----------- .../jmeter/functions/TestTimeShiftFunction.java | 20 +++++----- .../http/control/TestCacheManagerBase.java | 44 +++++++++++---------- .../control/TestCacheManagerThreadIteration.java | 29 +++++++------- 5 files changed, 75 insertions(+), 70 deletions(-) diff --git a/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java b/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java index 9cbbc3be42..7ad315d949 100644 --- a/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java +++ b/src/core/src/test/java/org/apache/jmeter/threads/TestJMeterThread.java @@ -20,7 +20,7 @@ package org.apache.jmeter.threads; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import java.util.Date; +import java.time.Instant; import org.apache.jmeter.control.LoopController; import org.apache.jmeter.samplers.AbstractSampler; @@ -156,9 +156,9 @@ class TestJMeterThread { jMeterThread.setScheduled(true); jMeterThread.setEndTime(System.currentTimeMillis() + maxDuration); jMeterThread.setThreadGroup(threadGroup); - long startTime = new Date().getTime(); + Instant startTime = Instant.now(); jMeterThread.run(); - long duration = new Date().getTime() - startTime; + long duration = Instant.now().toEpochMilli() - startTime.toEpochMilli(); assertFalse("Sampler should not be called", dummySampler.isCalled()); diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeRandomDateFunction.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeRandomDateFunction.java index b53f7bdf01..b0e99fd660 100644 --- a/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeRandomDateFunction.java +++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeRandomDateFunction.java @@ -21,10 +21,9 @@ import static org.apache.jmeter.functions.FunctionTestHelper.makeParams; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import java.time.LocalDate; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.Collection; @@ -34,6 +33,7 @@ import org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.threads.JMeterContext; import org.apache.jmeter.threads.JMeterContextService; import org.apache.jmeter.threads.JMeterVariables; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -46,7 +46,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { private String value; @BeforeEach - public void setUp() { + void setUp() { jmctx = JMeterContextService.getContext(); vars = new JMeterVariables(); jmctx.setVariables(vars); @@ -56,12 +56,12 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testParameterCount() throws Exception { + void testParameterCount() throws Exception { checkInvalidParameterCounts(function, 3, 5); } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { String endDate = "2099-01-01"; String formatDate = "yyyy-dd-MM"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatDate); @@ -69,22 +69,22 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { function.setParameters(params); value = function.execute(result, null); LocalDate result = LocalDate.parse(value, formatter); - LocalDate now = LocalDate.now(); + LocalDate now = LocalDate.now(ZoneId.systemDefault()); LocalDate max = LocalDate.parse(endDate, formatter); - assertTrue(now.isBefore(result) && result.isBefore(max)); + Assertions.assertTrue(now.isBefore(result) && result.isBefore(max)); } @Test - public void testDefault2() throws Exception { + void testDefault2() throws Exception { String endDate = "2099-01-01"; Collection<CompoundVariable> params = makeParams("yyyy-dd-MM", "", endDate, "", ""); function.setParameters(params); value = function.execute(result, null); - assertEquals(10, value.length()); + Assertions.assertEquals(10, value.length()); } @Test - public void testFormatDate() throws Exception { + void testFormatDate() throws Exception { String endDate = "01 01 2099"; String formatDate = "dd MM yyyy"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatDate); @@ -92,23 +92,23 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { function.setParameters(params); value = function.execute(result, null); LocalDate result = LocalDate.parse(value, formatter); - LocalDate now = LocalDate.now(); + LocalDate now = LocalDate.now(ZoneId.systemDefault()); LocalDate max = LocalDate.parse(endDate, formatter); - assertTrue(now.isBefore(result) && result.isBefore(max)); + Assertions.assertTrue(now.isBefore(result) && result.isBefore(max)); } @Test - public void testFormatDate2() throws Exception { + void testFormatDate2() throws Exception { String endDate = "01012099"; String formatDate = "ddMMyyyy"; Collection<CompoundVariable> params = makeParams(formatDate, "", endDate, "", ""); function.setParameters(params); value = function.execute(result, null); - assertEquals(8, value.length()); + Assertions.assertEquals(8, value.length()); } @Test - public void testFormatDate3() throws Exception { + void testFormatDate3() throws Exception { String startDate = "29 Aug 2111"; String endDate = "30 Aug 2111"; String formatDate = "dd MMM yyyy"; @@ -120,7 +120,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testFrenchFormatDate() throws Exception { + void testFrenchFormatDate() throws Exception { String startDate = "29 mars 2111"; String endDate = "30 mars 2111"; String formatDate = "dd MMM yyyy"; @@ -132,7 +132,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testEmptyFormatDate() throws Exception { + void testEmptyFormatDate() throws Exception { String startDate = "2111-03-29"; String endDate = "2111-03-30"; String formatDate = ""; @@ -144,7 +144,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testEndDateBeforeStartDate() throws Exception { + void testEndDateBeforeStartDate() throws Exception { String startDate = "2111-03-29"; String endDate = "2011-03-30"; String formatDate = ""; @@ -156,7 +156,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testEndDateBeforeStartDateNullVariable() throws Exception { + void testEndDateBeforeStartDateNullVariable() throws Exception { String startDate = "2111-03-29"; String endDate = "2111-03-30"; String formatDate = ""; @@ -168,7 +168,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testEndDateBeforeStartDateWithVariable() throws Exception { + void testEndDateBeforeStartDateWithVariable() throws Exception { String startDate = "2111-03-29"; String endDate = "2111-03-30"; String formatDate = ""; @@ -181,7 +181,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testInvalidFormat() throws Exception { + void testInvalidFormat() throws Exception { String startDate = "2111-03-29"; String endDate = "2011-03-30"; String formatDate = "abcd"; @@ -193,7 +193,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testInvalidStartDateFormat() throws Exception { + void testInvalidStartDateFormat() throws Exception { String startDate = "23-2111-03"; String endDate = "2011-03-30"; String formatDate = "abcd"; @@ -205,7 +205,7 @@ public class TestTimeRandomDateFunction extends JMeterTestCase { } @Test - public void testInvalidEndDateFormat() throws Exception { + void testInvalidEndDateFormat() throws Exception { String startDate = "2011-03-30"; String endDate = "23-2111-03"; String formatDate = "abcd"; diff --git a/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java b/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java index f3d53da157..a307ed8334 100644 --- a/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java +++ b/src/functions/src/test/java/org/apache/jmeter/functions/TestTimeShiftFunction.java @@ -98,7 +98,7 @@ class TestTimeShiftFunction extends JMeterTestCase { long resultat = Long.parseLong(value); LocalDateTime nowFromFunction = LocalDateTime.ofInstant(Instant.ofEpochMilli(resultat), TimeZone.getDefault().toZoneId()); - assertThat(nowFromFunction, within(5, ChronoUnit.SECONDS, LocalDateTime.now())); + assertThat(nowFromFunction, within(5, ChronoUnit.SECONDS, LocalDateTime.now(ZoneId.systemDefault()))); } @Test @@ -106,7 +106,7 @@ class TestTimeShiftFunction extends JMeterTestCase { Collection<CompoundVariable> params = makeParams("yyyy-MM-dd", "", "P1d", ""); function.setParameters(params); value = function.execute(result, null); - LocalDate tomorrow = LocalDate.now().plusDays(1); + LocalDate tomorrow = LocalDate.now(ZoneId.systemDefault()).plusDays(1); LocalDate tomorrowFromFunction = LocalDate.parse(value); assertThat(tomorrowFromFunction, sameDay(tomorrow)); } @@ -120,16 +120,18 @@ class TestTimeShiftFunction extends JMeterTestCase { Collection<CompoundVariable> params = makeParams("yyyy-MM-dd'T'HH:mm:ss", "", "P10DT-1H-5M5S", ""); function.setParameters(params); value = function.execute(result, null); - LocalDateTime futureDate = LocalDateTime.now().plusDays(10).plusHours(-1).plusMinutes(-5).plusSeconds(5); + LocalDateTime futureDate = LocalDateTime.now(ZoneId.systemDefault()) + .plusDays(10).plusHours(-1).plusMinutes(-5).plusSeconds(5); LocalDateTime futureDateFromFunction = LocalDateTime.parse(value); assertThat(futureDateFromFunction, within(1, ChronoUnit.SECONDS, futureDate)); } - private BooleanSupplier dstChangeAhead(String duration) { + private static BooleanSupplier dstChangeAhead(String duration) { return () -> { ZoneId defaultZoneId = ZoneId.systemDefault(); - Instant now = LocalDateTime.now().atZone(defaultZoneId).toInstant(); - Instant then = LocalDateTime.now().plus(Duration.parse(duration)).atZone(defaultZoneId).toInstant(); + Instant now = LocalDateTime.now(defaultZoneId).atZone(defaultZoneId).toInstant(); + Instant then = LocalDateTime.now(defaultZoneId).plus(Duration.parse(duration)) + .atZone(defaultZoneId).toInstant(); ZoneRules rules = defaultZoneId.getRules(); Duration nowDST = rules.getDaylightSavings(now); Duration thenDST = rules.getDaylightSavings(then); @@ -180,7 +182,7 @@ class TestTimeShiftFunction extends JMeterTestCase { long resultat = Long.parseLong(value); LocalDateTime nowFromFunction = LocalDateTime.ofInstant(Instant.ofEpochMilli(resultat), TimeZone.getDefault().toZoneId()); - assertThat(nowFromFunction, within(5, ChronoUnit.SECONDS, LocalDateTime.now())); + assertThat(nowFromFunction, within(5, ChronoUnit.SECONDS, LocalDateTime.now(ZoneId.systemDefault()))); } @Test @@ -200,13 +202,13 @@ class TestTimeShiftFunction extends JMeterTestCase { function.setParameters(params); value = function.execute(result, null); LocalDateTime randomFutureDate = LocalDateTime.parse(value); - LocalDateTime checkFutureDate = LocalDateTime.now().plusMinutes(randomInt); + LocalDateTime checkFutureDate = LocalDateTime.now(ZoneId.systemDefault()).plusMinutes(randomInt); assertThat(randomFutureDate, within(5, ChronoUnit.SECONDS, checkFutureDate)); randomInt = r.ints(1, 60).limit(1).findFirst().getAsInt(); vars.put("random", String.valueOf(randomInt)); value = function.execute(result, null); randomFutureDate = LocalDateTime.parse(value); - checkFutureDate = LocalDateTime.now().plusMinutes(randomInt); + checkFutureDate = LocalDateTime.now(ZoneId.systemDefault()).plusMinutes(randomInt); assertThat(randomFutureDate, within(5, ChronoUnit.SECONDS, checkFutureDate)); } diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java index b2e0def17e..e776c2842f 100644 --- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java +++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java @@ -25,11 +25,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.Locale; import java.util.Map; -import java.util.TimeZone; import org.apache.jmeter.junit.JMeterTestCase; import org.apache.jmeter.protocol.http.control.CacheManager.CacheEntry; @@ -43,22 +43,23 @@ import org.junit.jupiter.api.parallel.ExecutionMode; public abstract class TestCacheManagerBase extends JMeterTestCase { protected static final String LOCAL_HOST = "http://localhost/"; protected static final String EXPECTED_ETAG = "0xCAFEBABEDEADBEEF"; - protected static final TimeZone GMT = TimeZone.getTimeZone("GMT"); + protected static final ZoneId GMT = ZoneId.of("GMT"); protected CacheManager cacheManager; protected String currentTimeInGMT; protected String vary = null; protected URL url; protected HTTPSampleResult sampleResultOK; - protected String makeDate(Date d) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); - simpleDateFormat.setTimeZone(GMT); - return simpleDateFormat.format(d); + protected String makeDate(Instant d) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z") + .withLocale(Locale.US) + .withZone(GMT); + return formatter.format(d); } public void setUp() throws Exception { this.cacheManager = new CacheManager(); - this.currentTimeInGMT = makeDate(new Date()); + this.currentTimeInGMT = makeDate(Instant.now()); this.url = new URL(LOCAL_HOST); this.sampleResultOK = getSampleResultWithSpecifiedResponseCode("200"); @@ -106,7 +107,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.testIterationStart(null); assertNoSuchEntry(); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start + 2000))); + setExpires(makeDate(Instant.ofEpochMilli(start + 2000))); cacheResultWithGivenCode("304"); assertValidEntry(); sleepTill(start + 2010); @@ -119,7 +120,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.testIterationStart(null); assertNoSuchEntry(); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start + 2000))); + setExpires(makeDate(Instant.ofEpochMilli(start + 2000))); cacheResult(sampleResultOK); assertValidEntry(); sleepTill(start + 2010); @@ -131,7 +132,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.setUseExpires(false); this.cacheManager.testIterationStart(null); assertNoSuchEntry(); - setExpires(makeDate(new Date(System.currentTimeMillis() + 2000))); + setExpires(makeDate(Instant.ofEpochMilli(System.currentTimeMillis() + 2000))); cacheResult(sampleResultOK); assertInvalidEntry(); } @@ -142,7 +143,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.testIterationStart(null); assertNoSuchEntry(); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("public, max-age=1"); cacheResult(sampleResultOK); assertValidEntry(); @@ -213,7 +214,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.testIterationStart(null); assertNull(getThreadCacheEntry(LOCAL_HOST), "Should not find entry"); assertFalse(this.cacheManager.inCache(url, origHeaders), "Should not find valid entry"); - setExpires(makeDate(new Date(System.currentTimeMillis()))); + setExpires(makeDate(Instant.ofEpochMilli(System.currentTimeMillis()))); setCacheControl("public, max-age=5"); sampleResultOK.setRequestHeaders(asString(origHeaders)); this.vary = vary; @@ -230,7 +231,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.setUseExpires(true); this.cacheManager.testIterationStart(null); assertNoSuchEntry(); - setExpires(makeDate(new Date(System.currentTimeMillis()))); + setExpires(makeDate(Instant.ofEpochMilli(System.currentTimeMillis()))); setCacheControl("public, max-age=5"); HTTPSampleResult sampleResultHEAD = getSampleResultWithSpecifiedResponseCode("200"); sampleResultHEAD.setHTTPMethod("HEAD"); @@ -244,7 +245,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.testIterationStart(null); assertNoSuchEntry(); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("private, max-age=1"); cacheResult(sampleResultOK); assertValidEntry(); @@ -264,7 +265,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { // be fresh for the next 10% of X seconds == 0.1*X seconds long start = System.currentTimeMillis(); long age = 30 * 1000; // 30 seconds - setLastModified(makeDate(new Date(start - age))); + setLastModified(makeDate(Instant.ofEpochMilli(start - age))); cacheResult(sampleResultOK); assertValidEntry(); sleepTill(start + age / 10 + 1010); @@ -283,7 +284,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { // be fresh for the next 10% of X seconds == 0.1*X seconds long start = System.currentTimeMillis(); long age = 30 * 1000; // 30 seconds - setLastModified(makeDate(new Date(start - age))); + setLastModified(makeDate(Instant.ofEpochMilli(start - age))); cacheResult(sampleResultOK); assertValidEntry(); sleepTill(start + age / 10 + 1010); @@ -296,7 +297,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.testIterationStart(null); assertNoSuchEntry(); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start + 2000))); + setExpires(makeDate(Instant.ofEpochMilli(start + 2000))); setCacheControl("private"); cacheResult(sampleResultOK); assertValidEntry(); @@ -340,7 +341,7 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { this.cacheManager.testIterationStart(null); assertNoSuchEntry(); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("public, max-age=1, no-transform"); cacheResult(sampleResultOK); assertValidEntry(); @@ -352,7 +353,8 @@ public abstract class TestCacheManagerBase extends JMeterTestCase { private void assertInvalidEntry() throws Exception { CacheEntry cachedEntry = getThreadCacheEntry(LOCAL_HOST); assertNotNull(getThreadCacheEntry(LOCAL_HOST), "Should find entry"); - assertFalse(this.cacheManager.inCache(url), "Should not find valid entry. Found: " + cachedEntry + " at " + System.currentTimeMillis()); + assertFalse(this.cacheManager.inCache(url), + () -> "Should not find valid entry. Found: " + cachedEntry + " at " + System.currentTimeMillis()); } @SuppressWarnings("deprecation") diff --git a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java index cbf6e6a590..68c260cc9f 100644 --- a/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java +++ b/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerThreadIteration.java @@ -25,13 +25,13 @@ import static org.junit.Assert.assertTrue; import java.lang.reflect.Field; import java.net.URISyntaxException; import java.net.URL; -import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.TimeZone; import org.apache.http.Header; import org.apache.http.HttpEntity; @@ -62,7 +62,7 @@ public class TestCacheManagerThreadIteration { private static final String SAME_USER="__jmv_SAME_USER"; protected static final String LOCAL_HOST = "http://localhost/"; protected static final String EXPECTED_ETAG = "0xCAFEBABEDEADBEEF"; - protected static final TimeZone GMT = TimeZone.getTimeZone("GMT"); + protected static final ZoneId GMT = ZoneId.of("GMT"); protected CacheManager cacheManager; protected String currentTimeInGMT; protected String vary = null; @@ -226,10 +226,11 @@ public class TestCacheManagerThreadIteration { } } - protected String makeDate(Date d) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); - simpleDateFormat.setTimeZone(GMT); - return simpleDateFormat.format(d); + protected String makeDate(Instant d) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z") + .withLocale(Locale.US) + .withZone(GMT); + return formatter.format(d); } protected HTTPSampleResult getSampleResultWithSpecifiedResponseCode(String code) { @@ -246,7 +247,7 @@ public class TestCacheManagerThreadIteration { @BeforeEach public void setUp() throws Exception { this.cacheManager = new CacheManager(); - this.currentTimeInGMT = makeDate(new Date()); + this.currentTimeInGMT = makeDate(Instant.now()); this.url = new URL(LOCAL_HOST); this.sampleResultOK = getSampleResultWithSpecifiedResponseCode("200"); this.httpMethod = new HttpPostStub(); @@ -311,7 +312,7 @@ public class TestCacheManagerThreadIteration { Header[] headers = new Header[1]; assertFalse("Should not find valid entry", this.cacheManager.inCache(url, headers)); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("public, max-age=1"); cacheResult(sampleResultOK); assertNotNull("Before iternation, should find entry", getThreadCacheEntry(LOCAL_HOST)); @@ -357,7 +358,7 @@ public class TestCacheManagerThreadIteration { Header[] headers = new Header[1]; assertFalse("Should not find valid entry", this.cacheManager.inCache(url, headers)); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("public, max-age=1"); cacheResult(sampleResultOK); this.cacheManager.setThreadContext(jmctx); @@ -373,7 +374,7 @@ public class TestCacheManagerThreadIteration { jmctx.setVariables(jmvars); this.cacheManager.setThreadContext(jmctx); start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("public, max-age=1"); cacheResult(sampleResultOK); assertNotNull("Before iternation, should find entry", getThreadCacheEntry(LOCAL_HOST)); @@ -396,7 +397,7 @@ public class TestCacheManagerThreadIteration { Header[] headers = new Header[1]; assertFalse("Should not find valid entry", this.cacheManager.inCache(url, headers)); long start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("public, max-age=1"); cacheResult(sampleResultOK); this.cacheManager.setThreadContext(jmctx); @@ -411,7 +412,7 @@ public class TestCacheManagerThreadIteration { jmctx.setVariables(jmvars); this.cacheManager.setThreadContext(jmctx); start = System.currentTimeMillis(); - setExpires(makeDate(new Date(start))); + setExpires(makeDate(Instant.ofEpochMilli(start))); setCacheControl("public, max-age=1"); cacheResult(sampleResultOK); assertNotNull("Before iteration, should find entry", getThreadCacheEntry(LOCAL_HOST));
