Search in sources :

Example 11 with InMemoryCacheManager

use of org.ff4j.cache.InMemoryCacheManager in project ff4j by ff4j.

the class InMemoryCacheTest method testGetProperty.

@Test
public void testGetProperty() throws InterruptedException {
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    imcm.putProperty(new PropertyString("p1"));
    Assert.assertNull(imcm.getProperty("p2"));
    Assert.assertNotNull(imcm.getProperty("p1"));
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 12 with InMemoryCacheManager

use of org.ff4j.cache.InMemoryCacheManager in project ff4j by ff4j.

the class InMemoryCacheTest method testEvictProperty1.

@Test
public void testEvictProperty1() {
    // Given
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    imcm.putProperty(new PropertyString("p1"));
    Assert.assertFalse(imcm.listCachedPropertyNames().isEmpty());
    // When
    imcm.evictProperty("p1");
    // Then
    Assert.assertTrue(imcm.listCachedPropertyNames().isEmpty());
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 13 with InMemoryCacheManager

use of org.ff4j.cache.InMemoryCacheManager in project ff4j by ff4j.

the class InMemoryCacheTest method testPutEmptyPropertyName.

@Test(expected = IllegalArgumentException.class)
public void testPutEmptyPropertyName() {
    PropertyString p = new PropertyString();
    p.setName("");
    new InMemoryCacheManager().putProperty(p);
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 14 with InMemoryCacheManager

use of org.ff4j.cache.InMemoryCacheManager in project ff4j by ff4j.

the class InMemoryCacheTest method testEvictProperty2.

@Test
public void testEvictProperty2() {
    // Given
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    imcm.putProperty(new PropertyString("p2"));
    Assert.assertFalse(imcm.listCachedPropertyNames().isEmpty());
    // When
    imcm.evictProperty("p1");
    // Then
    Assert.assertFalse(imcm.listCachedPropertyNames().isEmpty());
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 15 with InMemoryCacheManager

use of org.ff4j.cache.InMemoryCacheManager in project ff4j by ff4j.

the class AbstractCacheManagerTest method testAbstractCacheManagerForCoverage.

@Test
public void testAbstractCacheManagerForCoverage() {
    AbstractCacheManagerJUnitTest ac = new AbstractCacheManagerJUnitTest() {

        protected FF4JCacheManager getCacheManager() {
            if (cacheManager == null) {
                cacheManager = new InMemoryCacheManager();
            }
            return cacheManager;
        }
    };
    ac.initialize();
    ac.testClear();
    ac.testPutOK();
    ac.clean();
    ac.testPutSeveral();
    ac.testEvictOK();
    ac.clean();
    ac.testPutAvoidDoublon();
    ac.clean();
    ac.testEvictFeatureNotExist();
    ac.clean();
    Assert.assertNotNull(ac);
}
Also used : AbstractCacheManagerJUnitTest(org.ff4j.test.cache.AbstractCacheManagerJUnitTest) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) AbstractCacheManagerJUnitTest(org.ff4j.test.cache.AbstractCacheManagerJUnitTest) Test(org.junit.Test)

Aggregations

InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)29 Test (org.junit.Test)24 PropertyString (org.ff4j.property.PropertyString)11 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)9 Feature (org.ff4j.core.Feature)7 Given (cucumber.api.java.en.Given)5 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)4 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)3 HashSet (java.util.HashSet)2 FF4j (org.ff4j.FF4j)2 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)2 PropertyStoreAuditProxy (org.ff4j.audit.proxy.PropertyStoreAuditProxy)1 Store2CachePollingScheduler (org.ff4j.cache.Store2CachePollingScheduler)1 FeatureStore (org.ff4j.core.FeatureStore)1 Property (org.ff4j.property.Property)1 PropertyLogLevel (org.ff4j.property.PropertyLogLevel)1 PropertyStore (org.ff4j.property.store.PropertyStore)1 AbstractCacheManagerJUnitTest (org.ff4j.test.cache.AbstractCacheManagerJUnitTest)1