Search in sources :

Example 1 with TestMessageContext

use of org.apache.synapse.TestMessageContext in project wso2-synapse by wso2.

the class POJOCommandMediatorTest method testPojoWithPropertiesCommandImpl.

public void testPojoWithPropertiesCommandImpl() throws Exception {
    Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " + "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " + "expression=\"fn:concat('XPATH ', 'FUNC')\" action=\"ReadMessage\"/></pojoCommand>"), new Properties());
    POJOCommandTestHelper.reset();
    TestMessageContext msgContext = new TestMessageContext();
    msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
    pcm.mediate(msgContext);
    assertEquals("XPATH FUNC", POJOCommandTestHelper.getInstance().getChangedProperty());
    assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) TestMessageContext(org.apache.synapse.TestMessageContext) Mediator(org.apache.synapse.Mediator) Properties(java.util.Properties) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 2 with TestMessageContext

use of org.apache.synapse.TestMessageContext in project wso2-synapse by wso2.

the class POJOCommandMediatorTest method testPojoWithoutPropertiesCommandImpl.

public void testPojoWithoutPropertiesCommandImpl() throws Exception {
    Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " + "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
    POJOCommandTestHelper.reset();
    TestMessageContext msgContext = new TestMessageContext();
    msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
    pcm.mediate(msgContext);
    assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) TestMessageContext(org.apache.synapse.TestMessageContext) Mediator(org.apache.synapse.Mediator) Properties(java.util.Properties) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 3 with TestMessageContext

use of org.apache.synapse.TestMessageContext in project wso2-synapse by wso2.

the class POJOCommandMediatorTest method testPojoWithoutPropertiesNotCommandImpl.

public void testPojoWithoutPropertiesNotCommandImpl() throws Exception {
    Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestMediator' " + "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
    POJOCommandTestHelper.reset();
    TestMessageContext msgContext = new TestMessageContext();
    msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
    pcm.mediate(msgContext);
    assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) TestMessageContext(org.apache.synapse.TestMessageContext) Mediator(org.apache.synapse.Mediator) Properties(java.util.Properties) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 4 with TestMessageContext

use of org.apache.synapse.TestMessageContext in project wso2-synapse by wso2.

the class POJOCommandMediatorTest method testPojoWithStaticPropertiesCommandImpl.

public void testPojoWithStaticPropertiesCommandImpl() throws Exception {
    Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestImplementedMediator' " + "xmlns='http://ws.apache.org/ns/synapse'><property name=\"testProp\" " + "value=\"Test Property\"/></pojoCommand>"), new Properties());
    POJOCommandTestHelper.reset();
    TestMessageContext msgContext = new TestMessageContext();
    msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
    pcm.mediate(msgContext);
    assertEquals("Test Property", POJOCommandTestHelper.getInstance().getChangedProperty());
    assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
}
Also used : Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) TestMessageContext(org.apache.synapse.TestMessageContext) Mediator(org.apache.synapse.Mediator) Properties(java.util.Properties) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration)

Example 5 with TestMessageContext

use of org.apache.synapse.TestMessageContext in project wso2-synapse by wso2.

the class SynapseXPathTest method testContextProperties.

public void testContextProperties() throws Exception {
    SynapseXPath xpath = new SynapseXPath("$ctx:test");
    MessageContext synCtx = new TestMessageContext();
    synCtx.setProperty("test", message);
    assertEquals(xpath.evaluate(synCtx), message);
}
Also used : SynapseXPath(org.apache.synapse.util.xpath.SynapseXPath) TestMessageContext(org.apache.synapse.TestMessageContext) TestMessageContext(org.apache.synapse.TestMessageContext) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Aggregations

TestMessageContext (org.apache.synapse.TestMessageContext)20 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)16 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)13 Properties (java.util.Properties)12 Mediator (org.apache.synapse.Mediator)12 MessageContext (org.apache.synapse.MessageContext)10 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)4 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 ManagedLifecycle (org.apache.synapse.ManagedLifecycle)2 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)2 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)2 EndpointDefinition (org.apache.synapse.endpoints.EndpointDefinition)2 SynapseXPath (org.apache.synapse.util.xpath.SynapseXPath)2 Test (org.junit.Test)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 AbstractEndpoint (org.apache.synapse.endpoints.AbstractEndpoint)1