Search in sources :

Example 16 with InMemoryCacheManager

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

the class FeatureStoreStepDef 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 17 with InMemoryCacheManager

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

the class FF4JServicesStepDef 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 18 with InMemoryCacheManager

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

the class PropertyStoreServicesStepDef method the_property_store_is_cached.

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

Example 19 with InMemoryCacheManager

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

the class PropertyStoreStepDef method the_property_store_is_cached.

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

Example 20 with InMemoryCacheManager

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

the class CacheProxyTest method testCacheProxyManagerProperty.

@Test
public void testCacheProxyManagerProperty() {
    FF4jCacheProxy proxy = new FF4jCacheProxy();
    proxy.setTargetPropertyStore(new InMemoryPropertyStore());
    proxy.setTargetFeatureStore(new InMemoryFeatureStore());
    proxy.setCacheManager(new InMemoryCacheManager());
    Assert.assertTrue(proxy.isEmpty());
    proxy.create(new Feature("a"));
    Assert.assertFalse(proxy.isEmpty());
    proxy.createProperty(new PropertyString("p1", "v1"));
    Property<?> p1 = proxy.readProperty("p1");
    proxy.readProperty("p1");
    proxy.getTargetPropertyStore().createProperty(new PropertyString("p2"));
    proxy.readProperty("p2");
    proxy.updateProperty("p1", "v2");
    proxy.updateProperty(p1);
    Assert.assertFalse(proxy.isEmpty());
    Assert.assertFalse(proxy.listPropertyNames().isEmpty());
    proxy.deleteProperty("p1");
    proxy.clear();
    Set<Property<?>> setOfProperty = new HashSet<Property<?>>();
    setOfProperty.add(new PropertyLogLevel("a", LogLevel.INFO));
    setOfProperty.add(new PropertyLogLevel("titi1", LogLevel.INFO));
    proxy.importProperties(setOfProperty);
    // Already in cache, but not same value
    proxy.createProperty(new PropertyString("cacheNStore", "cacheNStore"));
    proxy.readProperty("cacheNStore", p1);
    // Not in cache, but in store, but not same default value
    proxy.getTargetPropertyStore().createProperty(new PropertyString("p4", "v4"));
    proxy.readProperty("p1", p1);
    proxy.readProperty("p1", p1);
    // Nowhere, return default
    proxy.readProperty("p2", new PropertyString("p2"));
    proxy.readProperty("p1", new PropertyString("p3"));
}
Also used : PropertyLogLevel(org.ff4j.property.PropertyLogLevel) 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) Property(org.ff4j.property.Property) HashSet(java.util.HashSet) 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