Search in sources :

Example 1 with ValueWrapper

use of cn.taketoday.cache.Cache.ValueWrapper in project today-framework by TAKETODAY.

the class CaffeineCacheTests method testLoadingCacheGetWithType.

@Test
void testLoadingCacheGetWithType() {
    String value = "value";
    CaffeineCache loadingCache = new CaffeineCache(CACHE_NAME, Caffeine.newBuilder().build(key -> value));
    String valueWrapper = loadingCache.get(new Object(), String.class);
    assertThat(valueWrapper).isNotNull();
    assertThat(valueWrapper).isEqualTo(value);
}
Also used : Test(org.junit.jupiter.api.Test) BeforeEach(org.junit.jupiter.api.BeforeEach) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) AbstractValueAdaptingCacheTests(cn.taketoday.contextsupport.testfixture.cache.AbstractValueAdaptingCacheTests) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValueWrapper(cn.taketoday.cache.Cache.ValueWrapper) Cache(cn.taketoday.cache.Cache) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Test(org.junit.jupiter.api.Test)

Example 2 with ValueWrapper

use of cn.taketoday.cache.Cache.ValueWrapper in project today-framework by TAKETODAY.

the class CaffeineCacheTests method testLoadingCacheGet.

@Test
void testLoadingCacheGet() {
    Object value = new Object();
    CaffeineCache loadingCache = new CaffeineCache(CACHE_NAME, Caffeine.newBuilder().build(key -> value));
    ValueWrapper valueWrapper = loadingCache.get(new Object());
    assertThat(valueWrapper).isNotNull();
    assertThat(valueWrapper.get()).isEqualTo(value);
}
Also used : Test(org.junit.jupiter.api.Test) BeforeEach(org.junit.jupiter.api.BeforeEach) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) AbstractValueAdaptingCacheTests(cn.taketoday.contextsupport.testfixture.cache.AbstractValueAdaptingCacheTests) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValueWrapper(cn.taketoday.cache.Cache.ValueWrapper) Cache(cn.taketoday.cache.Cache) ValueWrapper(cn.taketoday.cache.Cache.ValueWrapper) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Test(org.junit.jupiter.api.Test)

Example 3 with ValueWrapper

use of cn.taketoday.cache.Cache.ValueWrapper in project today-infrastructure by TAKETODAY.

the class CaffeineCacheTests method testLoadingCacheGet.

@Test
void testLoadingCacheGet() {
    Object value = new Object();
    CaffeineCache loadingCache = new CaffeineCache(CACHE_NAME, Caffeine.newBuilder().build(key -> value));
    ValueWrapper valueWrapper = loadingCache.get(new Object());
    assertThat(valueWrapper).isNotNull();
    assertThat(valueWrapper.get()).isEqualTo(value);
}
Also used : Test(org.junit.jupiter.api.Test) BeforeEach(org.junit.jupiter.api.BeforeEach) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) AbstractValueAdaptingCacheTests(cn.taketoday.contextsupport.testfixture.cache.AbstractValueAdaptingCacheTests) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValueWrapper(cn.taketoday.cache.Cache.ValueWrapper) Cache(cn.taketoday.cache.Cache) ValueWrapper(cn.taketoday.cache.Cache.ValueWrapper) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Test(org.junit.jupiter.api.Test)

Example 4 with ValueWrapper

use of cn.taketoday.cache.Cache.ValueWrapper in project today-infrastructure by TAKETODAY.

the class CaffeineCacheTests method testLoadingCacheGetWithType.

@Test
void testLoadingCacheGetWithType() {
    String value = "value";
    CaffeineCache loadingCache = new CaffeineCache(CACHE_NAME, Caffeine.newBuilder().build(key -> value));
    String valueWrapper = loadingCache.get(new Object(), String.class);
    assertThat(valueWrapper).isNotNull();
    assertThat(valueWrapper).isEqualTo(value);
}
Also used : Test(org.junit.jupiter.api.Test) BeforeEach(org.junit.jupiter.api.BeforeEach) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) AbstractValueAdaptingCacheTests(cn.taketoday.contextsupport.testfixture.cache.AbstractValueAdaptingCacheTests) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ValueWrapper(cn.taketoday.cache.Cache.ValueWrapper) Cache(cn.taketoday.cache.Cache) CaffeineCache(cn.taketoday.cache.support.CaffeineCache) Test(org.junit.jupiter.api.Test)

Aggregations

Cache (cn.taketoday.cache.Cache)4 ValueWrapper (cn.taketoday.cache.Cache.ValueWrapper)4 CaffeineCache (cn.taketoday.cache.support.CaffeineCache)4 AbstractValueAdaptingCacheTests (cn.taketoday.contextsupport.testfixture.cache.AbstractValueAdaptingCacheTests)4 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Assertions.assertThatIllegalStateException (org.assertj.core.api.Assertions.assertThatIllegalStateException)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Test (org.junit.jupiter.api.Test)4