use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class SourceTextRetrieverTest method testSOAPEnvelopeTextRetriever.
public void testSOAPEnvelopeTextRetriever() throws Exception {
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope env = fac.getDefaultEnvelope();
OMElement payload = AXIOMUtil.stringToOM(fac, "<getQuote id=\"attr\"><symbol>TEST</symbol><property>1</property>" + "<property>2</property></getQuote>");
env.getBody().addChild(payload);
MessageContext msgCtx = new MessageContext();
msgCtx.setEnvelope(env);
EvaluatorContext context = new EvaluatorContext(null, null);
context.setMessageContext(msgCtx);
SOAPEnvelopeTextRetriever txtRtvr = new SOAPEnvelopeTextRetriever("//symbol");
assertEquals("TEST", txtRtvr.getSourceText(context));
txtRtvr = new SOAPEnvelopeTextRetriever("//getQuote/@id");
assertEquals("attr", txtRtvr.getSourceText(context));
txtRtvr = new SOAPEnvelopeTextRetriever("//property[1]");
assertEquals("1", txtRtvr.getSourceText(context));
txtRtvr = new SOAPEnvelopeTextRetriever("//property[2]");
assertEquals("2", txtRtvr.getSourceText(context));
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class XFormURLEncodedFormatterTest method testGetBytes.
public void testGetBytes() throws AxisFault, XMLStreamException {
XFormURLEncodedFormatter formatter = new XFormURLEncodedFormatter();
MessageContext messageContext = Util.newMessageContext("<test><test>123</test></test>");
byte[] bytes = formatter.getBytes(messageContext, new OMOutputFormat());
assertEquals("Invalid X-form URL Encoded string", "test=123", new String(bytes));
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class XFormURLEncodedFormatterTest method testGetContentTypeWithSoapAction.
public void testGetContentTypeWithSoapAction() throws AxisFault, XMLStreamException {
XFormURLEncodedFormatter formatter = new XFormURLEncodedFormatter();
MessageContext messageContext = Util.newMessageContext();
String contentType = formatter.getContentType(messageContext, new OMOutputFormat(), "urn:mediate");
assertEquals("Invalid content type", "application/x-www-form-urlencoded;action=\"urn:mediate\";", contentType);
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class XFormURLEncodedFormatterTest method testGetContentType.
public void testGetContentType() throws AxisFault, XMLStreamException {
XFormURLEncodedFormatter formatter = new XFormURLEncodedFormatter();
MessageContext messageContext = Util.newMessageContext();
String contentType = formatter.getContentType(messageContext, new OMOutputFormat(), "");
assertEquals("Invalid content type", "application/x-www-form-urlencoded", contentType);
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class VFSUtils method getFileName.
public static String getFileName(MessageContext msgCtx, VFSOutTransportInfo vfsOutInfo) {
String fileName = null;
// first preference to a custom filename set on the current message context
Map transportHeaders = (Map) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
if (transportHeaders != null) {
fileName = (String) transportHeaders.get(VFSConstants.REPLY_FILE_NAME);
}
// if not, does the service (in its service.xml) specify one?
if (fileName == null) {
Parameter param = msgCtx.getAxisService().getParameter(VFSConstants.REPLY_FILE_NAME);
if (param != null) {
fileName = (String) param.getValue();
}
}
// next check if the OutTransportInfo specifies one
if (fileName == null) {
fileName = vfsOutInfo.getOutFileName();
}
// if none works.. use default
if (fileName == null) {
fileName = VFSConstants.DEFAULT_RESPONSE_FILE;
}
return fileName;
}
Aggregations