Search in sources :

Example 46 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class FF4jTest method readFeatureNotFound.

@Test(expected = FeatureNotFoundException.class)
public void readFeatureNotFound() {
    // Given
    FF4j ff4j = new FF4j();
    // When
    ff4j.getFeature("i-dont-exist");
// Then
// expect error...
}
Also used : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 47 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class FF4jTest method testGetFeatures.

@Test
public void testGetFeatures() {
    FF4j ff4j = new FF4j("ff4j.xml");
    Assert.assertEquals(5, ff4j.getFeatures().size());
}
Also used : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 48 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class FF4jTest method testDisableWithAudit.

@Test
public void testDisableWithAudit() {
    // Given
    FF4j ff4j = new FF4j(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 : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 49 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class FF4jTest method testDeleteFeature.

@Test
public void testDeleteFeature() {
    FF4j ff4j = new FF4j("ff4j.xml");
    ff4j.audit();
    Assert.assertTrue(ff4j.exist(F1));
    ff4j.delete(F1);
    Assert.assertFalse(ff4j.exist(F1));
}
Also used : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 50 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class AuditBeanTest method testEventBuider.

@Test
public void testEventBuider() {
    FF4j ff4j = new FF4j();
    ff4j.setAuthorizationsManager(new DefinedPermissionSecurityManager("a", Util.set("1", "2")));
    EventBuilder eb = new EventBuilder(ff4j);
    eb.name("FeatureX");
    Assert.assertEquals("a", eb.build().getUser());
}
Also used : EventBuilder(org.ff4j.audit.EventBuilder) FF4j(org.ff4j.FF4j) DefinedPermissionSecurityManager(org.ff4j.test.DefinedPermissionSecurityManager) Test(org.junit.Test)

Aggregations

FF4j (org.ff4j.FF4j)60 Test (org.junit.Test)41 Before (org.junit.Before)9 Feature (org.ff4j.core.Feature)8 ArrayList (java.util.ArrayList)4 PropertyString (org.ff4j.property.PropertyString)4 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)4 AssertFf4j (org.ff4j.test.AssertFf4j)4 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)3 Date (java.util.Date)2 HashSet (java.util.HashSet)2 PropertyStoreAuditProxy (org.ff4j.audit.proxy.PropertyStoreAuditProxy)2 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)2 FeatureStore (org.ff4j.core.FeatureStore)2 PropertyDate (org.ff4j.property.PropertyDate)2 PropertyStore (org.ff4j.property.store.PropertyStore)2 SpringSecurityAuthorisationManager (org.ff4j.security.SpringSecurityAuthorisationManager)2 TestConstantsFF4j (org.ff4j.test.TestConstantsFF4j)2 ApiConfig (org.ff4j.web.ApiConfig)2 ApiConfigBuilder (org.ff4j.web.ApiConfigBuilder)2