use of org.apache.synapse.core.axis2.Axis2MessageContext in project wso2-synapse by wso2.
the class TestUtils method getAxis2MessageContext.
public static Axis2MessageContext getAxis2MessageContext(String bodyText, Map<String, Entry> props) throws Exception {
TestMessageContextBuilder builder = new TestMessageContextBuilder();
builder.setRequireAxis2MessageContext(true);
builder.setBodyFromString(bodyText);
if (props != null) {
for (Map.Entry<String, Entry> mapEntry : props.entrySet()) {
builder.addEntry(mapEntry.getKey(), mapEntry.getValue());
}
}
return (Axis2MessageContext) builder.build();
}
use of org.apache.synapse.core.axis2.Axis2MessageContext in project wso2-synapse by wso2.
the class TestUtils method createSynapseMessageContext.
public static MessageContext createSynapseMessageContext(String payload, SynapseConfiguration config) throws Exception {
org.apache.axis2.context.MessageContext mc = new org.apache.axis2.context.MessageContext();
AxisConfiguration axisConfig = config.getAxisConfiguration();
if (axisConfig == null) {
axisConfig = new AxisConfiguration();
config.setAxisConfiguration(axisConfig);
}
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
SynapseEnvironment env = new Axis2SynapseEnvironment(cfgCtx, config);
MessageContext synMc = new Axis2MessageContext(mc, config, env);
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
omDoc.addChild(envelope);
envelope.getBody().addChild(createOMElement(payload));
synMc.setEnvelope(envelope);
return synMc;
}
Aggregations