use of org.cache2k.processor.EntryProcessor in project cache2k by cache2k.
the class EntryProcessorTest method initial_GetYieldsNull.
@Test
public void initial_GetYieldsNull() {
Cache<Integer, Integer> c = target.cache();
final AtomicBoolean _reached = new AtomicBoolean(false);
EntryProcessor p = new EntryProcessor() {
@Override
public Object process(MutableCacheEntry e) throws Exception {
assertNull(e.getValue());
_reached.set(true);
return null;
}
};
final int _KEY = 123;
Object _result = c.invoke(_KEY, p);
assertNull(_result);
assertTrue("no exception during process", _reached.get());
assertFalse(c.containsKey(_KEY));
}
use of org.cache2k.processor.EntryProcessor in project cache2k by cache2k.
the class EntryProcessorTest method test_Initial_GetSet.
@Test
public void test_Initial_GetSet() {
target.statistics();
Cache<Integer, Integer> c = target.cache();
EntryProcessor p = new EntryProcessor() {
@Override
public Object process(MutableCacheEntry e) throws Exception {
Object o = e.getValue();
assertNull(o);
e.setValue("dummy");
return "abc";
}
};
Object _result = c.invoke(123, p);
assertEquals("abc", _result);
target.statistics().missCount.expect(1).getCount.expect(1).putCount.expect(1).expectAllZero();
}
use of org.cache2k.processor.EntryProcessor in project cache2k by cache2k.
the class EntryProcessorTest method test_Initial_Set.
@Test
public void test_Initial_Set() {
Cache<Integer, Integer> c = target.cache();
EntryProcessor p = new EntryProcessor() {
@Override
public Object process(MutableCacheEntry e) throws Exception {
e.setValue("dummy");
return "abc";
}
};
Object _result = c.invoke(123, p);
assertEquals("abc", _result);
}
Aggregations