use of org.ff4j.cache.FF4jCacheProxy 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);
}
use of org.ff4j.cache.FF4jCacheProxy in project ff4j by ff4j.
the class CacheProxyTest method testCacheProxyNullTriggerException.
@Test(expected = IllegalArgumentException.class)
public void testCacheProxyNullTriggerException() {
FF4jCacheProxy proxy = new FF4jCacheProxy();
proxy.getTargetFeatureStore();
}
use of org.ff4j.cache.FF4jCacheProxy 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"));
}
use of org.ff4j.cache.FF4jCacheProxy in project ff4j by ff4j.
the class CacheProxyWithPollingTest method testStartCacheProxy.
@Test(expected = IllegalStateException.class)
public void testStartCacheProxy() {
FF4jCacheProxy proxy = new FF4jCacheProxy();
proxy.startPolling(100);
}
use of org.ff4j.cache.FF4jCacheProxy in project ff4j by ff4j.
the class JsonUtils method cacheJson.
/**
* Cache JSON expression for a store.
*
* @param store
* current store
* @return
* cache expression
*/
public static final String cacheJson(Object store) {
StringBuilder sb = new StringBuilder();
if (store instanceof FF4jCacheProxy) {
FF4jCacheProxy cacheProxy = (FF4jCacheProxy) store;
sb.append(",\"cached\":true");
sb.append(",\"cacheProvider\":\"" + cacheProxy.getCacheProvider() + "\"");
sb.append(",\"cacheStore\":\"" + cacheProxy.getCachedTargetStore() + "\"");
} else {
sb.append(",\"cached\":false");
}
return sb.toString();
}
Aggregations