Search in sources :

Example 31 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class InMemoryPropertyStoreTest method testDonotImportNull.

@Test(expected = IllegalArgumentException.class)
public void testDonotImportNull() {
    InMemoryPropertyStore f = new InMemoryPropertyStore();
    f.importPropertiesFromXmlFile(null);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) Test(org.junit.Test)

Example 32 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class InMemoryPropertyStoreTest method testEmpty.

@Test
public void testEmpty() {
    // Given
    InMemoryPropertyStore ips = new InMemoryPropertyStore();
    Assert.assertTrue(ips.isEmpty());
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) Test(org.junit.Test)

Example 33 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore 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 34 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class InMemoryPropertiesStoreTest method testGetters.

@Test
public void testGetters() {
    InMemoryPropertyStore ips = new InMemoryPropertyStore();
    ips.setLocation("ff4j.xml");
    ips.setFileName("invalid.xml");
    Assert.assertEquals("invalid.xml", ips.getFileName());
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) Test(org.junit.Test)

Example 35 with InMemoryPropertyStore

use of org.ff4j.property.store.InMemoryPropertyStore in project ff4j by ff4j.

the class InMemoryPropertiesStoreTest method testInvalidXML.

@Test(expected = IllegalArgumentException.class)
public void testInvalidXML() {
    new InMemoryPropertyStore(new HashMap<String, Property<?>>());
    InputStream in = getClass().getClassLoader().getResourceAsStream("invalid.xml");
    new InMemoryPropertyStore(in);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InputStream(java.io.InputStream) PropertyString(org.ff4j.property.PropertyString) Property(org.ff4j.property.Property) Test(org.junit.Test)

Aggregations

InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)41 Test (org.junit.Test)28 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)10 PropertyString (org.ff4j.property.PropertyString)8 Property (org.ff4j.property.Property)6 PropertyStore (org.ff4j.property.store.PropertyStore)6 InputStream (java.io.InputStream)4 Before (org.junit.Before)4 FF4j (org.ff4j.FF4j)3 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)3 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)3 AbstractPollingScheduler (com.netflix.config.AbstractPollingScheduler)2 DynamicConfiguration (com.netflix.config.DynamicConfiguration)2 FixedDelayPollingScheduler (com.netflix.config.FixedDelayPollingScheduler)2 PolledConfigurationSource (com.netflix.config.PolledConfigurationSource)2 HashSet (java.util.HashSet)2 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)2 Feature (org.ff4j.core.Feature)2 BeforeClass (org.junit.BeforeClass)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1