use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class ExpressionFlipStategyTest method testExplicitevaluate.
@Test
public void testExplicitevaluate() {
ExpressionFlipStrategy efs = new ExpressionFlipStrategy();
Assert.assertTrue(efs.evaluate("D", ff4j.getFeatureStore(), null));
Assert.assertTrue(efs.evaluate("TOTO", ff4j.getFeatureStore(), null));
FlippingExecutionContext fex = new FlippingExecutionContext();
fex.putString(ExpressionFlipStrategy.PARAM_EXPRESSION, "D");
Assert.assertTrue(efs.evaluate("D", ff4j.getFeatureStore(), fex));
fex.putString(ExpressionFlipStrategy.PARAM_EXPRESSION, "TOTO");
Assert.assertFalse(efs.evaluate("D", ff4j.getFeatureStore(), fex));
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class FeatureJsonMarshallTest method testJsonUtils.
@Test
public void testJsonUtils() {
FlippingStrategy ps = new FlippingStrategy() {
public void init(String featureName, Map<String, String> initParam) {
}
public Map<String, String> getInitParams() {
return null;
}
public boolean evaluate(String fn, FeatureStore s, FlippingExecutionContext ex) {
return false;
}
};
JsonUtils.flippingStrategyAsJson(ps);
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class FF4j method init.
/**
* Initialization of background components.
*/
private synchronized void init() {
// Execution Context
FlippingExecutionContext context = new FlippingExecutionContext();
this.currentExecutionContext.set(context);
// Event Publisher
if (eventPublisher == null) {
eventPublisher = new EventPublisher(eventRepository);
this.shutdownEventPublisher = true;
}
// Audit is enabled, proxified stores for auditing
if (isEnableAudit()) {
if (fstore != null && !(fstore instanceof FeatureStoreAuditProxy)) {
this.fstore = new FeatureStoreAuditProxy(this, fstore);
}
if (pStore != null && !(pStore instanceof PropertyStoreAuditProxy)) {
this.pStore = new PropertyStoreAuditProxy(this, pStore);
}
} else {
// Audit is disabled but could have been enabled before... removing PROXY if relevant
if (fstore != null && fstore instanceof FeatureStoreAuditProxy) {
this.fstore = ((FeatureStoreAuditProxy) fstore).getTarget();
}
if (pStore != null && pStore instanceof PropertyStoreAuditProxy) {
this.pStore = ((PropertyStoreAuditProxy) pStore).getTarget();
}
}
// Flag as OK
this.initialized = true;
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class FeatureTagDisable method eval.
/**
* {@inheritDoc}
*/
protected boolean eval(FF4j ff4j, PageContext jspContext) {
FlippingExecutionContext executionContext = new FlippingExecutionContext();
if (isShareHttpSession()) {
executionContext.putString("LOCALE", pageContext.getRequest().getLocalName());
@SuppressWarnings("unchecked") Map<String, String[]> parameters = pageContext.getRequest().getParameterMap();
for (Map.Entry<String, String[]> param : parameters.entrySet()) {
String[] innerParams = param.getValue();
if (innerParams != null) {
StringBuilder sb = new StringBuilder();
for (String innerParam : innerParams) {
sb.append(innerParam);
sb.append(",");
}
String expression = sb.toString();
executionContext.putString(param.getKey(), expression.substring(0, expression.length() - 1));
}
}
}
return !ff4j.check(getFeatureid(), executionContext);
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class FeatureTest method testFlipExecContext3.
@Test(expected = IllegalArgumentException.class)
public void testFlipExecContext3() {
Map<String, Object> parameters = new HashMap<String, Object>();
FlippingExecutionContext fec = new FlippingExecutionContext();
parameters.put("b", new Integer(1));
fec.getDouble("b");
}
Aggregations