svn commit: r929839 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r929839 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java

doogie-3
Author: doogie
Date: Thu Apr  1 04:47:25 2010
New Revision: 929839

URL: http://svn.apache.org/viewvc?rev=929839&view=rev
Log:
New changeMemSize tests.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java?rev=929839&r1=929838&r2=929839&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java Thu Apr  1 04:47:25 2010
@@ -333,10 +333,28 @@ public class UtilCacheTests extends Gene
         }
         cache.setMaxInMemory(2);
         for (int i = 0; i < size - 2; i++) {
+            map.remove(Integer.toString(i));
+        }
+        assertEquals("map-keys", map.keySet(), cache.getCacheLineKeys());
+        assertEquals("map-values", map.values(), cache.values());
+        cache.setMaxInMemory(0);
+        assertEquals("map-keys", map.keySet(), cache.getCacheLineKeys());
+        assertEquals("map-values", map.values(), cache.values());
+        for (int i = size * 2; i < size * 3; i++) {
             String s = Integer.toString(i);
-            map.remove(s);
+            assertKey(s, cache, s, new String(s), new String(":" + s), i - size * 2 + 3, map);
+        }
+        cache.setMaxInMemory(0);
+        assertEquals("map-keys", map.keySet(), cache.getCacheLineKeys());
+        assertEquals("map-values", map.values(), cache.values());
+        cache.setMaxInMemory(size);
+        for (int i = 0; i < size * 2; i++) {
+            map.remove(Integer.toString(i));
         }
-        assertEquals("size", 2, cache.size());
+        // Can't compare the contents of these collections, as setting LRU after not
+        // having one, means the items that get evicted are essentially random.
+        assertEquals("map-keys", map.keySet().size(), cache.getCacheLineKeys().size());
+        assertEquals("map-values", map.values().size(), cache.values().size());
     }
 
     private void expireTest(UtilCache<String, Serializable> cache, int size, long ttl) throws Exception {