Search in sources :

Example 41 with FF4j

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

the class FF4jTest method createDeleteProperty.

@Test
public void createDeleteProperty() {
    FF4j ff4j = new FF4j();
    ff4j.createProperty(new PropertyString("p1", "v1"));
    ff4j.audit();
    ff4j.createProperty(new PropertyString("p2", "v2"));
    Assert.assertTrue(ff4j.getPropertiesStore().existProperty("p1"));
    ff4j.deleteProperty("p1");
    Assert.assertFalse(ff4j.getPropertiesStore().existProperty("p1"));
}
Also used : PropertyString(org.ff4j.property.PropertyString) FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 42 with FF4j

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

the class FF4jTest method testToString.

@Test
public void testToString() {
    FF4j ff4j = new FF4j("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();
}
Also used : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 43 with FF4j

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

the class FF4jTest method testOverrideStrategy.

@Test
public void testOverrideStrategy() {
    FF4j ff4j = new FF4j();
    ff4j.audit();
    ff4j.createFeature("N1", true, "description NEWS");
    ff4j.createFeature("N2", false, "description NEWS");
    Assert.assertTrue(ff4j.check("N1"));
    Assert.assertFalse(ff4j.checkOveridingStrategy("N1", new ExpressionFlipStrategy("N1", "N1 & N2")));
}
Also used : ExpressionFlipStrategy(org.ff4j.strategy.el.ExpressionFlipStrategy) FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 44 with FF4j

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

the class FF4jTest method testDisableFeature.

// disabling...
@Test
public void testDisableFeature() {
    FF4j ff4j = new FF4j();
    ff4j.autoCreate(true);
    ff4j.disable("newffff");
    Assert.assertTrue(ff4j.exist("newffff"));
    Assert.assertFalse(ff4j.check("newffff"));
}
Also used : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 45 with FF4j

use of org.ff4j.FF4j 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("ff4j.xml");
    ff4j.autoCreate();
    assertFalse(ff4j.exist("autoCreatedFeature"));
    // Auto creation by testing its value
    assertFalse(ff4j.check("autoCreatedFeature"));
    // Assertion
    assertTrue(ff4j.exist("autoCreatedFeature"));
}
Also used : FF4j(org.ff4j.FF4j) 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