Commits

Anonymous committed ffcf1c8

long problem fixed!
avoid that flush time is equal to last update time of a new entry, because on fast pcs content maybe created twice

Comments (0)

Files changed (1)

src/test/java/com/opensymphony/oscache/web/TestOscacheFilter.java

         flushCache();
 
         // Call the page for the second time
-        String stringResponse = invokeURL(baseUrl, 500);
+        String stringResponse = invokeURL(baseUrl, 200);
 
         // Connect again, we should have the same content
         String newResponse = invokeURL(baseUrl, 0);
 
         // Try again with a session ID this time. The session ID should get filtered
         // out of the cache key so the content should be the same
-        newResponse = invokeURL(baseUrl + "?" + SESSION_ID, 500);
+        newResponse = invokeURL(baseUrl + "?" + SESSION_ID, 200);
         assertTrue("new response by a session id request " + newResponse + " should be the same to " + stringResponse, stringResponse.equals(newResponse));
 
         // Connect again with extra params, the content should be different
-        newResponse = invokeURL(baseUrl + "?" + PARAM_1 + "&" + PARAM_2, 1000);
+        newResponse = invokeURL(baseUrl + "?" + PARAM_1 + "&" + PARAM_2, 500);
         assertFalse("new response " + newResponse + " expected it to be different to last one.", stringResponse.equals(newResponse));
 
         stringResponse = newResponse;
     public void testOSCacheFilterFast() {
         String baseUrl = constructURL(BASE_PAGE);
 
-        for (int i = 0; i < 5; i++) {
+        for (int i = 0; i < 10; i++) {
             // Flush the cache to avoid getting refreshed content from previous tests
             flushCache();
             // build the url
             String url = baseUrl + "?i=" + i;
-            String response = invokeURL(url, 500);
-            for (int j = 0; j < 3; j++) {
-                String newResponse = invokeURL(url, 500);
+            String response = invokeURL(url, 100);
+            for (int j = 0; j < 5; j++) {
+                String newResponse = invokeURL(url, 100);
                 assertTrue("Fast: new response (i="+i+",j="+j+") " + newResponse + " should be the same to " + response, response.equals(newResponse));
             }
         }
         String stringResponse = invokeURL(flushUrl, 0);
         
         assertTrue("Flushing the cache failed!", stringResponse.indexOf("This is some cache content") > 0);
+        
+        // avoid that flush time is equal to last update time of a new entry
+        try {
+            Thread.sleep(5);
+        } catch (InterruptedException ignore) {
+        }
     }
 
     /**
             return null;
         }
     }
+    
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.