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");
}
}
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");
}
}
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");
}
}
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;
}
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;
}
Aggregations