Beispiel #1
0
 @Test
 public void testInvalidateSingleton() {
   CacheService cs = getCache();
   cs.longSingletonToCache_5("static");
   cs.__cacheData()
       .invalidateCache(MethodCall.get(cs.getClass(), "longSingletonToCache_5", "static"));
   int prev = cs.getCounter();
   cs.longSingletonToCache_5("static");
   assertTrue(prev + 1 == cs.getCounter());
 }
Beispiel #2
0
 @Test
 public void testInvalidateAllValues() {
   CacheService cs = getCache();
   cs.longServiceToCache_5("static1");
   cs.longServiceToCache_5("static2");
   cs.longServiceToCache_5("static3");
   cs.longServiceToCache_5("static4");
   cs.__cacheData()
       .invalidateCache(
           MethodCall.get(cs.getClass(), "longServiceToCache_5", "static").getMethod());
   int prev = cs.getCounter();
   cs.longServiceToCache_5("static1");
   cs.longServiceToCache_5("static2");
   cs.longServiceToCache_5("static3");
   cs.longServiceToCache_5("static4");
   assertTrue(prev + 4 == cs.getCounter());
 }
Beispiel #3
0
  @Test
  public void testSoftRef() {
    CacheService cs = getCache();
    try {
      for (int n = 0; n < 1000; n++) {
        cs.bigMemHard(n);
      }
      fail("should run out of ram");
    } catch (java.lang.OutOfMemoryError e) {
      // clear cache to free ram
      cs.__cacheData()
          .invalidateCache(MethodCall.get(cs.getClass(), "bigMemHard", (int) 0).getMethod());
    }

    for (int n = 0; n < 10; n++) {
      cs.bigMemSoft(n);
    }
  }