package pond.common.struc;

import org.junit.Test;
import pond.common.struc.cache.OnTimeExpiredCache;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

/**
 * Created by ed on 9/9/15.
 */
public class OnTimeExpiredCacheTest {

  @Test
  public void test() throws InterruptedException {

//    S._debug_on(TimeExpiredCache.class);
    OnTimeExpiredCache<String, String> cache = new OnTimeExpiredCache<>(30, 10);

    for (int i = 0; i < 100; i++) {
      cache.put(String.valueOf(i), String.valueOf(i) + "_str");
    }

    assertEquals("12_str", cache.get("12"));
    Thread.sleep(40);
    assertNull(cache.get("12"));

    for (int i = 100; i < 200; i++) {
      cache.put(String.valueOf(i), String.valueOf(i) + "_str");
    }

    assertNull(cache.get("12"));
    assertEquals("122_str", cache.get("122"));
    Thread.sleep(40);
    assertNull(cache.get("12"));
    assertNull(cache.get("122"));

  }

}

@@ -44,16 +44,38 @@
 t.Test;%0A
+import pond.common.S;%0A
 import p
@@ -117,16 +117,16 @@
 dCache;%0A
-
 %0Aimport 
@@ -461,9 +461,9 @@
 e%3C%3E(
-3
+4
 0, 1
@@ -628,37 +628,66 @@
    Thread.sleep(
-4
+6
 0);%0A
+    S.echo(cache.get(%2212%22));%0A
     assertNull(c
@@ -910,17 +910,17 @@
 d.sleep(
-4
+6
 0);%0A    

fix OnTimeExpiredCacheTest failure