Search in sources :

Example 36 with FF4j

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

the class FF4jDroolsKBaseXml method testDroolsStrategyFromkBaseName.

@Test
public void testDroolsStrategyFromkBaseName() {
    // Given
    FF4j ff4j = new FF4j("ff4j-kbase.xml");
    // When
    Assert.assertTrue(ff4j.exist("f1"));
    // Then
    Assert.assertTrue(ff4j.check("f1"));
}
Also used : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 37 with FF4j

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

the class InMemoryPropertyStoreTest method testProperty.

public void testProperty() {
    FF4j ff4j = new FF4j("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 : FF4j(org.ff4j.FF4j) Date(java.util.Date) PropertyDate(org.ff4j.property.PropertyDate) PropertyDate(org.ff4j.property.PropertyDate)

Example 38 with FF4j

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

the class FF4jTest method authorisationManager.

@Test
public void authorisationManager() {
    FF4j ff4j = new FF4j();
    ff4j.setAuthorizationsManager(new DefinedPermissionSecurityManager(null));
    ff4j.getAuthorizationsManager().toString();
    ff4j.createFeature("f1");
    ff4j.check("f1");
    ff4j.setAuthorizationsManager(new DefinedPermissionSecurityManager(new HashSet<String>()));
    ff4j.getAuthorizationsManager().toString();
    ff4j.setAuthorizationsManager(new DefinedPermissionSecurityManager(Util.set("S1", "S2")));
    ff4j.getAuthorizationsManager().toString();
}
Also used : FF4j(org.ff4j.FF4j) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 39 with FF4j

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

the class FF4jTest method testAllowed.

@Test
public void testAllowed() {
    FF4j ff4j = new FF4j();
    ff4j.setAuthorizationsManager(new DefinedPermissionSecurityManager(Util.set("USER")));
    Feature f1 = new Feature("f1", true, null, null, Util.set("USER"));
    ff4j.createFeature(f1);
    ff4j.check(f1.getUid());
    ff4j.isAllowed(f1);
}
Also used : FF4j(org.ff4j.FF4j) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 40 with FF4j

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

the class FF4jTest method testDisableFeatureNotExist.

@Test(expected = FeatureNotFoundException.class)
public void testDisableFeatureNotExist() {
    FF4j ff4j = new FF4j();
    ff4j.disable("newffff");
}
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