use of org.apache.synapse.commons.evaluators.EqualEvaluator 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");
}
}
use of org.apache.synapse.commons.evaluators.EqualEvaluator 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.EqualEvaluator in project wso2-synapse by wso2.
the class URLRewriteMediatorTest method testConditionalRewriteScenario4.
public void testConditionalRewriteScenario4() throws Exception {
URLRewriteMediator mediator = new URLRewriteMediator();
mediator.setOutputProperty("outURL");
RewriteAction action1 = new RewriteAction();
action1.setRegex("MyService");
action1.setValue("SimpleStockQuoteService");
action1.setFragmentIndex(URIFragments.PATH);
action1.setActionType(RewriteAction.ACTION_REPLACE);
RewriteRule rule1 = new RewriteRule();
rule1.addRewriteAction(action1);
EqualEvaluator eval1 = new EqualEvaluator();
SOAPEnvelopeTextRetriever txtRtvr1 = new SOAPEnvelopeTextRetriever("//symbol");
eval1.setTextRetriever(txtRtvr1);
eval1.setValue("IBM");
rule1.setCondition(eval1);
mediator.addRule(rule1);
MessageContext msgCtx = TestUtils.createLightweightSynapseMessageContext("<getQuote><symbol>IBM</symbol></getQuote>");
msgCtx.setTo(new EndpointReference("http://localhost:9000/services/MyService"));
mediator.mediate(msgCtx);
assertEquals(targetURL, msgCtx.getProperty("outURL"));
}
use of org.apache.synapse.commons.evaluators.EqualEvaluator 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.EqualEvaluator 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");
}
}
Aggregations