use of org.cache2k.Cache2kBuilder in project cache2k by cache2k.
the class CacheManagerTest method create_config_cache2k_types.
@Test
@Ignore("not yet")
public void create_config_cache2k_types() {
CachingProvider p = Caching.getCachingProvider();
CacheManager cm = p.getCacheManager();
ExtendedMutableConfiguration<String, BigDecimal> mc = new ExtendedMutableConfiguration<String, BigDecimal>();
mc.setCache2kConfiguration(new Cache2kBuilder<String, BigDecimal>() {
}.toConfiguration());
Cache<String, BigDecimal> c = cm.createCache("aCache", mc);
assertEquals("aCache", c.getName());
assertEquals(String.class, c.getConfiguration(Configuration.class).getKeyType());
assertEquals(BigDecimal.class, c.getConfiguration(Configuration.class).getValueType());
c.close();
}
use of org.cache2k.Cache2kBuilder in project cache2k by cache2k.
the class CacheManagerTest method create_cache2k_config_nowrap.
@Test
public void create_cache2k_config_nowrap() {
CachingProvider p = Caching.getCachingProvider();
CacheManager cm = p.getCacheManager();
Cache<Long, Double> cache = cm.createCache("aCache", ExtendedMutableConfiguration.of(new Cache2kBuilder<Long, Double>() {
}.entryCapacity(10000).expireAfterWrite(5, TimeUnit.MINUTES)));
assertFalse(cache instanceof CopyCacheProxy);
cache.close();
}
use of org.cache2k.Cache2kBuilder in project cache2k by cache2k.
the class OsgiIT method testEventPackage.
/**
* Simple test to see whether event package is exported.
*/
@Test
public void testEventPackage() {
CacheManager m = CacheManager.getInstance("testEventPackage");
final AtomicInteger _count = new AtomicInteger();
Cache<String, String> c = new Cache2kBuilder<String, String>() {
}.manager(m).eternal(true).addListener(new CacheEntryCreatedListener<String, String>() {
@Override
public void onEntryCreated(final Cache<String, String> cache, final CacheEntry<String, String> entry) {
_count.incrementAndGet();
}
}).build();
c.put("abc", "123");
assertTrue(c.containsKey("abc"));
assertEquals("123", c.peek("abc"));
assertEquals(1, _count.get());
c.close();
}
use of org.cache2k.Cache2kBuilder in project cache2k by cache2k.
the class CacheManagerTest method create_cache2k_config_wrap.
@Test
public void create_cache2k_config_wrap() {
CachingProvider p = Caching.getCachingProvider();
CacheManager cm = p.getCacheManager();
Cache<Long, Double> cache = cm.createCache("aCache", ExtendedMutableConfiguration.of(new Cache2kBuilder<Long, Double>() {
}.entryCapacity(10000).expireAfterWrite(5, TimeUnit.MINUTES).with(new JCacheConfiguration.Builder().copyAlwaysIfRequested(true))));
assertTrue(cache instanceof CopyCacheProxy);
cache.close();
}
use of org.cache2k.Cache2kBuilder in project cache2k by cache2k.
the class JmxSupportTest method testDisabled.
@Test
public void testDisabled() throws Exception {
String _name = getClass().getName() + ".testInitialProperties";
Cache c = new Cache2kBuilder<Long, List<Collection<Long>>>() {
}.name(_name).disableStatistics(true).eternal(true).build();
objectName = constructCacheObjectName(_name);
try {
retrieve("Alert");
fail("exception expected");
} catch (InstanceNotFoundException ex) {
}
c.close();
}
Aggregations