Search in sources :

Example 26 with InMemoryFeatureStore

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

the class InMemoryFeatureStoreTest method testUnitFeatureInitialization2.

@Test
public void testUnitFeatureInitialization2() {
    LinkedHashMap<String, Feature> map1 = new LinkedHashMap<String, Feature>();
    map1.put("new", new Feature("new", true, "description"));
    map1.put("old", new Feature("old", true, "description"));
    InMemoryFeatureStore imfs = new InMemoryFeatureStore(map1);
    Assert.assertEquals(2, imfs.readAll().size());
    Assert.assertNotNull(imfs.read("old"));
}
Also used : InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) Feature(org.ff4j.core.Feature) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 27 with InMemoryFeatureStore

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

the class InMemoryFeatureStoreTest method testDonotImportInvalid.

@Test(expected = IllegalArgumentException.class)
public void testDonotImportInvalid() {
    InMemoryFeatureStore f = new InMemoryFeatureStore();
    f.importFeaturesFromXmlFile("invalid.xml");
}
Also used : InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) Test(org.junit.Test)

Example 28 with InMemoryFeatureStore

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

the class InMemoryFeatureStoreTest method testImportTwice.

@Test
public void testImportTwice() {
    InMemoryFeatureStore f = new InMemoryFeatureStore();
    f.importFeaturesFromXmlFile("ff4j.xml");
    f.importFeaturesFromXmlFile("ff4j.xml");
    Assert.assertFalse(f.readAll().isEmpty());
}
Also used : InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) Test(org.junit.Test)

Example 29 with InMemoryFeatureStore

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

the class InMemoryFeatureStoreTest method testDonotImportNull.

@Test(expected = IllegalArgumentException.class)
public void testDonotImportNull() {
    InMemoryFeatureStore f = new InMemoryFeatureStore();
    f.importFeaturesFromXmlFile(null);
}
Also used : InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) Test(org.junit.Test)

Example 30 with InMemoryFeatureStore

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

the class ClientFilterStrategyTest method testInitialisationProgram.

@Test
public void testInitialisationProgram() {
    FlippingStrategy fs = new ClientFilterStrategy("Pierre, Paul, Jacques");
    fs.init("f1", null);
    fs.init("f1", new HashMap<String, String>());
    new WhiteListStrategy();
    new WhiteListStrategy("Pierre");
    // Working
    new BlackListStrategy();
    FlippingStrategy bl2 = new BlackListStrategy("Pierre");
    FlippingExecutionContext context = new FlippingExecutionContext();
    context.putString("clientHostName", "localhost");
    Assert.assertTrue(bl2.evaluate("f1", new InMemoryFeatureStore(), context));
    context.putString("clientHostName", "Pierre");
    Assert.assertFalse(bl2.evaluate("f1", new InMemoryFeatureStore(), context));
}
Also used : ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) BlackListStrategy(org.ff4j.strategy.BlackListStrategy) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FlippingStrategy(org.ff4j.core.FlippingStrategy) WhiteListStrategy(org.ff4j.strategy.WhiteListStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

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