use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class FlipSecurityTests2 method setUp.
@Before
public void setUp() throws Exception {
securityCtx = SecurityContextHolder.getContext();
// Init SpringSecurity Context
SecurityContext context = new SecurityContextImpl();
List<GrantedAuthority> listOfRoles = new ArrayList<GrantedAuthority>();
listOfRoles.add(new SimpleGrantedAuthority("ROLE_USER"));
User u1 = new User("user1", "user1", true, true, true, true, listOfRoles);
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(u1.getUsername(), u1.getPassword(), u1.getAuthorities());
token.setDetails(u1);
context.setAuthentication(token);
SecurityContextHolder.setContext(context);
// <--
ff4j = new FF4j(new XmlParser(), "test-ff4j-security-spring.xml");
ff4j.setAuthorizationsManager(new SpringSecurityAuthorisationManager());
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class PropertiesParserTest method importProperties_should_be_same_asXMLImport.
@Test
public void importProperties_should_be_same_asXMLImport() {
// Give XML an YAML files
InputStream xmlFile = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.xml");
InputStream ymlFile = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.properties");
// When parsing those files
XmlConfig xmlConfig = new XmlParser().parseConfigurationFile(xmlFile);
FF4jConfiguration propsConfig = new PropertiesParser().parseConfigurationFile(ymlFile);
// Than both config are even
assertEquals(xmlConfig.getFeatures().size(), propsConfig.getFeatures().size());
assertEquals(xmlConfig.getProperties().size(), propsConfig.getProperties().size());
// Custom-properties
Feature f1Xml = xmlConfig.getFeatures().get("first");
Feature f1props = propsConfig.getFeatures().get("first");
assertEquals(f1Xml.getDescription(), f1props.getDescription());
assertEquals(f1Xml.getCustomProperties().size(), f1props.getCustomProperties().size());
// FlipStrategy & Permission
Feature f3Xml = xmlConfig.getFeatures().get("third");
Feature f3Props = propsConfig.getFeatures().get("third");
assertEquals(f3Xml.getFlippingStrategy().getClass(), f3Props.getFlippingStrategy().getClass());
assertEquals(f3Xml.getFlippingStrategy().getInitParams().get("expression"), f3Props.getFlippingStrategy().getInitParams().get("expression"));
assertEquals(f3Xml.getPermissions(), f3Props.getPermissions());
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class PropertiesParserTest method should_export_anyConfig_asProperties.
@Test
public void should_export_anyConfig_asProperties() {
// Given an XML file
InputStream xmlFile = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.xml");
// When loading config
XmlConfig xmlConfig = new XmlParser().parseConfigurationFile(xmlFile);
// Then it possible to export as YAML
new PropertiesParser().export(xmlConfig);
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class YamlParserTest method importYaml_should_be_same_asXMLImport.
@Test
public void importYaml_should_be_same_asXMLImport() {
// Give XML an YAML files
InputStream xmlFile = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.xml");
InputStream ymlFile = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.yml");
// When parsing those files
XmlConfig xmlConfig = new XmlParser().parseConfigurationFile(xmlFile);
FF4jConfiguration ymlConfig = new YamlParser().parseConfigurationFile(ymlFile);
// Than both config are even
assertEquals(xmlConfig.getFeatures().size(), ymlConfig.getFeatures().size());
assertEquals(xmlConfig.getProperties().size(), ymlConfig.getProperties().size());
// Custom-properties
Feature f1Xml = xmlConfig.getFeatures().get("first");
Feature f1Yml = ymlConfig.getFeatures().get("first");
assertEquals(f1Xml.getDescription(), f1Yml.getDescription());
assertEquals(f1Xml.getCustomProperties().size(), f1Yml.getCustomProperties().size());
// FlipStrategy & Permission
Feature f3Xml = xmlConfig.getFeatures().get("third");
Feature f3Yml = ymlConfig.getFeatures().get("third");
assertEquals(f3Xml.getFlippingStrategy().getClass(), f3Yml.getFlippingStrategy().getClass());
assertEquals(f3Xml.getFlippingStrategy().getInitParams().get("expression"), f3Yml.getFlippingStrategy().getInitParams().get("expression"));
assertEquals(f3Xml.getPermissions(), f3Yml.getPermissions());
}
use of org.ff4j.conf.XmlParser in project ff4j by ff4j.
the class YamlParserTest method should_export_anyConfig_asYaml.
@Test
public void should_export_anyConfig_asYaml() {
// Given an XML file
InputStream xmlFile = getClass().getClassLoader().getResourceAsStream("test-ff4j-features.xml");
// When loading config
XmlConfig xmlConfig = new XmlParser().parseConfigurationFile(xmlFile);
// Then it possible to export as YAML
new YamlParser().export(xmlConfig);
}
Aggregations