Search in sources :

Example 36 with XmlParser

use of org.ff4j.conf.XmlParser in project ff4j by ff4j.

the class FF4j_autocreate_multithreaded_Test method initFF4j.

@Override
public FF4j initFF4j() {
    FF4j ff4j = new FF4j(new XmlParser(), "ff4j.xml");
    ff4j.setFeatureStore(new DelayingFeatureStore("ff4j.xml"));
    return ff4j;
}
Also used : XmlParser(org.ff4j.conf.XmlParser) FF4j(org.ff4j.FF4j)

Example 37 with XmlParser

use of org.ff4j.conf.XmlParser in project ff4j by ff4j.

the class FF4jTest method testDisableWithAudit.

@Test
public void testDisableWithAudit() {
    // Given
    FF4j ff4j = new FF4j(new XmlParser(), getClass().getClassLoader().getResourceAsStream("ff4j.xml"));
    ff4j.audit();
    Assert.assertTrue(ff4j.exist(F1));
    Assert.assertTrue(ff4j.getFeature(F1).isEnable());
    // When
    ff4j.disable(F1);
    // Then
    Assert.assertFalse(ff4j.getFeature(F1).isEnable());
}
Also used : XmlParser(org.ff4j.conf.XmlParser) FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 38 with XmlParser

use of org.ff4j.conf.XmlParser in project ff4j by ff4j.

the class GenerationUtilTest method generationSource.

@Test
public void generationSource() throws IOException {
    // Given
    FF4j ff4j = new FF4j(new XmlParser(), "ff4j.xml");
    Assert.assertNotNull(ff4j.getFeatureStore());
    Assert.assertNotNull(ff4j.getPropertiesStore());
    // When
    String data = GeneratorUtils.generateInterfaceConstantsSource(ff4j);
    // Then
    Assert.assertTrue(data.contains("FEATURE"));
    Assert.assertTrue(data.contains("interface"));
    Assert.assertNotNull(GeneratorUtils.exportInterfaceConstants(ff4j));
    GeneratorUtils.generateInterfaceConstantFile(ff4j, new File("./target"));
}
Also used : XmlParser(org.ff4j.conf.XmlParser) FF4j(org.ff4j.FF4j) File(java.io.File) Test(org.junit.Test)

Example 39 with XmlParser

use of org.ff4j.conf.XmlParser in project ff4j by ff4j.

the class InMemoryPropertyStoreTest method testProperty.

public void testProperty() {
    FF4j ff4j = new FF4j(new XmlParser(), "ff4j.xml");
    ff4j.getPropertiesStore().createProperty(new PropertyDate("property_3", new Date()));
    Property<?> ap = ff4j.getPropertiesStore().readProperty("property_3");
    PropertyDate pDate = (PropertyDate) ap;
    pDate.setValue(new Date());
    ff4j.getPropertiesStore().updateProperty(pDate);
    ff4j.getPropertiesStore().deleteProperty("property_3");
    Assert.assertFalse(testedStore.existProperty("property_3"));
}
Also used : XmlParser(org.ff4j.conf.XmlParser) FF4j(org.ff4j.FF4j) Date(java.util.Date) PropertyDate(org.ff4j.property.PropertyDate) PropertyDate(org.ff4j.property.PropertyDate)

Example 40 with XmlParser

use of org.ff4j.conf.XmlParser in project ff4j by ff4j.

the class FeatureXmlParserTest method testParsingProperties.

@Test
public void testParsingProperties() throws IOException {
    // Given
    XmlParser parser = new XmlParser();
    InputStream in = getClass().getClassLoader().getResourceAsStream("ff4j-parser-properties.xml");
    // When
    XmlConfig conf = parser.parseConfigurationFile(in);
    // Then
    Map<String, Feature> features = conf.getFeatures();
    Assert.assertNotNull(features);
    // Then
    Map<String, Property<?>> properties = conf.getProperties();
    Assert.assertNotNull(properties);
}
Also used : XmlParser(org.ff4j.conf.XmlParser) XmlConfig(org.ff4j.conf.XmlConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Feature(org.ff4j.core.Feature) Property(org.ff4j.property.Property) Test(org.junit.Test)

Aggregations

XmlParser (org.ff4j.conf.XmlParser)44 Test (org.junit.Test)29 InputStream (java.io.InputStream)22 FF4j (org.ff4j.FF4j)17 XmlConfig (org.ff4j.conf.XmlConfig)14 Feature (org.ff4j.core.Feature)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 Property (org.ff4j.property.Property)7 FF4jConfiguration (org.ff4j.conf.FF4jConfiguration)4 Date (java.util.Date)3 Before (org.junit.Before)3 ArrayList (java.util.ArrayList)2 ServletOutputStream (javax.servlet.ServletOutputStream)2 FileItem (org.apache.commons.fileupload.FileItem)2 DiskFileItemFactory (org.apache.commons.fileupload.disk.DiskFileItemFactory)2 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)2 YamlParser (org.ff4j.parser.yaml.YamlParser)2 PropertyDate (org.ff4j.property.PropertyDate)2 SpringSecurityAuthorisationManager (org.ff4j.security.SpringSecurityAuthorisationManager)2 TestConstantsFF4j (org.ff4j.test.TestConstantsFF4j)2