Search in sources :

Example 6 with SourceTextRetriever

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

the class EqualBuilderTest method testURLEqual.

public void testURLEqual() {
    String input = "<equal type=\"url\" value=\"" + VALUE + "\"/>";
    try {
        EqualEvaluator eval = (EqualEvaluator) fac.create(AXIOMUtil.stringToOM(input));
        SourceTextRetriever txtRtvr = eval.getTextRetriever();
        assertTrue(txtRtvr instanceof URLTextRetriever);
        assertEquals(eval.getValue(), VALUE);
        assertNull(txtRtvr.getSource());
    } catch (Exception e) {
        fail("Error while parsing the input XML");
    }
}
Also used : URLTextRetriever(org.apache.synapse.commons.evaluators.source.URLTextRetriever) SourceTextRetriever(org.apache.synapse.commons.evaluators.source.SourceTextRetriever) EqualEvaluator(org.apache.synapse.commons.evaluators.EqualEvaluator)

Example 7 with SourceTextRetriever

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

the class MatchBuilderTest method testURLMatch2.

public void testURLMatch2() {
    String input = "<match type=\"url\" regex=\"" + REGEX + "\" source=\"" + FRAGMENT + "\"/>";
    try {
        MatchEvaluator eval = (MatchEvaluator) fac.create(AXIOMUtil.stringToOM(input));
        SourceTextRetriever txtRtvr = eval.getTextRetriever();
        assertTrue(txtRtvr instanceof URLTextRetriever);
        assertEquals(eval.getRegex().pattern(), REGEX);
        assertEquals(txtRtvr.getSource(), FRAGMENT);
    } catch (Exception e) {
        fail("Error while parsing the input XML");
    }
}
Also used : URLTextRetriever(org.apache.synapse.commons.evaluators.source.URLTextRetriever) SourceTextRetriever(org.apache.synapse.commons.evaluators.source.SourceTextRetriever) MatchEvaluator(org.apache.synapse.commons.evaluators.MatchEvaluator)

Example 8 with SourceTextRetriever

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

the class MatchBuilderTest method testURLMatch.

public void testURLMatch() {
    String input = "<match type=\"url\" regex=\"" + REGEX + "\"/>";
    try {
        MatchEvaluator eval = (MatchEvaluator) fac.create(AXIOMUtil.stringToOM(input));
        SourceTextRetriever txtRtvr = eval.getTextRetriever();
        assertTrue(txtRtvr instanceof URLTextRetriever);
        assertEquals(eval.getRegex().pattern(), REGEX);
        assertNull(txtRtvr.getSource());
    } catch (Exception e) {
        e.printStackTrace();
        fail("Error while parsing the input XML");
    }
}
Also used : URLTextRetriever(org.apache.synapse.commons.evaluators.source.URLTextRetriever) SourceTextRetriever(org.apache.synapse.commons.evaluators.source.SourceTextRetriever) MatchEvaluator(org.apache.synapse.commons.evaluators.MatchEvaluator)

Example 9 with SourceTextRetriever

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

the class EqualFactory method create.

public Evaluator create(OMElement e) throws EvaluatorException {
    EqualEvaluator equal = new EqualEvaluator();
    SourceTextRetriever textRetriever = getSourceTextRetriever(e);
    equal.setTextRetriever(textRetriever);
    OMAttribute valueAttr = e.getAttribute(new QName(EvaluatorConstants.VALUE));
    if (valueAttr == null) {
        handleException(EvaluatorConstants.VALUE + " attribute is required");
        return null;
    }
    equal.setValue(valueAttr.getAttributeValue());
    return equal;
}
Also used : QName(javax.xml.namespace.QName) SourceTextRetriever(org.apache.synapse.commons.evaluators.source.SourceTextRetriever) OMAttribute(org.apache.axiom.om.OMAttribute) EqualEvaluator(org.apache.synapse.commons.evaluators.EqualEvaluator)

Example 10 with SourceTextRetriever

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

the class MatchFactory method create.

public Evaluator create(OMElement e) throws EvaluatorException {
    MatchEvaluator equal = new MatchEvaluator();
    SourceTextRetriever textRetriever = getSourceTextRetriever(e);
    equal.setTextRetriever(textRetriever);
    OMAttribute regExAttr = e.getAttribute(new QName(EvaluatorConstants.REGEX));
    if (regExAttr == null) {
        handleException(EvaluatorConstants.REGEX + " attribute is required");
        return null;
    }
    equal.setRegex(Pattern.compile(regExAttr.getAttributeValue()));
    return equal;
}
Also used : QName(javax.xml.namespace.QName) SourceTextRetriever(org.apache.synapse.commons.evaluators.source.SourceTextRetriever) OMAttribute(org.apache.axiom.om.OMAttribute) MatchEvaluator(org.apache.synapse.commons.evaluators.MatchEvaluator)

Aggregations

SourceTextRetriever (org.apache.synapse.commons.evaluators.source.SourceTextRetriever)10 EqualEvaluator (org.apache.synapse.commons.evaluators.EqualEvaluator)5 MatchEvaluator (org.apache.synapse.commons.evaluators.MatchEvaluator)5 URLTextRetriever (org.apache.synapse.commons.evaluators.source.URLTextRetriever)4 QName (javax.xml.namespace.QName)2 OMAttribute (org.apache.axiom.om.OMAttribute)2 HeaderTextRetriever (org.apache.synapse.commons.evaluators.source.HeaderTextRetriever)2 ParameterTextRetriever (org.apache.synapse.commons.evaluators.source.ParameterTextRetriever)2