@Test
public void testCapacity() throws InterruptedException {

    int timeout = 5000;
    cache = new TimedCache<TimedCacheTest.CacheEntry>(2, timeout);
    
    // Testing the capacity is tricky since the capacity can be 
    // exceeded for short amounts of time, so we try to flood the cache
    // to make sure the first entry is expired
    CacheEntry e1 = new CacheEntry(1);
    for (int i=0; i < 100; i++) {
        CacheEntry e = new CacheEntry(i);
        cache.update(e);
    }
    
    // entry 1 should have been expired due to capacity limits 
    assertEquals(false, cache.update(e1));
}