Search in sources :

Example 66 with SynapseEnvironment

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;
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) OMDocument(org.apache.axiom.om.OMDocument) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Example 67 with SynapseEnvironment

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);
}
Also used : TestMessageContext(org.apache.synapse.TestMessageContext) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) Value(org.apache.synapse.mediators.Value) BeforeClass(org.junit.BeforeClass)

Aggregations

SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)67 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)50 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)49 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)44 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)43 Test (org.junit.Test)40 OMElement (org.apache.axiom.om.OMElement)35 Parameter (org.apache.axis2.description.Parameter)29 MessageContext (org.apache.synapse.MessageContext)18 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)18 ArrayList (java.util.ArrayList)8 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)8 Endpoint (org.apache.synapse.endpoints.Endpoint)8 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)6 HashMap (java.util.HashMap)5 OMDocument (org.apache.axiom.om.OMDocument)4 SynapseException (org.apache.synapse.SynapseException)4 TestMessageContext (org.apache.synapse.TestMessageContext)4 IOException (java.io.IOException)3 ManagedLifecycle (org.apache.synapse.ManagedLifecycle)3