Search in sources :

Example 1 with SOAPEnvelopeTextRetriever

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"));
}
Also used : SOAPEnvelopeTextRetriever(org.apache.synapse.commons.evaluators.source.SOAPEnvelopeTextRetriever) MessageContext(org.apache.synapse.MessageContext) EqualEvaluator(org.apache.synapse.commons.evaluators.EqualEvaluator) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

EndpointReference (org.apache.axis2.addressing.EndpointReference)1 MessageContext (org.apache.synapse.MessageContext)1 EqualEvaluator (org.apache.synapse.commons.evaluators.EqualEvaluator)1 SOAPEnvelopeTextRetriever (org.apache.synapse.commons.evaluators.source.SOAPEnvelopeTextRetriever)1