use of org.ff4j.core.Feature in project ff4j by ff4j.
the class JdbcFeatureStoreErrorTest method testUpdateKO.
@Test(expected = FeatureAccessException.class)
public void testUpdateKO() throws SQLException {
DataSource mockDS = Mockito.mock(DataSource.class);
doThrow(new SQLException()).when(mockDS).getConnection();
JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
jrepo.setDataSource(mockDS);
jrepo.update(new Feature("f1", true));
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class ClientFilterStrategyTest method testFilterRequiredContext.
@Test(expected = IllegalArgumentException.class)
public void testFilterRequiredContext() {
// Given
Feature f1 = ff4j.getFeature(F1);
Assert.assertNotNull(f1.getFlippingStrategy());
org.ff4j.strategy.ClientFilterStrategy cStra = (ClientFilterStrategy) f1.getFlippingStrategy();
Assert.assertNotNull(cStra.getInitParams());
Assert.assertEquals(1, cStra.getInitParams().size());
Assert.assertTrue(f1.isEnable());
// Then FeatureContext is requires
ff4j.check(F1);
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class PonderationStrategyTest method testExpressionCustom.
@Test
public void testExpressionCustom() {
Feature f = ff4j.getFeature("pond_6");
Assert.assertEquals(new Double(0.6), Double.valueOf(((PonderationStrategy) f.getFlippingStrategy()).getInitParams().get("weight")));
int nbOK = 0;
int nbKO = 0;
for (int i = 0; i < 1000; i++) {
if (ff4j.check(f.getUid())) {
nbOK++;
} else {
nbKO++;
}
}
Assert.assertTrue("both result occured", nbOK > 0 && nbKO > 0);
}
use of org.ff4j.core.Feature 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));
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureJsonMarshallTest method testEmbeddedQuoteJson.
@Test
public void testEmbeddedQuoteJson() throws Exception {
Feature f = new FF4j(new XmlParser(), "test-feature-json1.xml").getFeature("embedded\"quote");
assertMarshalling(f);
}
Aggregations