Author: nbelaevski
Date: 2009-07-20 14:20:26 -0400 (Mon, 20 Jul 2009)
New Revision: 14966
Modified:
root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java
Log:
BaseCacheTest refactored
Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java
===================================================================
---
root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java 2009-07-20
17:25:47 UTC (rev 14965)
+++
root/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/BaseCacheTest.java 2009-07-20
18:20:26 UTC (rev 14966)
@@ -80,11 +80,25 @@
public void testExpiration() throws Exception {
assertNull(cache.get("a"));
- cache.put("a", "value-a", new Date(System.currentTimeMillis() +
3000));
+
+ long sleepTime = 0;
+ long expirationTime = System.currentTimeMillis() + 3000;
+
+ cache.put("a", "value-a", new Date(expirationTime));
assertEquals("value-a", cache.get("a"));
- Thread.sleep(2000);
+
+ //interval to reach 1 second before expiration time
+ sleepTime = expirationTime - 1000 - System.currentTimeMillis();
+ assertTrue(sleepTime > 0);
+ Thread.sleep(sleepTime);
+
assertEquals("value-a", cache.get("a"));
- Thread.sleep(2000);
+
+ //interval to reach 1 second after expiration time
+ sleepTime = expirationTime + 1000 - System.currentTimeMillis();
+ assertTrue(sleepTime > 0);
+
+ Thread.sleep(sleepTime);
assertNull(cache.get("a"));
}
}
Show replies by date