Search in sources :

Example 1 with ServerFilterStrategy

use of org.ff4j.strategy.ServerFilterStrategy in project ff4j by ff4j.

the class ClientFilterStrategyTest method testInitialisationProgramServer.

@Test
public void testInitialisationProgramServer() {
    FlippingStrategy fs = new ServerFilterStrategy("serv1,serv2");
    fs.init("f1", null);
    fs.init("f1", new HashMap<String, String>());
    FlippingExecutionContext context = new FlippingExecutionContext();
    fs.evaluate("f1", new InMemoryFeatureStore(), context);
}
Also used : ServerFilterStrategy(org.ff4j.strategy.ServerFilterStrategy) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FlippingStrategy(org.ff4j.core.FlippingStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 2 with ServerFilterStrategy

use of org.ff4j.strategy.ServerFilterStrategy in project ff4j by ff4j.

the class ServerFilterStrategyTest method testFilterInvalidClient.

@Test
public void testFilterInvalidClient() throws ParseException {
    // Given
    Feature f1 = ff4j.getFeature(F1);
    Assert.assertNotNull(f1.getFlippingStrategy());
    ServerFilterStrategy cStra = (ServerFilterStrategy) f1.getFlippingStrategy();
    Assert.assertNotNull(cStra.getInitParams());
    Assert.assertEquals(1, cStra.getInitParams().size());
    Assert.assertTrue(f1.isEnable());
    // When (add invalid client name)
    FlippingExecutionContext fex = new FlippingExecutionContext();
    fex.addValue(ServerFilterStrategy.SERVER_HOSTNAME, FEATURE_NEW);
    // Then
    Assert.assertFalse(ff4j.check(F1, fex));
}
Also used : ServerFilterStrategy(org.ff4j.strategy.ServerFilterStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 3 with ServerFilterStrategy

use of org.ff4j.strategy.ServerFilterStrategy in project ff4j by ff4j.

the class ServerFilterStrategyTest method testFilterOK.

@Test
public void testFilterOK() throws ParseException {
    // Given
    Feature f1 = ff4j.getFeature(F1);
    Assert.assertNotNull(f1.getFlippingStrategy());
    ServerFilterStrategy cStra = (ServerFilterStrategy) f1.getFlippingStrategy();
    Assert.assertNotNull(cStra.getInitParams());
    Assert.assertEquals(1, cStra.getInitParams().size());
    Assert.assertTrue(f1.isEnable());
    // When (add correct client name)
    FlippingExecutionContext fex = new FlippingExecutionContext();
    fex.addValue(ServerFilterStrategy.SERVER_HOSTNAME, "dev01");
    // Then
    Assert.assertTrue(ff4j.check(F1, fex));
}
Also used : ServerFilterStrategy(org.ff4j.strategy.ServerFilterStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Aggregations

FlippingExecutionContext (org.ff4j.core.FlippingExecutionContext)3 ServerFilterStrategy (org.ff4j.strategy.ServerFilterStrategy)3 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)3 Test (org.junit.Test)3 Feature (org.ff4j.core.Feature)2 FlippingStrategy (org.ff4j.core.FlippingStrategy)1 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)1