use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class SynapseXPathTest method testAbsoluteXPath.
public void testAbsoluteXPath() throws Exception {
SynapseXPath xpath = new SynapseXPath("//test");
MessageContext ctx = TestUtils.getTestContext("<test>" + message + "</test>");
assertEquals(message, xpath.stringValueOf(ctx));
}
use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class SynapseXPathTest method testAxis2ContextProperties.
public void testAxis2ContextProperties() throws Exception {
Axis2MessageContext synCtx = TestUtils.getAxis2MessageContext("<test/>", null);
synCtx.getAxis2MessageContext().setProperty("test", message);
synCtx.getAxis2MessageContext().setProperty("test2", "1234");
assertEquals(message, new SynapseXPath("$axis2:test").evaluate(synCtx));
assertEquals(1234, new SynapseXPath("$axis2:test2").numberValueOf(synCtx).intValue());
assertTrue(new SynapseXPath("$axis2:test2 = 1234").booleanValueOf(synCtx));
}
use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class SynapseXPathTest method testStandardXPathFunctions.
public void testStandardXPathFunctions() throws Exception {
MessageContext ctx = TestUtils.getTestContext("<test>123456</test>");
assertEquals(6, new SynapseXPath("string-length(//test)").numberValueOf(ctx).intValue());
}
use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class SynapseXPathTest method testStringXPath.
public void testStringXPath() throws Exception {
SynapseXPath xpath = SynapseXPath.parseXPathString("$body//{http://somens}test");
MessageContext ctx = TestUtils.getTestContext("<m0:test xmlns:m0=\"http://somens\">" + message + "</m0:test>");
assertEquals(message, xpath.stringValueOf(ctx));
}
use of org.apache.synapse.util.xpath.SynapseXPath in project wso2-synapse by wso2.
the class DetachMediatorFactory method createSpecificMediator.
public DetachMediator createSpecificMediator(OMElement elem, Properties properties) {
DetachMediator mediator = new DetachMediator();
processAuditStatus(mediator, elem);
OMAttribute attSource = elem.getAttribute(ATT_SOURCE);
OMAttribute attProperty = elem.getAttribute(ATT_PROPERTY);
if (attSource != null) {
try {
mediator.setSource(new SynapseXPath(attSource));
} catch (JaxenException e) {
handleException("Invalid XPath specified for the source attribute : " + attSource.getAttributeValue());
}
}
if (attProperty != null) {
mediator.setProperty(attProperty.getAttributeValue());
} else {
handleException("The 'property' attribute is required for the detach mediator");
}
return mediator;
}
Aggregations