Search in sources :

Example 1 with InMemoryCacheManager

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

the class FeatureStoreServicesStepDef method the_feature_store_is_cached.

@Given("^the feature store is cached$")
public void the_feature_store_is_cached() throws Throwable {
    FF4jCacheProxy proxy = new FF4jCacheProxy(ff4j.getFeatureStore(), null, new InMemoryCacheManager());
    ff4j.setFeatureStore(proxy);
}
Also used : InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) Given(cucumber.api.java.en.Given)

Example 2 with InMemoryCacheManager

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

the class FF4jTest method getConcreteFeatureStore.

@Test
public void getConcreteFeatureStore() {
    FF4j ff4j = new FF4j();
    ff4j.cache(new InMemoryCacheManager());
    Assert.assertNotNull(ff4j.getCacheProxy());
    Assert.assertNotNull(ff4j.getConcreteFeatureStore());
    Assert.assertNotNull(ff4j.getConcretePropertyStore());
    ff4j.setPropertiesStore(new PropertyStoreAuditProxy(ff4j, ff4j.getPropertiesStore()));
    Assert.assertNotNull(ff4j.getConcretePropertyStore());
}
Also used : PropertyStoreAuditProxy(org.ff4j.audit.proxy.PropertyStoreAuditProxy) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 3 with InMemoryCacheManager

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

the class CacheProxyTest method testCacheProxyManager.

@Test
public void testCacheProxyManager() {
    FF4jCacheProxy proxy = new FF4jCacheProxy();
    FF4JCacheManager cm = new InMemoryCacheManager();
    proxy.setCacheManager(cm);
    proxy.isCached();
    Assert.assertNotNull(proxy.getCacheProvider());
    proxy.setTargetPropertyStore(new InMemoryPropertyStore());
    Assert.assertEquals(0, proxy.readAllProperties().size());
    proxy.createProperty(new PropertyString("p1", "v1"));
    Assert.assertTrue(proxy.existProperty("p1"));
    Assert.assertFalse(proxy.existProperty("p2"));
    proxy.setTargetFeatureStore(new InMemoryFeatureStore());
    Set<Feature> setOfFeatures = new HashSet<Feature>();
    setOfFeatures.add(new Feature("f1"));
    setOfFeatures.add(new Feature("f2"));
    proxy.importFeatures(setOfFeatures);
}
Also used : FF4JCacheManager(org.ff4j.cache.FF4JCacheManager) PropertyString(org.ff4j.property.PropertyString) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) Feature(org.ff4j.core.Feature) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with InMemoryCacheManager

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

the class CacheProxyWithPollingTest method testCacheProxyManagerProperty.

@Test
public void testCacheProxyManagerProperty() throws InterruptedException {
    // When
    FeatureStore fs = new InMemoryFeatureStore("ff4j.xml");
    PropertyStore ps = new InMemoryPropertyStore("ff4j.xml");
    FF4JCacheManager cm = new InMemoryCacheManager();
    FF4jCacheProxy proxy = new FF4jCacheProxy(fs, ps, cm);
    // Start polling on 100ms basis
    proxy.startPolling(100);
    proxy.createSchema();
    Thread.sleep(200);
    // When (Remove something)
    fs.delete("AwesomeFeature");
    // Then (Proxy is not yet refresh)
    Assert.assertTrue(proxy.exist("AwesomeFeature"));
    // When (wait for cache refresh)
    Thread.sleep(200);
    // Then (also delete in cache si Cache is refreshed)
    Assert.assertFalse(proxy.exist("AwesomeFeature"));
    Store2CachePollingScheduler scheduler = proxy.getStore2CachePoller();
    scheduler.setInitialDelay(scheduler.getInitialDelay());
    scheduler.setPollingDelay(scheduler.getPollingDelay());
    proxy.stopPolling();
    proxy.setStore2CachePoller(new Store2CachePollingScheduler(fs, ps, cm));
}
Also used : FF4JCacheManager(org.ff4j.cache.FF4JCacheManager) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FeatureStore(org.ff4j.core.FeatureStore) Store2CachePollingScheduler(org.ff4j.cache.Store2CachePollingScheduler) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) Test(org.junit.Test)

Example 5 with InMemoryCacheManager

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

the class InMemoryCacheTest method testGetProperty4.

@Test(expected = IllegalArgumentException.class)
public void testGetProperty4() {
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    PropertyString p1 = new PropertyString("p1");
    p1.setName("");
    imcm.putProperty(p1, 1);
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) 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