You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2012/07/14 16:26:04 UTC
svn commit: r1361552 -
/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
Author: pmouawad
Date: Sat Jul 14 14:26:03 2012
New Revision: 1361552
URL: http://svn.apache.org/viewvc?rev=1361552&view=rev
Log:
Bug 53522 - Cache Manager should not store at all response with header "no-cache" and store other types of Cache-Control having max-age value
Added test case
Added sleep to ensure entries become invalid after their expiration date has passed
Bugzilla Id: 53522
Modified:
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java?rev=1361552&r1=1361551&r2=1361552&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/control/TestCacheManager.java Sat Jul 14 14:26:03 2012
@@ -190,6 +190,10 @@ public class TestCacheManager extends JM
this.cacheManager.saveDetails(this.urlConnection, sampleResultOK);
assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ Thread.sleep(2001);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
+
}
public void testNoExpiresJava() throws Exception{
@@ -209,10 +213,13 @@ public class TestCacheManager extends JM
assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
((URLConnectionStub)urlConnection).expires=makeDate(new Date(System.currentTimeMillis()));
- ((URLConnectionStub)urlConnection).cacheControl="public, max-age=10";
+ ((URLConnectionStub)urlConnection).cacheControl="public, max-age=5";
this.cacheManager.saveDetails(this.urlConnection, sampleResultOK);
assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ Thread.sleep(5001);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
}
public void testExpiresHttpClient() throws Exception{
@@ -224,6 +231,9 @@ public class TestCacheManager extends JM
this.cacheManager.saveDetails(httpMethod, sampleResultOK);
assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ Thread.sleep(2001);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
}
@@ -233,10 +243,13 @@ public class TestCacheManager extends JM
assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
((HttpMethodStub)httpMethod).expires=makeDate(new Date(System.currentTimeMillis()));
- ((HttpMethodStub)httpMethod).cacheControl="public, max-age=10";
+ ((HttpMethodStub)httpMethod).cacheControl="public, max-age=5";
this.cacheManager.saveDetails(httpMethod, sampleResultOK);
assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ Thread.sleep(5001);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
}
public void testPrivateCacheHttpClient() throws Exception{
@@ -245,11 +258,40 @@ public class TestCacheManager extends JM
assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
((HttpMethodStub)httpMethod).expires=makeDate(new Date(System.currentTimeMillis()));
- ((HttpMethodStub)httpMethod).cacheControl="private, max-age=10";
+ ((HttpMethodStub)httpMethod).cacheControl="private, max-age=5";
+ this.cacheManager.saveDetails(httpMethod, sampleResultOK);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ Thread.sleep(5001);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
+ }
+
+ public void testPrivateCacheNoMaxAgeNoExpireHttpClient() throws Exception{
+ this.cacheManager.setUseExpires(true);
+ this.cacheManager.testIterationStart(null);
+ assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
+ ((HttpMethodStub)httpMethod).cacheControl="private";
this.cacheManager.saveDetails(httpMethod, sampleResultOK);
assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
}
+
+ public void testPrivateCacheExpireNoMaxAgeHttpClient() throws Exception{
+ this.cacheManager.setUseExpires(true);
+ this.cacheManager.testIterationStart(null);
+ assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
+ ((HttpMethodStub)httpMethod).expires=makeDate(new Date(System.currentTimeMillis()+2000));
+ ((HttpMethodStub)httpMethod).cacheControl="private";
+ this.cacheManager.saveDetails(httpMethod, sampleResultOK);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ Thread.sleep(2001);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
+ }
public void testNoCacheHttpClient() throws Exception{
this.cacheManager.setUseExpires(true);
@@ -268,10 +310,13 @@ public class TestCacheManager extends JM
assertNull("Should not find entry",getThreadCacheEntry(LOCAL_HOST));
assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
((HttpMethodStub)httpMethod).expires=makeDate(new Date(System.currentTimeMillis()));
- ((HttpMethodStub)httpMethod).cacheControl="public, max-age=10, no-transform";
+ ((HttpMethodStub)httpMethod).cacheControl="public, max-age=5, no-transform";
this.cacheManager.saveDetails(httpMethod, sampleResultOK);
assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
assertTrue("Should find valid entry",this.cacheManager.inCache(url));
+ Thread.sleep(5001);
+ assertNotNull("Should find entry",getThreadCacheEntry(LOCAL_HOST));
+ assertFalse("Should not find valid entry",this.cacheManager.inCache(url));
}
public void testGetClearEachIteration() throws Exception {