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 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 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();
}
use of cn.taketoday.cache.Cache in project today-infrastructure by TAKETODAY.
the class AbstractJCacheAnnotationTests method putWithException.
@Test
public void putWithException() {
Cache cache = getCache(DEFAULT_CACHE);
Object key = createKey(this.keyItem);
Object value = new Object();
assertThat(cache.get(key)).isNull();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> service.putWithException(this.keyItem, value, true));
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 cacheException.
@Test
public void cacheException() {
Cache cache = getCache(EXCEPTION_CACHE);
Object key = createKey(this.keyItem);
assertThat(cache.get(key)).isNull();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> service.cacheWithException(this.keyItem, true));
Cache.ValueWrapper result = cache.get(key);
assertThat(result).isNotNull();
assertThat(result.get().getClass()).isEqualTo(UnsupportedOperationException.class);
}
Aggregations