Search in sources :

Example 1 with EvictionType

use of org.infinispan.eviction.EvictionType in project infinispan by infinispan.

the class BaseStoreFunctionalTest method testReloadWithEviction.

public void testReloadWithEviction() {
    int numberOfEntries = 10;
    ConfigurationBuilder cb = getDefaultCacheConfiguration();
    createCacheStoreConfig(cb.persistence(), "testReloadWithEviction", false).memory().size(numberOfEntries / 2).evictionType(EvictionType.COUNT);
    TestingUtil.defineConfiguration(cacheManager, "testReloadWithEviction", cb.build());
    Cache<String, Object> cache = cacheManager.getCache("testReloadWithEviction");
    Map<String, Object> entriesMap = IntStream.range(0, numberOfEntries).boxed().collect(Collectors.toMap(Object::toString, i -> wrap(i.toString(), "Val" + i)));
    cache.putAll(entriesMap);
    assertEquals(numberOfEntries, cache.size());
    entriesMap.forEach((k, v) -> assertEquals(v, cache.get(k)));
    cache.stop();
    cache.start();
    assertEquals(numberOfEntries, cache.size());
    entriesMap.forEach((k, v) -> assertEquals(v, cache.get(k)));
}
Also used : IntStream(java.util.stream.IntStream) SingleCacheManagerTest(org.infinispan.test.SingleCacheManagerTest) InternalCacheEntry(org.infinispan.container.entries.InternalCacheEntry) PersistenceManager(org.infinispan.persistence.manager.PersistenceManager) Person(org.infinispan.test.data.Person) AssertJUnit.assertArrayEquals(org.testng.AssertJUnit.assertArrayEquals) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Date(java.util.Date) Test(org.testng.annotations.Test) Cache(org.infinispan.Cache) AssertJUnit.assertTrue(org.testng.AssertJUnit.assertTrue) EvictionType(org.infinispan.eviction.EvictionType) MediaType(org.infinispan.commons.dataconversion.MediaType) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) Calendar(java.util.Calendar) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) SerializationContextInitializer(org.infinispan.protostream.SerializationContextInitializer) AssertJUnit.assertNull(org.testng.AssertJUnit.assertNull) Map(java.util.Map) MarshallableEntry(org.infinispan.persistence.spi.MarshallableEntry) TestingUtil(org.infinispan.test.TestingUtil) Method(java.lang.reflect.Method) SurvivesRestarts(org.infinispan.factories.annotations.SurvivesRestarts) TestDataSCI(org.infinispan.test.TestDataSCI) StorageType(org.infinispan.configuration.cache.StorageType) DataContainer(org.infinispan.container.DataContainer) TimeZone(java.util.TimeZone) Predicate(java.util.function.Predicate) ByRef(org.infinispan.commons.util.ByRef) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) TransactionMode(org.infinispan.transaction.TransactionMode) AssertJUnit.assertFalse(org.testng.AssertJUnit.assertFalse) CacheSet(org.infinispan.CacheSet) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) Sex(org.infinispan.test.data.Sex) CompletionStage(java.util.concurrent.CompletionStage) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder) CommonsTestingUtil(org.infinispan.commons.test.CommonsTestingUtil) Configuration(org.infinispan.configuration.cache.Configuration) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) AssertJUnit.assertNotNull(org.testng.AssertJUnit.assertNotNull) WaitNonBlockingStore(org.infinispan.persistence.support.WaitNonBlockingStore) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) Address(org.infinispan.test.data.Address) PersistenceException(org.infinispan.persistence.spi.PersistenceException) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) PersistenceConfigurationBuilder(org.infinispan.configuration.cache.PersistenceConfigurationBuilder)

Aggregations

Method (java.lang.reflect.Method)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 Map (java.util.Map)1 TimeZone (java.util.TimeZone)1 CompletionStage (java.util.concurrent.CompletionStage)1 TimeUnit (java.util.concurrent.TimeUnit)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Cache (org.infinispan.Cache)1 CacheSet (org.infinispan.CacheSet)1 MediaType (org.infinispan.commons.dataconversion.MediaType)1 CommonsTestingUtil (org.infinispan.commons.test.CommonsTestingUtil)1 ByRef (org.infinispan.commons.util.ByRef)1 Configuration (org.infinispan.configuration.cache.Configuration)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 PersistenceConfigurationBuilder (org.infinispan.configuration.cache.PersistenceConfigurationBuilder)1 StorageType (org.infinispan.configuration.cache.StorageType)1 StoreConfiguration (org.infinispan.configuration.cache.StoreConfiguration)1