Search in sources :

Example 6 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class InMemoryPropertyStoreTest method testInvalidXML.

@Test(expected = IllegalArgumentException.class)
public void testInvalidXML() {
    new InMemoryPropertyStore(new HashMap<String, Property<?>>());
    InputStream in = getClass().getClassLoader().getResourceAsStream("invalid.xml");
    new InMemoryPropertyStore(in);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InputStream(java.io.InputStream) PropertyString(org.ff4j.property.PropertyString) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 7 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class InMemoryPropertyStoreTest method testInheritMethods.

@Test
public void testInheritMethods() {
    InMemoryPropertyStore ip = new InMemoryPropertyStore();
    ip.importPropertiesFromXmlFile("test-ff4j-features.xml");
    Assert.assertNotNull(ip.toJson());
    ip.isEmpty();
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) Test(org.junit.Test)

Example 8 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class FF4jConfiguration method subset.

/**
 * {@inheritDoc}
 */
@Override
public Configuration subset(String prefix) {
    Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
    PropertyStore ps = new InMemoryPropertyStore();
    for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
        if (prop.getKey().startsWith(prefix)) {
            ps.createProperty(prop.getValue());
        }
    }
    return new FF4jConfiguration(ps);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) Property(org.ff4j.property.Property) Map(java.util.Map) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore)

Example 9 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class PropertyStoreArchaiusCommonsConfTest method testInitPropertyStore2.

/**
 * {@inheritDoc}
 */
@Test
public void testInitPropertyStore2() {
    PropertyStore sourceStore = new InMemoryPropertyStore("ff4j-properties.xml");
    PropertyStore archaiusStore = new PropertyStoreArchaius(sourceStore);
    Assert.assertTrue(archaiusStore.existProperty("a"));
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) Test(org.junit.Test)

Example 10 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class PropertyStoreAsArchaiusInputTest method initArchauisWithFF4j.

@BeforeClass
public static void initArchauisWithFF4j() throws InterruptedException {
    // Sample FF4J Store
    PropertyStore ff4jStore = new InMemoryPropertyStore("ff4j-properties.xml");
    // FF4Store as polling Source for Archiaus
    PolledConfigurationSource ff4jSource = new FF4jPolledConfigurationSource(ff4jStore);
    // Working Thread (polling from ff4j => Archaius)
    AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 100, true);
    // Define configuration with polling and source
    DynamicConfiguration configuration = new DynamicConfiguration(ff4jSource, scheduler);
    // Init configuration
    ConfigurationManager.install(configuration);
    // Other initialization mechanism
    FF4jPolledConfigurationSource conf2 = new FF4jPolledConfigurationSource();
    conf2.setFf4jStore(ff4jStore);
    // Must invoke poll
    Thread.sleep(100);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) DynamicConfiguration(com.netflix.config.DynamicConfiguration) AbstractPollingScheduler(com.netflix.config.AbstractPollingScheduler) FixedDelayPollingScheduler(com.netflix.config.FixedDelayPollingScheduler) PolledConfigurationSource(com.netflix.config.PolledConfigurationSource) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) BeforeClass(org.junit.BeforeClass)

Aggregations

InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)41 Test (org.junit.Test)28 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)10 PropertyString (org.ff4j.property.PropertyString)8 Property (org.ff4j.property.Property)6 PropertyStore (org.ff4j.property.store.PropertyStore)6 InputStream (java.io.InputStream)4 Before (org.junit.Before)4 FF4j (org.ff4j.FF4j)3 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)3 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)3 AbstractPollingScheduler (com.netflix.config.AbstractPollingScheduler)2 DynamicConfiguration (com.netflix.config.DynamicConfiguration)2 FixedDelayPollingScheduler (com.netflix.config.FixedDelayPollingScheduler)2 PolledConfigurationSource (com.netflix.config.PolledConfigurationSource)2 HashSet (java.util.HashSet)2 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)2 Feature (org.ff4j.core.Feature)2 BeforeClass (org.junit.BeforeClass)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1