use of org.apache.synapse.commons.evaluators.source.URLTextRetriever in project wso2-synapse by wso2.
the class URLRewriteMediatorTest method testConditionalRewriteScenario1.
public void testConditionalRewriteScenario1() throws Exception {
URLRewriteMediator mediator = new URLRewriteMediator();
RewriteAction action = new RewriteAction();
action.setValue(targetURL);
RewriteRule rule = new RewriteRule();
EqualEvaluator eval = new EqualEvaluator();
URLTextRetriever txtRtvr = new URLTextRetriever();
txtRtvr.setSource(EvaluatorConstants.URI_FRAGMENTS.port.name());
eval.setTextRetriever(txtRtvr);
eval.setValue("8280");
rule.setCondition(eval);
rule.addRewriteAction(action);
mediator.addRule(rule);
MessageContext msgCtx = TestUtils.createLightweightSynapseMessageContext("<empty/>");
msgCtx.setTo(new EndpointReference("http://localhost:8280"));
mediator.mediate(msgCtx);
assertEquals(targetURL, msgCtx.getTo().getAddress());
}
use of org.apache.synapse.commons.evaluators.source.URLTextRetriever 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");
}
}
use of org.apache.synapse.commons.evaluators.source.URLTextRetriever 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.URLTextRetriever 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.URLTextRetriever 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");
}
}
Aggregations