use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method duplicateCacheName.
@Test
public void duplicateCacheName() {
String _managerName = getClass().getName() + ".duplicateCacheName";
Log.registerSuppression(CacheManager.class.getName() + ":" + _managerName, new Log.SuppressionCounter());
CacheManager mgr = CacheManager.getInstance(_managerName);
try {
Cache c0 = Cache2kBuilder.forUnknownTypes().manager(mgr).eternal(true).name(this.getClass(), "same").build();
Cache c1 = Cache2kBuilder.forUnknownTypes().manager(mgr).eternal(true).name(this.getClass(), "same").build();
fail("exception expected");
} catch (IllegalStateException ex) {
}
mgr.close();
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method noTypes.
@Test
public void noTypes() {
Cache c = Cache2kBuilder.forUnknownTypes().eternal(true).build();
c.put("hallo", 234);
c.close();
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method autoGeneratedCacheName.
@Test
public void autoGeneratedCacheName() {
Cache c1 = Cache2kBuilder.forUnknownTypes().eternal(true).build();
assertTrue(c1.getName().startsWith("_org.cache2k"));
Cache c2 = Cache2kBuilder.forUnknownTypes().eternal(true).build();
assertTrue(c1 != c2);
c1.close();
c2.close();
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method cacheNameInConstructor2.
@Test
public void cacheNameInConstructor2() {
Cache c = new BuildCacheInConstructor2().cache;
assertThat(c.getName(), startsWith("_" + CLASSNAME + "$BuildCacheInConstructor2.INIT"));
c.close();
}
use of org.cache2k.Cache in project cache2k by cache2k.
the class Cache2kBuilderTest method managerName.
@Test
public void managerName() {
Cache c = Cache2kBuilder.forUnknownTypes().eternal(true).build();
assertEquals("default", c.getCacheManager().getName());
c.close();
}
Aggregations