### Question:
TimeCache { TimeCache(long span) { this.span = span; } TimeCache(long span); void add(String msg); boolean has(String msg); void sweep();  }### Answer:
@Test public void testTimeCache() throws InterruptedException { TimeCache timeCache = new TimeCache(1000); for (int i = 0; i < 1000; i++) { timeCache.add(String.valueOf(i)); } Thread.sleep(1001); timeCache.sweep(); for (int i = 0; i < 1000; i++) { Asserts.check(!timeCache.has(String.valueOf(i)), "has expired element:" + i); } for (int i = 1001; i < 2000; i++) { timeCache.add(String.valueOf(i)); } for (int i = 1001; i < 2000; i++) { Asserts.check(timeCache.has(String.valueOf(i)), "no has element:" + i); } }