Author: adriancole
Date: 2009-03-04 03:53:25 -0500 (Wed, 04 Mar 2009)
New Revision: 7834
Modified:
core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java
Log:
added test to ensure stop/start doesn't nuke values
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-04
00:18:45 UTC (rev 7833)
+++ core/branches/flat/src/test/java/org/horizon/loader/BaseCacheStoreTest.java 2009-03-04
08:53:25 UTC (rev 7834)
@@ -113,6 +113,30 @@
assert !cs.containsKey("k");
}
+ public void testStopStartDoesntNukeValues() throws InterruptedException,
CacheLoaderException {
+ assert !cs.containsKey("k1");
+ assert !cs.containsKey("k2");
+
+ long now = System.currentTimeMillis();
+ long lifespan = 1;
+ StoredEntry se1 = new StoredEntry("k1", "v1", now, now +
lifespan);
+ StoredEntry se2 = new StoredEntry("k2", "v2");
+
+ cs.store(se1);
+ cs.store(se2);
+ Thread.sleep(100);
+ cs.stop();
+ cs.start();
+ assert se1.isExpired();
+ assert cs.load("k1") == null;
+ assert !cs.containsKey("k1");
+ assert cs.load("k2") != null;
+ assert cs.containsKey("k2");
+ assert cs.load("k2").getValue().equals("v2");
+
+ }
+
+
public void testOnePhaseCommit() throws CacheLoaderException {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new Store(new StoredEntry("k1", "v1", -1, -1)));