Search in sources :

Example 1 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class ConditionFactory method createCondition.

public Condition createCondition(OMElement ruleElement) throws EvaluatorException {
    Condition r = new Condition();
    OMAttribute priorityAtt = ruleElement.getAttribute(new QName(EvaluatorConstants.PRIORITY));
    if (priorityAtt != null) {
        int p = Integer.parseInt(priorityAtt.getAttributeValue());
        r.setPriority(p);
    }
    OMElement ce = ruleElement.getFirstElement();
    EvaluatorFactory ef = EvaluatorFactoryFinder.getInstance().findEvaluatorFactory(ce.getLocalName());
    if (ef == null) {
        handleException("Invalid configuration element: " + ce.getLocalName());
        return null;
    }
    Evaluator evaluator = ef.create(ce);
    r.setEvaluator(evaluator);
    return r;
}
Also used : Condition(org.apache.synapse.commons.evaluators.Condition) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 2 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class MatchSerializerTest method testURLMatchSerializer2.

public void testURLMatchSerializer2() {
    String input = "<match xmlns=\"http://ws.apache.org/ns/synapse\" type=\"url\" regex=\"http://foo.org\" source=\"protocol\"/>";
    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");
    }
}
Also used : OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

Example 3 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class EqualSerializerTest method testURLEqualSerializer2.

public void testURLEqualSerializer2() {
    String input = "<equal xmlns=\"http://ws.apache.org/ns/synapse\" type=\"url\" value=\"http://foo.org\" source=\"protocol\"/>";
    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");
    }
}
Also used : OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

Example 4 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class EqualSerializerTest method testHeaderEqualSerializer.

public void testHeaderEqualSerializer() {
    String input = "<equal xmlns=\"http://ws.apache.org/ns/synapse\" type=\"header\" source=\"foo\" value=\"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");
    }
}
Also used : OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

Example 5 with Evaluator

use of org.apache.synapse.commons.evaluators.Evaluator in project wso2-synapse by wso2.

the class EqualSerializerTest method testParameterEqualSerializer.

public void testParameterEqualSerializer() {
    String input = "<equal xmlns=\"http://ws.apache.org/ns/synapse\" type=\"param\" source=\"foo\" value=\"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");
    }
}
Also used : OMElement(org.apache.axiom.om.OMElement) Evaluator(org.apache.synapse.commons.evaluators.Evaluator)

Aggregations

Evaluator (org.apache.synapse.commons.evaluators.Evaluator)16 OMElement (org.apache.axiom.om.OMElement)15 Iterator (java.util.Iterator)4 EvaluatorException (org.apache.synapse.commons.evaluators.EvaluatorException)3 ArrayList (java.util.ArrayList)2 QName (javax.xml.namespace.QName)1 OMAttribute (org.apache.axiom.om.OMAttribute)1 AndEvaluator (org.apache.synapse.commons.evaluators.AndEvaluator)1 Condition (org.apache.synapse.commons.evaluators.Condition)1 NotEvaluator (org.apache.synapse.commons.evaluators.NotEvaluator)1 OrEvaluator (org.apache.synapse.commons.evaluators.OrEvaluator)1 EvaluatorSerializer (org.apache.synapse.commons.evaluators.config.EvaluatorSerializer)1 Target (org.apache.synapse.mediators.eip.Target)1 ConditionalRoute (org.apache.synapse.mediators.filters.router.ConditionalRoute)1 ConditionalRouterMediator (org.apache.synapse.mediators.filters.router.ConditionalRouterMediator)1 RewriteAction (org.apache.synapse.mediators.transform.url.RewriteAction)1 RewriteRule (org.apache.synapse.mediators.transform.url.RewriteRule)1