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);
}
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());
}
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);
}
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));
}
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);
}
Aggregations