Search in sources :

Example 1 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class InMemoryPropertyStoreTest method testInitStores.

@Test
public void testInitStores() {
    new InMemoryPropertyStore(new HashMap<String, Property<?>>());
    InputStream in = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.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 2 with Property

use of org.ff4j.property.Property 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 3 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class PropertyStoreCassandra method readAllProperties.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Property<?>> readAllProperties() {
    Map<String, Property<?>> properties = new HashMap<String, Property<?>>();
    ResultSet resultSet = conn.getSession().execute(getBuilder().selectAllProperties());
    for (Row row : resultSet.all()) {
        Property<?> p = CassandraMapper.mapProperty(row);
        properties.put(p.getName(), p);
    }
    return properties;
}
Also used : HashMap(java.util.HashMap) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) Property(org.ff4j.property.Property)

Example 4 with Property

use of org.ff4j.property.Property 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 5 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class FF4jConfiguration method getProperties.

/**
 * {@inheritDoc}
 */
@Override
public Properties getProperties(String key) {
    Properties props = new Properties();
    if (key == null)
        return props;
    Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
    for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
        if (prop.getKey().startsWith(key)) {
            props.put(prop.getKey(), prop.getValue().getValue());
        }
    }
    return props;
}
Also used : Properties(java.util.Properties) Property(org.ff4j.property.Property) Map(java.util.Map)

Aggregations

Property (org.ff4j.property.Property)47 Test (org.junit.Test)19 PropertyString (org.ff4j.property.PropertyString)17 HashMap (java.util.HashMap)15 Feature (org.ff4j.core.Feature)12 InputStream (java.io.InputStream)9 Map (java.util.Map)7 XmlParser (org.ff4j.conf.XmlParser)7 LinkedHashMap (java.util.LinkedHashMap)6 XmlConfig (org.ff4j.conf.XmlConfig)6 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 PropertyAccessException (org.ff4j.exception.PropertyAccessException)4 ArrayList (java.util.ArrayList)3 PropertyLogLevel (org.ff4j.property.PropertyLogLevel)3 SearchResult (io.searchbox.core.SearchResult)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2