use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.
the class MappingUtilsTest method testJsonMapping.
@Test
public void testJsonMapping() {
JsonUtils.permissionsAsJson(null);
JsonUtils.customPropertiesAsJson(null);
JsonUtils.customPropertiesAsJson(new HashMap<String, Property<?>>());
FeatureStore store1 = new InMemoryFeatureStore();
FF4jCacheProxy proxy = new FF4jCacheProxy(store1, null, null);
JsonUtils.cacheJson(proxy);
}
use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.
the class FF4j method loadConfiguration.
protected void loadConfiguration(FF4jConfiguration config) {
this.fstore = new InMemoryFeatureStore(config);
this.pStore = new InMemoryPropertyStore(config);
}
use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.
the class CacheProxyWithPollingTest method testCacheProxyManagerPropertyDuringRefresh.
@Test
public void testCacheProxyManagerPropertyDuringRefresh() throws InterruptedException {
FeatureStore fs = new InMemoryFeatureStore("ff4j.xml");
PropertyStore ps = new InMemoryPropertyStore("ff4j.xml");
FF4JCacheManager cm = new InMemoryCacheManager();
final FF4jCacheProxy proxy = new FF4jCacheProxy(fs, ps, cm);
// scheduler refreshing cache through worker thread
Store2CachePollingScheduler store2CachePollingScheduler = new Store2CachePollingScheduler(proxy);
// setting polling delay 10ms
store2CachePollingScheduler.start(10);
// 20 threads trying to fetch property from cacheManager
ExecutorService fetchPropertyService = Executors.newFixedThreadPool(20);
Callable<Property<?>> callable = new Callable<Property<?>>() {
@Override
public Property<?> call() throws Exception {
try {
return proxy.getCacheManager().getProperty("a");
} catch (Exception e) {
throw e;
}
}
};
List<Callable<Property<?>>> multiplePropertyFetchCalls = new ArrayList<Callable<Property<?>>>(1000);
// generating 100000 requests
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 10; j++) {
// clear to avoid accumulation of callables over multiple iterations
multiplePropertyFetchCalls.clear();
}
for (int k = 0; k < 100; k++) {
multiplePropertyFetchCalls.add(callable);
}
// execute 100 property fetch calls on 20 threads
List<Future<Property<?>>> fetchPropertyCalls = fetchPropertyService.invokeAll(multiplePropertyFetchCalls);
// property should never be null
for (Future<Property<?>> property : fetchPropertyCalls) {
Assert.assertNotNull(property);
}
}
}
use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.
the class InMemoryFeatureStoreTest method testUnitFeatureInitialization.
@Test
public void testUnitFeatureInitialization() {
InMemoryFeatureStore imfs = new InMemoryFeatureStore();
imfs.create(new Feature("default", true, "grp1", "desc", null, new PonderationStrategy()));
Assert.assertEquals(1, imfs.readAll().size());
}
use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.
the class InMemoryFeatureStoreTest method testDonotImportEmpty.
@Test(expected = IllegalArgumentException.class)
public void testDonotImportEmpty() {
InMemoryFeatureStore f = new InMemoryFeatureStore();
f.importFeaturesFromXmlFile("");
}
Aggregations