Search in sources :

Example 16 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class CacheProxyTest method testCacheProxyManager.

@Test
public void testCacheProxyManager() {
    FF4jCacheProxy proxy = new FF4jCacheProxy();
    FF4JCacheManager cm = new InMemoryCacheManager();
    proxy.setCacheManager(cm);
    proxy.isCached();
    Assert.assertNotNull(proxy.getCacheProvider());
    proxy.setTargetPropertyStore(new InMemoryPropertyStore());
    Assert.assertEquals(0, proxy.readAllProperties().size());
    proxy.createProperty(new PropertyString("p1", "v1"));
    Assert.assertTrue(proxy.existProperty("p1"));
    Assert.assertFalse(proxy.existProperty("p2"));
    proxy.setTargetFeatureStore(new InMemoryFeatureStore());
    Set<Feature> setOfFeatures = new HashSet<Feature>();
    setOfFeatures.add(new Feature("f1"));
    setOfFeatures.add(new Feature("f2"));
    proxy.importFeatures(setOfFeatures);
}
Also used : FF4JCacheManager(org.ff4j.cache.FF4JCacheManager) PropertyString(org.ff4j.property.PropertyString) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) Feature(org.ff4j.core.Feature) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class InMemoryCacheTest method testGetProperty4.

@Test(expected = IllegalArgumentException.class)
public void testGetProperty4() {
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    PropertyString p1 = new PropertyString("p1");
    p1.setName("");
    imcm.putProperty(p1, 1);
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 18 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class InMemoryCacheTest method testGetPropertyTimeout.

@Test
public void testGetPropertyTimeout() throws InterruptedException {
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    imcm.putProperty(new PropertyString("p1"), 1);
    imcm.putProperty(new PropertyString("p2"), 10);
    Thread.sleep(1100);
    Assert.assertNull(imcm.getProperty("p1"));
    Assert.assertNotNull(imcm.getProperty("p2"));
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 19 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class InMemoryCacheTest method testGetProperty3.

@Test(expected = IllegalArgumentException.class)
public void testGetProperty3() {
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    PropertyString p1 = new PropertyString("p1");
    p1.setName(null);
    imcm.putProperty(p1, 1);
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 20 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class InMemoryCacheTest method testGetProperty.

@Test
public void testGetProperty() throws InterruptedException {
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    imcm.putProperty(new PropertyString("p1"));
    Assert.assertNull(imcm.getProperty("p2"));
    Assert.assertNotNull(imcm.getProperty("p1"));
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Aggregations

PropertyString (org.ff4j.property.PropertyString)54 Test (org.junit.Test)52 Feature (org.ff4j.core.Feature)18 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)11 Property (org.ff4j.property.Property)6 HashSet (java.util.HashSet)5 Set (java.util.Set)4 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)4 HashMap (java.util.HashMap)3 FF4j (org.ff4j.FF4j)3 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)3 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 DataSource (javax.sql.DataSource)2 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)2 PropertyJsonBean (org.ff4j.property.util.PropertyJsonBean)2 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1