use of org.apache.felix.cm.impl.SimpleFilter in project felix by apache.
the class CachingPersistenceManagerProxyTest method test_caching_is_applied.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void test_caching_is_applied() throws Exception {
String pid = "testDefaultPersistenceManager";
SimpleFilter filter = SimpleFilter.parse("(&(service.pid=" + pid + ")(property1=value1))");
PersistenceManager pm = new MockPersistenceManager();
CachingPersistenceManagerProxy cpm = new CachingPersistenceManagerProxy(pm);
Dictionary dictionary = new Hashtable();
dictionary.put("property1", "value1");
dictionary.put(Constants.SERVICE_PID, pid);
pm.store(pid, dictionary);
Collection<Dictionary> list = cpm.getDictionaries(filter);
assertEquals(1, list.size());
dictionary = new Hashtable();
dictionary.put("property1", "value2");
pid = "testDefaultPersistenceManager";
dictionary.put(Constants.SERVICE_PID, pid);
pm.store(pid, dictionary);
list = cpm.getDictionaries(filter);
assertEquals(1, list.size());
}
use of org.apache.felix.cm.impl.SimpleFilter in project felix by apache.
the class PersistenceManagerProxyTest method test_caching_is_avoided.
@SuppressWarnings({ "rawtypes", "unchecked" })
public void test_caching_is_avoided() throws Exception {
String pid = "testDefaultPersistenceManager";
SimpleFilter filter = SimpleFilter.parse("(&(service.pid=" + pid + ")(property1=value1))");
PersistenceManager pm = new MockNotCachablePersistenceManager();
PersistenceManagerProxy cpm = new PersistenceManagerProxy(pm);
Dictionary dictionary = new Hashtable();
dictionary.put("property1", "value1");
dictionary.put(Constants.SERVICE_PID, pid);
pm.store(pid, dictionary);
Collection<Dictionary> list = cpm.getDictionaries(filter);
assertEquals(1, list.size());
dictionary = new Hashtable();
dictionary.put("property1", "value2");
pid = "testDefaultPersistenceManager";
dictionary.put(Constants.SERVICE_PID, pid);
pm.store(pid, dictionary);
list = cpm.getDictionaries(filter);
assertEquals(0, list.size());
}
Aggregations