public final static String MAP_CACHE_LEVEL = "org.apache.chemistry.opencmis.client.bindings.cache.impl.MapCacheLevelImpl";
public final static String LRU_CACHE_LEVEL = "org.apache.chemistry.opencmis.client.bindings.cache.impl.LruCacheLevelImpl";
public void testCache() throws Exception {
Cache cache;
cache = new CacheImpl();
cache.initialize(new String[] { MAP_CACHE_LEVEL, LRU_CACHE_LEVEL, MAP_CACHE_LEVEL, MAP_CACHE_LEVEL });
String value1 = "value1";
String value2 = "value2";
String value3 = "value3";
Object valueObj;
// put and get
cache.put(value1, "l1", "l2a", "l3", "l4");
cache.put(value2, "l1", "l2b", "l3", "l4");
cache.put(value3, "l1", "l2c", "l3", "l4");
valueObj = cache.get("l1", "l2a", "l3", "l4");
assertTrue(valueObj instanceof String);
assertTrue(value1 == valueObj);
valueObj = cache.get("l1", "l2b", "l3", "l4");
assertTrue(valueObj instanceof String);
assertTrue(value2 == valueObj);
valueObj = cache.get("l1", "l2c", "l3", "l4");
assertTrue(valueObj instanceof String);
assertTrue(value3 == valueObj);
// remove leaf
cache.remove("l1", "l2", "l3", "l4");
valueObj = cache.get("l1", "l2", "l3", "l4");
assertNull(valueObj);
// put and get
cache.put(value1, "l1", "l2", "l3", "l4");
valueObj = cache.get("l1", "l2", "l3", "l4");
assertTrue(valueObj instanceof String);
assertTrue(value1 == valueObj);
// remove branch
cache.remove("l1", "l2");
valueObj = cache.get("l1", "l2", "l3", "l4");
assertNull(valueObj);
}