@Test public void isCorrectExpirationTimeSetForAppId() throws Exception { api_cache.report(createTransactionData()); long time1 = api_cache.getTransactionExpirationTimeFor("bce4c8f4"); assertEquals( "T1 had wrong expiration time", api_cache.getCurrentResponseExpirationTime(), time1); long time2 = api_cache.getTransactionExpirationTimeFor("bad7e480"); assertEquals( "T2 had wrong expiration time", api_cache.getCurrentResponseExpirationTime(), time2); }
@Test public void cacheEvictionTimeIsBeingSetCorrectly() throws Exception { api_cache.setReportExpirationInterval(200L); long currentTime = api_cache.getCurrentResponseExpirationTime(); Thread.sleep(550L); long newTime = api_cache.getCurrentResponseExpirationTime(); SimpleDateFormat df = new SimpleDateFormat("yyyy MM dd hh mm ss S"); log.info("Current time: " + df.format(currentTime)); log.info(" New time: " + df.format(newTime)); assertTrue("ExpirationTime was not incremented correctly", newTime == (currentTime + 200L)); }