Search in sources :

Example 6 with InMemoryFeatureStore

use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.

the class RedisCacheManagerTestIT method testPutGet.

@Test
public void testPutGet() {
    // Initializing Features for test
    FeatureStore store = new InMemoryFeatureStore(TEST_FEATURES_FILE);
    Feature fold = store.read(F4);
    // Put in Cache
    cache.putFeature(fold);
    // Retrieve object
    Feature fcached = cache.getFeature(F4);
    Assert.assertEquals(fcached.getUid(), fold.getUid());
    Assert.assertEquals(fcached.getPermissions(), fold.getPermissions());
}
Also used : InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) Feature(org.ff4j.core.Feature) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FeatureStore(org.ff4j.core.FeatureStore) Test(org.junit.Test)

Example 7 with InMemoryFeatureStore

use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.

the class OfficeHourStrategyTest method testOfficeHourEmptyExpression.

@Test
public void testOfficeHourEmptyExpression() {
    OfficeHourStrategy ohs = new OfficeHourStrategy();
    ohs.parseIntervalsExpression(null);
    ohs.parseIntervalsExpression("");
    ohs.matches(Calendar.getInstance(), null);
    ohs.evaluate("f1", new InMemoryFeatureStore(), null);
    ohs.evaluate("f1", new InMemoryFeatureStore(), new FlippingExecutionContext());
}
Also used : InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) OfficeHourStrategy(org.ff4j.strategy.time.OfficeHourStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 8 with InMemoryFeatureStore

use of org.ff4j.store.InMemoryFeatureStore 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 9 with InMemoryFeatureStore

use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.

the class ClientFilterStrategyTest method testInitialisationProgramServer.

@Test
public void testInitialisationProgramServer() {
    FlippingStrategy fs = new ServerFilterStrategy("serv1,serv2");
    fs.init("f1", null);
    fs.init("f1", new HashMap<String, String>());
    FlippingExecutionContext context = new FlippingExecutionContext();
    fs.evaluate("f1", new InMemoryFeatureStore(), context);
}
Also used : ServerFilterStrategy(org.ff4j.strategy.ServerFilterStrategy) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FlippingStrategy(org.ff4j.core.FlippingStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 10 with InMemoryFeatureStore

use of org.ff4j.store.InMemoryFeatureStore in project ff4j by ff4j.

the class FeatureStoreAuditProxyTest method initStore.

/**
 * {@inheritDoc}
 */
@Override
public FeatureStore initStore() {
    FF4j ff4j = new FF4j();
    InMemoryFeatureStore imfs = new InMemoryFeatureStore();
    imfs.setLocation("ff4j.xml");
    ff4j.setFeatureStore(imfs);
    return new FeatureStoreAuditProxy(ff4j, imfs);
}
Also used : FF4j(org.ff4j.FF4j) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FeatureStoreAuditProxy(org.ff4j.audit.proxy.FeatureStoreAuditProxy)

Aggregations

InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)35 Test (org.junit.Test)20 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)16 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)6 Feature (org.ff4j.core.Feature)6 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)5 FF4j (org.ff4j.FF4j)4 FeatureStore (org.ff4j.core.FeatureStore)4 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)3 FlippingExecutionContext (org.ff4j.core.FlippingExecutionContext)3 Property (org.ff4j.property.Property)3 PropertyString (org.ff4j.property.PropertyString)3 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)3 Before (org.junit.Before)3 HashSet (java.util.HashSet)2 Store2CachePollingScheduler (org.ff4j.cache.Store2CachePollingScheduler)2 FlippingStrategy (org.ff4j.core.FlippingStrategy)2 PropertyStore (org.ff4j.property.store.PropertyStore)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 ArrayList (java.util.ArrayList)1