@Test public void testBasicCache() { CacheService cs = getCache(); int result = cs.longServiceToCache_5("static"); for (int n = 0; n < 5; n++) { int loopresult = cs.longServiceToCache_5("static"); assertTrue(loopresult == result); } }
@Test public void testInvalidation() { CacheService cs = getCache(); cs.longServiceToCache_5("static"); cs.__cacheData() .invalidateCache(MethodCall.get(cs.getClass(), "longServiceToCache_5", "static")); int prev = cs.getCounter(); cs.longServiceToCache_5("static"); assertTrue(prev + 1 == cs.getCounter()); }
@Test public void testCacheMax() { CacheService cs = getCache(); for (int n = 0; n < 5; n++) { int loopresult = cs.longServiceToCache_5("" + n); assertTrue(loopresult == n); } for (int n = 0; n < 5; n++) { int loopresult = cs.longServiceToCache_5("" + n); assertTrue(loopresult == n); } assertTrue(0 == cs.longServiceToCache_5("0")); assertTrue(5 == cs.longServiceToCache_5("not cached")); }