### Question:
JCacheEntry implements CacheEntry { public boolean isValid() { if (element != null) { return !element.isExpired(); } else { return false; } } JCacheEntry(Element element); Object getKey(); Object getValue(); Object setValue(Object value); long getCost(); long getCreationTime(); long getExpirationTime(); int getHits(); long getLastAccessTime(); long getLastUpdateTime(); long getVersion(); boolean isValid();  }### Answer:
@Test public void testIsValid() throws Exception { Cache cache = getTestCache(); CacheEntry entry = new JCacheEntry(new Element("key1", "value1")); assertEquals(true, entry.isValid()); cache.put(entry.getKey(), entry.getValue()); CacheEntry retrievedEntry = cache.getCacheEntry(entry.getKey()); assertEquals(true, retrievedEntry.isValid()); Thread.sleep(1020); assertEquals(false, retrievedEntry.isValid()); }
@Test public void testIsValid() throws Exception { Cache cache = getTestCache(); CacheEntry entry = new JCacheEntry(new Element("key1", "value1")); assertEquals(true, entry.isValid()); cache.put(entry.getKey(), entry.getValue()); CacheEntry retrievedEntry = cache.getCacheEntry(entry.getKey()); assertEquals(true, retrievedEntry.isValid()); Thread.sleep(1999); assertEquals(false, retrievedEntry.isValid()); }