Search in sources :

Example 1 with SourceTextRetriever

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

the class MatchBuilderTest method testParameterMatch.

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

Example 2 with SourceTextRetriever

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

the class MatchBuilderTest method testHeaderMatch.

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

Example 3 with SourceTextRetriever

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

the class EqualBuilderTest method testParameterEqual.

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

Example 4 with SourceTextRetriever

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

the class EqualBuilderTest method testURLEqual2.

public void testURLEqual2() {
    String input = "<equal type=\"url\" value=\"" + VALUE + "\"" + " source=\"" + FRAGMENT + "\"/>";
    try {
        EqualEvaluator eval = (EqualEvaluator) fac.create(AXIOMUtil.stringToOM(input));
        SourceTextRetriever txtRtvr = eval.getTextRetriever();
        assertTrue(txtRtvr instanceof URLTextRetriever);
        assertEquals(eval.getValue(), VALUE);
        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) EqualEvaluator(org.apache.synapse.commons.evaluators.EqualEvaluator)

Example 5 with SourceTextRetriever

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

the class EqualBuilderTest method testHeaderEqual.

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

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