Search in sources :

Example 41 with PropertyString

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

the class PropertyTest method testPropertyJsonBean.

@Test
public void testPropertyJsonBean() {
    PropertyString p2 = new PropertyString("p2", "EAST", Util.set("EAST", "WEST", "SOUTH", "NORTH"));
    PropertyJsonBean jb = new PropertyJsonBean(p2);
    jb.setDescription("descs");
    Assert.assertNotNull(jb);
    Assert.assertNotNull(jb.getName());
    Assert.assertNotNull(jb.getType());
    Assert.assertNotNull(jb.getDescription());
    Assert.assertNotNull(jb.getFixedValues());
    Assert.assertNotNull(jb.getValue());
    Assert.assertNotNull(jb.asProperty());
}
Also used : PropertyString(org.ff4j.property.PropertyString) PropertyJsonBean(org.ff4j.property.util.PropertyJsonBean) Test(org.junit.Test)

Example 42 with PropertyString

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

the class CacheProxyTest method testCacheProxyManagerProperty.

@Test
public void testCacheProxyManagerProperty() {
    FF4jCacheProxy proxy = new FF4jCacheProxy();
    proxy.setTargetPropertyStore(new InMemoryPropertyStore());
    proxy.setTargetFeatureStore(new InMemoryFeatureStore());
    proxy.setCacheManager(new InMemoryCacheManager());
    Assert.assertTrue(proxy.isEmpty());
    proxy.create(new Feature("a"));
    Assert.assertFalse(proxy.isEmpty());
    proxy.createProperty(new PropertyString("p1", "v1"));
    Property<?> p1 = proxy.readProperty("p1");
    proxy.readProperty("p1");
    proxy.getTargetPropertyStore().createProperty(new PropertyString("p2"));
    proxy.readProperty("p2");
    proxy.updateProperty("p1", "v2");
    proxy.updateProperty(p1);
    Assert.assertFalse(proxy.isEmpty());
    Assert.assertFalse(proxy.listPropertyNames().isEmpty());
    proxy.deleteProperty("p1");
    proxy.clear();
    Set<Property<?>> setOfProperty = new HashSet<Property<?>>();
    setOfProperty.add(new PropertyLogLevel("a", LogLevel.INFO));
    setOfProperty.add(new PropertyLogLevel("titi1", LogLevel.INFO));
    proxy.importProperties(setOfProperty);
    // Already in cache, but not same value
    proxy.createProperty(new PropertyString("cacheNStore", "cacheNStore"));
    proxy.readProperty("cacheNStore", p1);
    // Not in cache, but in store, but not same default value
    proxy.getTargetPropertyStore().createProperty(new PropertyString("p4", "v4"));
    proxy.readProperty("p1", p1);
    proxy.readProperty("p1", p1);
    // Nowhere, return default
    proxy.readProperty("p2", new PropertyString("p2"));
    proxy.readProperty("p1", new PropertyString("p3"));
}
Also used : PropertyLogLevel(org.ff4j.property.PropertyLogLevel) 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) Property(org.ff4j.property.Property) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 43 with PropertyString

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

the class InMemoryCacheTest method testPutNullPropertyName.

@Test(expected = IllegalArgumentException.class)
public void testPutNullPropertyName() {
    PropertyString p = new PropertyString();
    p.setName(null);
    new InMemoryCacheManager().putProperty(p);
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 44 with PropertyString

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

the class InMemoryCacheTest method testClear.

@Test
public void testClear() {
    // Given
    InMemoryCacheManager imcm = new InMemoryCacheManager();
    imcm.putProperty(new PropertyString("p1"));
    Assert.assertFalse(imcm.listCachedPropertyNames().isEmpty());
    // When
    imcm.clearProperties();
    // Then
    Assert.assertTrue(imcm.listCachedPropertyNames().isEmpty());
}
Also used : PropertyString(org.ff4j.property.PropertyString) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) Test(org.junit.Test)

Example 45 with PropertyString

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

the class AbstractPropertyStoreJunitTest method addPropertyOKsimple.

// --------------- create -----------
/**
 * TDD.
 */
@Test
public void addPropertyOKsimple() {
    // Given
    Assert.assertFalse(testedStore.existProperty("toto"));
    // When
    testedStore.createProperty(new PropertyString("toto", "ff4j"));
    // Then
    Assert.assertTrue(testedStore.existProperty("toto"));
}
Also used : PropertyString(org.ff4j.property.PropertyString) 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