use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class AbstractFeatureStore method importFeaturesFromXmlFile.
/**
* Initialize store from XML Configuration File.
*
* @param xmlConfFile
* xml configuration file
*/
public Map<String, Feature> importFeaturesFromXmlFile(String xmlConfFile) {
// Argument validation
if (xmlConfFile == null || xmlConfFile.isEmpty()) {
throw new IllegalArgumentException("Configuration filename cannot be null nor empty");
}
// Load as Inputstream
InputStream xmlIS = getClass().getClassLoader().getResourceAsStream(xmlConfFile);
if (xmlIS == null) {
throw new IllegalArgumentException("File " + xmlConfFile + " could not be read, please check path and rights");
}
// Use the Feature Parser
XmlConfig conf = new XmlParser().parseConfigurationFile(xmlIS);
Map<String, Feature> features = conf.getFeatures();
importFeatures(features.values());
return features;
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class FF4jTest method autoCreateFeatureEnableTest.
@Test
public void autoCreateFeatureEnableTest() {
// Default : store = inMemory, load features from ff4j.xml file
FF4j ff4j = new FF4j(new XmlParser(), "ff4j.xml");
ff4j.autoCreate();
assertFalse(ff4j.exist("autoCreatedFeature"));
// Auto creation by testing its value
assertFalse(ff4j.check("autoCreatedFeature"));
// Assertion
assertTrue(ff4j.exist("autoCreatedFeature"));
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class FF4jTest method testToString.
@Test
public void testToString() {
FF4j ff4j = new FF4j(new XmlParser(), "ff4j.xml");
ff4j.toString();
Assert.assertNotNull(ff4j.getFeatureStore());
ff4j.setFeatureStore(null);
ff4j.setPropertiesStore(null);
ff4j.setEventRepository(null);
ff4j.setEventPublisher(null);
ff4j.setAuthorizationsManager(new DefinedPermissionSecurityManager(Util.set("val1")));
ff4j.toString();
ff4j.removeCurrentContext();
ff4j.getCurrentContext();
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class FF4jTest method testGetFeatures.
@Test
public void testGetFeatures() {
FF4j ff4j = new FF4j(new XmlParser(), "ff4j.xml");
Assert.assertEquals(5, ff4j.getFeatures().size());
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class FF4jTest method testDeleteFeature.
@Test
public void testDeleteFeature() {
FF4j ff4j = new FF4j(new XmlParser(), "ff4j.xml");
ff4j.audit();
Assert.assertTrue(ff4j.exist(F1));
ff4j.delete(F1);
Assert.assertFalse(ff4j.exist(F1));
}
Aggregations