ham1 commented on code in PR #6891:
URL: https://github.com/apache/jmeter/pull/6891#discussion_r4739413716


##########
src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerBase.java:
##########
@@ -59,8 +62,9 @@ protected String makeDate(Instant d) {
     }
 
     public void setUp() throws Exception {
-        this.cacheManager = new CacheManager();
-        this.currentTimeInGMT = makeDate(Instant.now());
+        this.clock = new MutableClock(Instant.now());

Review Comment:
   Fixed in f4d38bd87: the clock now starts at 2026-11-30T00:00:00Z. With the 
system clock put back one read at a time, the `TestCacheManager*` tests now 
fail for the max-age read (11 failures), the Last-Modified read (6) and the 
fallback for a missing Date header (1, from a new test).
   
   The unparseable-Date fallback is still untested, because it can't be 
reached. HttpClient's `DateUtils.parseDate` returns `null` rather than throwing 
`IllegalArgumentException`, so a response with Last-Modified and an unparseable 
Date (and neither max-age nor Expires) throws a `NullPointerException` in 
`calcExpiresDate`. This PR doesn't change that, and I'd fix it separately.
   



##########
src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/control/TestCacheManagerHeaderSource.java:
##########
@@ -61,6 +64,23 @@ public void tearDown() throws Exception {
         super.tearDown();
     }
 
+    @Test
+    @SuppressWarnings("deprecation")
+    public void testCloneAndProxyKeepClock() throws Exception {
+        this.cacheManager.setUseExpires(true);
+        this.cacheManager = (CacheManager) this.cacheManager.clone();
+        this.cacheManager.testIterationStart(null);
+        setCacheControl("max-age=1");
+        long start = clock.millis();
+        cacheResult(sampleResultOK);
+        CacheManager proxy = this.cacheManager.createCacheManagerProxy();
+        assertTrue(this.cacheManager.inCache(url), "Clone should find valid 
entry");
+        assertTrue(proxy.inCache(url), "Proxy should find valid entry");
+        clock.setMillis(start + 2010);
+        assertFalse(this.cacheManager.inCache(url), "Clone should find expired 
entry");
+        assertFalse(proxy.inCache(url), "Proxy should find expired entry");

Review Comment:
   Split in f4d38bd87 into `testCloneKeepsClock` and `testProxyKeepsClock`, 
with the proxy made from the original cache manager.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to