use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class FilterMediatorTest method testFilterConditionTrueRegex.
public void testFilterConditionTrueRegex() throws Exception {
setFilterConditionPassed(false);
// create a new filter mediator
FilterMediator filter = new FilterMediator();
// set source xpath condition to //symbol
SynapseXPath source = new SynapseXPath("//wsx:symbol");
source.addNamespace("wsx", "http://www.webserviceX.NET/");
filter.setSource(source);
// set regex to IBM
Pattern regex = Pattern.compile("IBM");
filter.setRegex(regex);
// set dummy mediator to be called on success
filter.addChild(testMediator);
// test validate mediator, with static enveope
filter.mediate(TestUtils.getTestContext(REQ));
assertTrue(filterConditionPassed);
}
use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class FilterMediatorTest method testFilterConditionFalseRegex.
public void testFilterConditionFalseRegex() throws Exception {
setFilterConditionPassed(false);
// create a new filter mediator
FilterMediator filter = new FilterMediator();
// set source xpath condition to //symbol
SynapseXPath source = new SynapseXPath("//wsx:symbol");
source.addNamespace("wsx", "http://www.webserviceX.NET/");
filter.setSource(source);
// set regex to MSFT
Pattern regex = Pattern.compile("MSFT");
filter.setRegex(regex);
// set dummy mediator to be called on success
filter.addChild(testMediator);
// test validate mediator, with static enveope
filter.mediate(TestUtils.getTestContext(REQ));
assertTrue(!filterConditionPassed);
}
use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class FilterMediatorTest method testFilterConditionWithThenElse.
public void testFilterConditionWithThenElse() throws Exception {
setFilterConditionPassed(false);
// create a new filter mediator
FilterMediator filter = new FilterMediator();
// set source xpath condition to //symbol
SynapseXPath source = new SynapseXPath("//wsx:symbol");
source.addNamespace("wsx", "http://www.webserviceX.NET/");
filter.setSource(source);
// set regex to MSFT
Pattern regex = Pattern.compile("MSFT");
filter.setRegex(regex);
AnonymousListMediator seq = new AnonymousListMediator();
seq.addChild(testMediator);
filter.setElseMediator(seq);
// test validate mediator, with static enveope
filter.mediate(TestUtils.getTestContext(REQ));
assertTrue(filterConditionPassed);
}
Aggregations