public void testLoading() throws CacheLoaderException {
    assertNotInCacheAndStore("k1", "k2", "k3", "k4");
    for (int i = 1; i < 5; i++) store.store(TestInternalCacheEntryFactory.create("k" + i, "v" + i));
    for (int i = 1; i < 5; i++) assert cache.get("k" + i).equals("v" + i);
    // make sure we have no stale locks!!
    assertNoLocks(cache);

    for (int i = 1; i < 5; i++) cache.evict("k" + i);
    // make sure we have no stale locks!!
    assertNoLocks(cache);

    assert cache.putIfAbsent("k1", "v1-SHOULD-NOT-STORE").equals("v1");
    assert cache.remove("k2").equals("v2");
    assert cache.replace("k3", "v3-REPLACED").equals("v3");
    assert cache.replace("k4", "v4", "v4-REPLACED");
    // make sure we have no stale locks!!
    assertNoLocks(cache);

    assert cache.size() == 3
        : "Expected the cache to contain 3 elements but contained " + cache.size();

    for (int i = 1; i < 5; i++) cache.evict("k" + i);
    // make sure we have no stale locks!!
    assertNoLocks(cache);

    assert cache.isEmpty(); // cache size ops will not trigger a load

    cache.clear(); // this should propagate to the loader though
    assertNotInCacheAndStore("k1", "k2", "k3", "k4");
    // make sure we have no stale locks!!
    assertNoLocks(cache);
  }
  public void testLoadingToMemory() throws CacheLoaderException {
    assertNotInCacheAndStore("k1", "k2");
    store.store(TestInternalCacheEntryFactory.create("k1", "v1"));
    store.store(TestInternalCacheEntryFactory.create("k2", "v2"));

    assertInStoreNotInCache("k1", "k2");

    assert "v1".equals(cache.get("k1"));
    assert "v2".equals(cache.get("k2"));

    assertInCacheAndStore("k1", "v1");
    assertInCacheAndStore("k2", "v2");

    store.remove("k1");
    store.remove("k2");

    assertInCacheAndNotInStore("k1", "k2");
    assert "v1".equals(cache.get("k1"));
    assert "v2".equals(cache.get("k2"));
  }