testPolicy("test-ea-with-old-config");
}
private void testPolicy(String cacheName) throws Exception
{
EAExoCache cache = (EAExoCache)service_.getCacheInstance(cacheName);
cache.put("a", "a");
cache.put("b", "a");
cache.put("c", "a");
cache.put("d", "a");
Thread.sleep(1000);
assertEquals(4, cache.getCacheSize());
cache.put("e", "a");
assertEquals(5, cache.getCacheSize());
cache.put("f", "a");
assertEquals(6, cache.getCacheSize());
Thread.sleep(1100);
assertEquals(2, cache.getCacheSize());
Thread.sleep(1000);
assertEquals(0, cache.getCacheSize());
cache.setMaxSize(3);
cache.setLiveTime(400);
cache.setExpirationTimeout(500);
cache.put("a", "a");
cache.put("b", "a");
cache.put("c", "a");
cache.put("d", "a");
assertEquals(4, cache.getCacheSize());
cache.put("e", "a");
assertEquals(5, cache.getCacheSize());
cache.put("f", "a");
Thread.sleep(600);
assertEquals(0, cache.getCacheSize());
}