use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.
the class MatchSerializerTest method testParameterMatchSerializer.
public void testParameterMatchSerializer() {
String input = "<match xmlns=\"http://ws.apache.org/ns/synapse\" type=\"param\" source=\"foo\" regex=\"bar\"/>";
try {
Evaluator eval = fac.create(AXIOMUtil.stringToOM(input));
OMElement output = serializer.serialize(null, eval);
assertXMLEqual(input, output.toString());
} catch (Exception e) {
fail("Error while parsing the input XML");
}
}
use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.
the class MatchSerializerTest method testURLMatchSerializer.
public void testURLMatchSerializer() {
String input = "<match xmlns=\"http://ws.apache.org/ns/synapse\" type=\"url\" regex=\"http://foo.org\"/>";
try {
Evaluator eval = fac.create(AXIOMUtil.stringToOM(input));
OMElement output = serializer.serialize(null, eval);
assertXMLEqual(input, output.toString());
} catch (Exception e) {
fail("Error while parsing the input XML");
}
}
use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.
the class AbstractEvaluatorSerializer method serializeChildren.
protected void serializeChildren(OMElement parent, Evaluator[] childEvaluators) throws EvaluatorException {
for (Evaluator evaluator : childEvaluators) {
String name = evaluator.getName();
EvaluatorSerializer serializer = EvaluatorSerializerFinder.getInstance().getSerializer(name);
if (serializer != null) {
serializer.serialize(parent, evaluator);
} else {
String msg = "Couldn't find the serializer for evaliator: " + name;
log.error(msg);
throw new EvaluatorException(msg);
}
}
}
use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.
the class AndFactory method create.
public Evaluator create(OMElement e) throws EvaluatorException {
AndEvaluator o = new AndEvaluator();
Iterator it = e.getChildElements();
List<Evaluator> evaluators = new ArrayList<Evaluator>();
while (it.hasNext()) {
OMElement evaluatorElement = (OMElement) it.next();
EvaluatorFactory ef = EvaluatorFactoryFinder.getInstance().findEvaluatorFactory(evaluatorElement.getLocalName());
if (ef == null) {
handleException("Invalid configuration element: " + evaluatorElement.getLocalName());
return null;
}
Evaluator evaluator = ef.create(evaluatorElement);
evaluators.add(evaluator);
}
if (evaluators.size() > 1) {
o.setEvaluators(evaluators.toArray(new Evaluator[evaluators.size()]));
} else {
handleException("Two or more expressions " + "should be provided under And");
return null;
}
return o;
}
use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.
the class NotFactory method create.
public Evaluator create(OMElement e) throws EvaluatorException {
NotEvaluator not = new NotEvaluator();
OMElement ce = e.getFirstElement();
EvaluatorFactory ef = EvaluatorFactoryFinder.getInstance().findEvaluatorFactory(ce.getLocalName());
if (ef == null) {
handleException("Invalid configuration element: " + ce.getLocalName());
return null;
}
Evaluator evaluator = ef.create(ce);
not.setEvaluator(evaluator);
return not;
}
Aggregations