Search in sources :

Example 1 with FeatureStore

use of org.ff4j.core.FeatureStore in project ff4j by ff4j.

the class FeatureStoreHttpSpringTest method initStore.

/**
 * {@inheritDoc}
 */
protected FeatureStore initStore() {
    ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext("spring-context.xml");
    FeatureStore store = appCtx.getBean(FF4j.class).getFeatureStore();
    appCtx.close();
    return store;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) FF4j(org.ff4j.FF4j) FeatureStore(org.ff4j.core.FeatureStore)

Example 2 with FeatureStore

use of org.ff4j.core.FeatureStore in project ff4j by ff4j.

the class FeatureStoreMongoCollectionCore1Test method emptyListAttributes.

/**
 * LazyBSONObjectList vs BasicBSONObjectList
 */
@Test
@Ignore
public void emptyListAttributes() throws UnknownHostException {
    MongoCollection<Document> features = getMongoClient().getDatabase("FF4J").getCollection("feature");
    // When
    FeatureStore mongoStore = new FeatureStoreMongo(features, "ff4j.xml");
    // Then (no error)
    Assert.assertTrue(mongoStore.readAll().keySet().size() > 0);
}
Also used : FeatureStoreMongo(org.ff4j.mongo.store.FeatureStoreMongo) Document(org.bson.Document) FeatureStore(org.ff4j.core.FeatureStore) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with FeatureStore

use of org.ff4j.core.FeatureStore in project ff4j by ff4j.

the class CoreFeatureStoreTestSupport method setUp.

/**
 * {@inheritDoc}
 */
@Before
public void setUp() throws Exception {
    ff4j = new FF4j();
    FeatureStore fs = initStore();
    ff4j.setFeatureStore(fs);
    testedStore = fs;
    assertFf4j = new AssertFf4j(ff4j);
}
Also used : AssertFf4j(org.ff4j.test.AssertFf4j) FF4j(org.ff4j.FF4j) TestConstantsFF4j(org.ff4j.test.TestConstantsFF4j) FeatureStore(org.ff4j.core.FeatureStore) Before(org.junit.Before)

Example 4 with FeatureStore

use of org.ff4j.core.FeatureStore 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 5 with FeatureStore

use of org.ff4j.core.FeatureStore in project ff4j by ff4j.

the class FeatureJsonMarshallTest method testJsonUtils.

@Test
public void testJsonUtils() {
    FlippingStrategy ps = new FlippingStrategy() {

        public void init(String featureName, Map<String, String> initParam) {
        }

        public Map<String, String> getInitParams() {
            return null;
        }

        public boolean evaluate(String fn, FeatureStore s, FlippingExecutionContext ex) {
            return false;
        }
    };
    JsonUtils.flippingStrategyAsJson(ps);
}
Also used : FlippingStrategy(org.ff4j.core.FlippingStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Map(java.util.Map) FeatureStore(org.ff4j.core.FeatureStore) Test(org.junit.Test)

Aggregations

FeatureStore (org.ff4j.core.FeatureStore)11 Test (org.junit.Test)7 FF4j (org.ff4j.FF4j)3 PropertyStore (org.ff4j.property.store.PropertyStore)3 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)3 Map (java.util.Map)2 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)2 Feature (org.ff4j.core.Feature)2 Property (org.ff4j.property.Property)2 PropertyString (org.ff4j.property.PropertyString)2 Ignore (org.junit.Ignore)2 DBCollection (com.mongodb.DBCollection)1 HashMap (java.util.HashMap)1 Document (org.bson.Document)1 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)1 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)1 Store2CachePollingScheduler (org.ff4j.cache.Store2CachePollingScheduler)1 XmlConfig (org.ff4j.conf.XmlConfig)1 XmlParser (org.ff4j.conf.XmlParser)1 FlippingExecutionContext (org.ff4j.core.FlippingExecutionContext)1