Search in sources :

Example 6 with FF4j

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

the class InvalidParameter method testInvalidParameter.

@Test(expected = IllegalArgumentException.class)
public void testInvalidParameter() throws Throwable {
    final IDoIt service = new IDoItImpl();
    service.doIt("");
    FeatureAdvisor fa = new FeatureAdvisor();
    fa.setFf4j(new FF4j("test-ff4j-features.xml"));
    MethodInvocation mi = new MethodInvocation() {

        public Object proceed() throws Throwable {
            return null;
        }

        public Object getThis() {
            return service;
        }

        public AccessibleObject getStaticPart() {
            return null;
        }

        public Object[] getArguments() {
            return null;
        }

        public Method getMethod() {
            try {
                Method m = IDoIt.class.getMethod("doIt", String.class);
                return m;
            } catch (SecurityException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
            return null;
        }
    };
    fa.invoke(mi);
}
Also used : FF4j(org.ff4j.FF4j) FeatureAdvisor(org.ff4j.aop.FeatureAdvisor) MethodInvocation(org.aopalliance.intercept.MethodInvocation) AccessibleObject(java.lang.reflect.AccessibleObject) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 7 with FF4j

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

the class EhCacheCacheManagerTest2 method initialize.

@Before
public /**
 * Init cache.
 */
void initialize() {
    cacheManager = new FeatureCacheProviderEhCache();
    // Stores in memory
    ff4j = new FF4j();
    ff4j.createFeature(new Feature("f1", false));
    // Enable caching using EHCACHE
    ff4j.cache(cacheManager);
// How to access cacheManager from FF4J
// ff4j.getCacheProxy().getCacheManager();
}
Also used : FF4j(org.ff4j.FF4j) Feature(org.ff4j.core.Feature) Before(org.junit.Before)

Example 8 with FF4j

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

the class FF4jTest method testImportProperties.

@Test
public void testImportProperties() {
    FF4j ff4j = new FF4j();
    List<Property<?>> listOfProperties = new ArrayList<Property<?>>();
    listOfProperties.add(new PropertyString("p1", "v1"));
    ff4j.importProperties(listOfProperties);
    Assert.assertTrue(ff4j.getPropertiesStore().existProperty("p1"));
    // no Error
    ff4j.importProperties(null);
}
Also used : PropertyString(org.ff4j.property.PropertyString) FF4j(org.ff4j.FF4j) ArrayList(java.util.ArrayList) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 9 with FF4j

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

the class FF4jTest method getConcreteFeatureStore.

@Test
public void getConcreteFeatureStore() {
    FF4j ff4j = new FF4j();
    ff4j.cache(new InMemoryCacheManager());
    Assert.assertNotNull(ff4j.getCacheProxy());
    Assert.assertNotNull(ff4j.getConcreteFeatureStore());
    Assert.assertNotNull(ff4j.getConcretePropertyStore());
    ff4j.setPropertiesStore(new PropertyStoreAuditProxy(ff4j, ff4j.getPropertiesStore()));
    Assert.assertNotNull(ff4j.getConcretePropertyStore());
}
Also used : PropertyStoreAuditProxy(org.ff4j.audit.proxy.PropertyStoreAuditProxy) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 10 with FF4j

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

the class FF4jTest method testReadCoreMetadata.

@Test
public void testReadCoreMetadata() {
    FF4j ff4j = new FF4j();
    ff4j.getVersion();
    Assert.assertNotNull(ff4j.getStartTime());
    Assert.assertNotNull(ff4j.getPropertiesStore());
    Assert.assertNotNull(ff4j.getCurrentContext());
    Assert.assertNotNull(ff4j.getProperties());
}
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