use of org.apache.synapse.core.SynapseEnvironment 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;
}
use of org.apache.synapse.core.SynapseEnvironment in project wso2-synapse by wso2.
the class BeanMediatorTest method init.
/**
* Initializing bean mediator by creating an initial bean in messageContext
*/
@BeforeClass
public static void init() {
SynapseEnvironment synapseEnvironment = Mockito.mock(SynapseEnvironment.class);
messageContext = new TestMessageContext();
beanMediator.setReplace(true);
beanMediator.setDescription(DESCRIPTION);
beanMediator.setBreakPoint(true);
beanMediator.setSkipEnabled(true);
beanMediator.setMediatorPosition(1);
beanMediator.setPropertyName(PROPERTY_NAME);
Value value = new Value(VALUE_TEXT);
beanMediator.setValue(value);
Target target = new Target(ATTRIBUTE, TestUtils.createOMElement(XML));
beanMediator.setTarget(target);
beanMediator.setAction(BeanMediator.Action.CREATE);
beanMediator.setClazz(SampleBean.class);
beanMediator.setVarName(VAR_NAME);
messageContext.setEnvironment(synapseEnvironment);
beanMediator.mediate(messageContext);
}
Aggregations