Files
java-tutorials/libraries/src/test/java/com/baeldung/jcache/JCacheIntegrationTest.java
T

27 lines
895 B
Java
Raw Normal View History

2017-09-09 21:37:26 +02:00
package com.baeldung.jcache;
2017-09-14 11:02:05 +03:00
import org.junit.Test;
2017-09-09 21:37:26 +02:00
import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.cache.configuration.MutableConfiguration;
import javax.cache.spi.CachingProvider;
2017-09-14 11:02:05 +03:00
import static org.junit.Assert.assertEquals;
2017-09-09 21:37:26 +02:00
2018-03-04 17:39:09 +02:00
public class JCacheIntegrationTest {
2017-09-09 21:37:26 +02:00
@Test
public void instantiateCache() {
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<String, String> config = new MutableConfiguration<>();
Cache<String, String> cache = cacheManager.createCache("simpleCache", config);
cache.put("key1", "value1");
cache.put("key2", "value2");
assertEquals("value1", cache.get("key1"));
assertEquals("value2", cache.get("key2"));
cacheManager.close();
}
2017-09-23 11:42:36 +02:00
}