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);
}
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();
}
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);
}
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"));
}
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);
}
Aggregations