Search in sources :

Example 56 with Cache

use of org.cache2k.Cache in project cache2k by cache2k.

the class IntegrationTest method notPresent.

@Test
public void notPresent() {
    Cache c = new Cache2kBuilder<String, String>() {
    }.manager(CacheManager.getInstance("notPresent")).name("anyCache").build();
    c.close();
}
Also used : Cache(org.cache2k.Cache) Test(org.junit.Test)

Example 57 with Cache

use of org.cache2k.Cache in project cache2k by cache2k.

the class IntegrationTest method defaultManagerName.

/**
 * The name of the default manager is set by the configuration.
 */
@Test
@Ignore
public void defaultManagerName() {
    Cache c = Cache2kBuilder.forUnknownTypes().name("flowers").build();
    assertTrue("default manager", c.getCacheManager().isDefaultManager());
    assertEquals("myApp", c.getCacheManager().getName());
    c.close();
}
Also used : Cache(org.cache2k.Cache) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 58 with Cache

use of org.cache2k.Cache in project cache2k by cache2k.

the class IntegrationTest method eternal_configExpire.

@Test
public void eternal_configExpire() {
    try {
        Cache c = new Cache2kBuilder<String, String>() {
        }.manager(CacheManager.getInstance("specialCases")).name("withExpiry").eternal(true).build();
        c.close();
        fail("expect exception");
    } catch (ConfigurationException ex) {
        assertThat(ex.getMessage(), containsString("Value '2d' rejected: eternal enabled explicitly, refusing to enable expiry at"));
    }
}
Also used : Cache2kBuilder(org.cache2k.Cache2kBuilder) Cache(org.cache2k.Cache) Test(org.junit.Test)

Example 59 with Cache

use of org.cache2k.Cache in project cache2k by cache2k.

the class IntegrationTest method ignoreAnonymousCache.

@Test
public void ignoreAnonymousCache() {
    Cache c = new Cache2kBuilder<String, String>() {
    }.manager(CacheManager.getInstance("specialCases")).build();
    c.close();
}
Also used : Cache2kBuilder(org.cache2k.Cache2kBuilder) Cache(org.cache2k.Cache) Test(org.junit.Test)

Example 60 with Cache

use of org.cache2k.Cache in project cache2k by cache2k.

the class ManagerMXBeanImpl method getHealthStatus.

@Override
public String getHealthStatus() {
    List<HealthInfoElement> li = new ArrayList<HealthInfoElement>();
    for (Cache c : manager.getActiveCaches()) {
        InternalCache ic = (InternalCache) c;
        li.addAll(ic.getInfo().getHealth());
    }
    sortHealthInfoList(li);
    return constructHealthString(li);
}
Also used : ArrayList(java.util.ArrayList) InternalCache(org.cache2k.core.InternalCache) HealthInfoElement(org.cache2k.core.HealthInfoElement) Cache(org.cache2k.Cache) InternalCache(org.cache2k.core.InternalCache)

Aggregations

Cache (org.cache2k.Cache)60 Test (org.junit.Test)49 CacheManager (org.cache2k.CacheManager)11 Cache2kBuilder (org.cache2k.Cache2kBuilder)9 CacheEntry (org.cache2k.CacheEntry)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 ExceptionWrapper (org.cache2k.core.ExceptionWrapper)8 InternalCache (org.cache2k.core.InternalCache)8 CacheRule (org.cache2k.test.util.CacheRule)6 Condition (org.cache2k.test.util.Condition)6 IntCacheRule (org.cache2k.test.util.IntCacheRule)5 CountDownLatch (java.util.concurrent.CountDownLatch)3 MBeanInfo (javax.management.MBeanInfo)3 Log (org.cache2k.core.util.Log)3 CacheEntryCreatedListener (org.cache2k.event.CacheEntryCreatedListener)3 CacheEntryUpdatedListener (org.cache2k.event.CacheEntryUpdatedListener)3 ArrayList (java.util.ArrayList)2 CacheLoaderException (org.cache2k.integration.CacheLoaderException)2 Collection (java.util.Collection)1 Date (java.util.Date)1