use of org.apache.synapse.commons.evaluators.source.SOAPEnvelopeTextRetriever 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"));
}
Aggregations