Search in sources :

Example 1 with LRUCache

use of com.jayway.jsonpath.spi.cache.LRUCache in project JsonPath by jayway.

the class IssuesTest method issue_94_2.

@Test
public void issue_94_2() throws Exception {
    LRUCache cache = new LRUCache(5);
    JsonPath dummy = JsonPath.compile("$");
    cache.put("1", dummy);
    cache.put("2", dummy);
    cache.put("3", dummy);
    cache.put("4", dummy);
    cache.put("5", dummy);
    cache.put("6", dummy);
    cache.get("1");
    cache.get("2");
    cache.get("3");
    cache.get("4");
    cache.get("5");
    cache.get("6");
    cache.get("2");
    cache.get("3");
    cache.get("4");
    cache.get("5");
    cache.get("6");
    cache.get("3");
    cache.get("4");
    cache.get("5");
    cache.get("6");
    cache.get("4");
    cache.get("5");
    cache.get("6");
    cache.get("5");
    cache.get("6");
    cache.get("6");
    assertThat(cache.getSilent("6")).isNotNull();
    assertThat(cache.getSilent("5")).isNotNull();
    assertThat(cache.getSilent("4")).isNotNull();
    assertThat(cache.getSilent("3")).isNotNull();
    assertThat(cache.getSilent("2")).isNotNull();
    assertThat(cache.getSilent("1")).isNull();
}
Also used : LRUCache(com.jayway.jsonpath.spi.cache.LRUCache) JsonPath(com.jayway.jsonpath.JsonPath) BaseTest(com.jayway.jsonpath.BaseTest) Test(org.junit.Test)

Example 2 with LRUCache

use of com.jayway.jsonpath.spi.cache.LRUCache in project JsonPath by jayway.

the class IssuesTest method issue_94_1.

@Test
public void issue_94_1() throws Exception {
    LRUCache cache = new LRUCache(200);
    JsonPath dummy = JsonPath.compile("$");
    for (int i = 0; i < 1000; ++i) {
        String key = String.valueOf(i);
        cache.get(key);
        cache.put(key, dummy);
    }
    assertThat(cache.size()).isEqualTo(200);
}
Also used : LRUCache(com.jayway.jsonpath.spi.cache.LRUCache) JsonPath(com.jayway.jsonpath.JsonPath) BaseTest(com.jayway.jsonpath.BaseTest) Test(org.junit.Test)

Aggregations

BaseTest (com.jayway.jsonpath.BaseTest)2 JsonPath (com.jayway.jsonpath.JsonPath)2 LRUCache (com.jayway.jsonpath.spi.cache.LRUCache)2 Test (org.junit.Test)2