Author: adriancole
Date: 2009-03-02 05:33:55 -0500 (Mon, 02 Mar 2009)
New Revision: 7818
Modified:
core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
Log:
added removeAll testcase
Modified: core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-02
10:18:44 UTC (rev 7817)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-02
10:33:55 UTC (rev 7818)
@@ -216,7 +216,7 @@
final Transaction tx = EasyMock.createNiceMock(Transaction.class);
cs.prepare(mods, tx, false);
- Thread t = new Thread(new Runnable(){
+ Thread t = new Thread(new Runnable() {
public void run() {
cs.rollback(tx);
}
@@ -237,7 +237,7 @@
cs.prepare(mods, tx, false);
- Thread t2 = new Thread(new Runnable(){
+ Thread t2 = new Thread(new Runnable() {
public void run() {
cs.rollback(tx);
}
@@ -277,6 +277,37 @@
assert expected.isEmpty();
}
+ @Test
+ public void testStoreAndRemoveAll() throws CacheLoaderException {
+ cs.store(new StoredEntry("k1", "v1", -1, -1));
+ cs.store(new StoredEntry("k2", "v2", -1, -1));
+ cs.store(new StoredEntry("k3", "v3", -1, -1));
+ cs.store(new StoredEntry("k4", "v4", -1, -1));
+
+
+ Set<StoredEntry> set = cs.loadAll();
+
+ assert set.size() == 4;
+ Set expected = new HashSet();
+ expected.add("k1");
+ expected.add("k2");
+ expected.add("k3");
+ expected.add("k4");
+ for (StoredEntry se : set) assert expected.remove(se.getKey());
+ assert expected.isEmpty();
+
+ Set toRemove = new HashSet();
+ toRemove.add("k1");
+ toRemove.add("k2");
+ toRemove.add("k3");
+ cs.removeAll(toRemove);
+
+ set = cs.loadAll();
+ assert set.size() == 1;
+ set.remove("k4");
+ assert expected.isEmpty();
+ }
+
public void testPurgeExpired() throws Exception {
long now = System.currentTimeMillis();
long lifespan = 1000;
Show replies by date