use of cn.taketoday.cache.Cache in project today-infrastructure by TAKETODAY.
the class AbstractJCacheAnnotationTests method earlyRemove.
@Test
public void earlyRemove() {
Cache cache = getCache(DEFAULT_CACHE);
Object key = createKey(this.keyItem);
Object value = new Object();
cache.put(key, value);
service.earlyRemove(this.keyItem);
assertThat(cache.get(key)).isNull();
}
use of cn.taketoday.cache.Cache in project today-infrastructure by TAKETODAY.
the class AbstractJCacheAnnotationTests method cacheExceptionVetoed.
@Test
public void cacheExceptionVetoed() {
Cache cache = getCache(EXCEPTION_CACHE);
Object key = createKey(this.keyItem);
assertThat(cache.get(key)).isNull();
assertThatNullPointerException().isThrownBy(() -> service.cacheWithException(this.keyItem, false));
assertThat(cache.get(key)).isNull();
}
use of cn.taketoday.cache.Cache in project today-infrastructure by TAKETODAY.
the class AbstractJCacheAnnotationTests method cacheCheckedException.
@Test
public void cacheCheckedException() {
Cache cache = getCache(EXCEPTION_CACHE);
Object key = createKey(this.keyItem);
assertThat(cache.get(key)).isNull();
assertThatIOException().isThrownBy(() -> service.cacheWithCheckedException(this.keyItem, true));
Cache.ValueWrapper result = cache.get(key);
assertThat(result).isNotNull();
assertThat(result.get().getClass()).isEqualTo(IOException.class);
}
use of cn.taketoday.cache.Cache in project today-infrastructure by TAKETODAY.
the class AbstractJCacheAnnotationTests method earlyPutWithExceptionVetoPut.
@Test
public void earlyPutWithExceptionVetoPut() {
Cache cache = getCache(DEFAULT_CACHE);
Object key = createKey(this.keyItem);
Object value = new Object();
assertThat(cache.get(key)).isNull();
assertThatNullPointerException().isThrownBy(() -> service.earlyPutWithException(this.keyItem, value, false));
// This will be cached anyway as the earlyPut has updated the cache before
Cache.ValueWrapper result = cache.get(key);
assertThat(result).isNotNull();
assertThat(result.get()).isEqualTo(value);
}
use of cn.taketoday.cache.Cache in project today-infrastructure by TAKETODAY.
the class AbstractJCacheAnnotationTests method removeAll.
@Test
public void removeAll() {
Cache cache = getCache(DEFAULT_CACHE);
Object key = createKey(this.keyItem);
cache.put(key, new Object());
service.removeAll();
assertThat(isEmpty(cache)).isTrue();
}
Aggregations