use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class ClassMediatorTest method testDestroy.
public void testDestroy() throws Exception {
Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " + "xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
TestMessageContext msgContext = new TestMessageContext();
msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
cm.mediate(msgContext);
assertTrue(ClassMediatorTestMediator.invoked);
((ManagedLifecycle) cm).destroy();
assertTrue(ClassMediatorTestMediator.destroyed);
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class POJOCommandMediatorTest method testPojoWithContextR$UPropertiesCommandImpl.
public void testPojoWithContextR$UPropertiesCommandImpl() 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=\"ctxTest\" " + "context-name=\"testCtxProp\" action=\"ReadAndUpdateContext\"/></pojoCommand>"), new Properties());
POJOCommandTestHelper.reset();
MessageContext ctx = new TestMessageContext();
ctx.setProperty("testCtxProp", "test");
ctx.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
pcm.mediate(ctx);
assertEquals("testcommand", ctx.getProperty("testCtxProp").toString());
assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class POJOCommandMediatorTest method testPojoWithMessagePropertiesCommandImpl.
public void testPojoWithMessagePropertiesCommandImpl() 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=\"TestProperty\" expression=\"//testNode\"/></pojoCommand>"), new Properties());
POJOCommandTestHelper.reset();
MessageContext ctx = new TestMessageContext();
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
envelope.getBody().addChild(createOMElement("<original><testNode/></original>"));
ctx.setEnvelope(envelope);
ctx.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
pcm.mediate(ctx);
assertEquals("TestProperty", POJOCommandTestHelper.getInstance().getChangedProperty());
assertEquals("<original>TestProperty</original>", ctx.getEnvelope().getBody().getFirstOMChild().toString());
assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class POJOCommandMediatorTest method testPojoWithPropertiesNotCommandImpl.
public void testPojoWithPropertiesNotCommandImpl() throws Exception {
Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<pojoCommand name='org.apache.synapse.mediators.ext.POJOCommandTestMediator' " + "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());
}
use of org.apache.synapse.core.axis2.Axis2SynapseEnvironment in project wso2-synapse by wso2.
the class POJOCommandMediatorTest method testPojoWithContextPropertiesCommandImpl.
public void testPojoWithContextPropertiesCommandImpl() 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\" context-name=\"testPropInMC\"/></pojoCommand>"), new Properties());
POJOCommandTestHelper.reset();
MessageContext ctx = new TestMessageContext();
ctx.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
pcm.mediate(ctx);
assertEquals("Test Property", POJOCommandTestHelper.getInstance().getChangedProperty());
assertEquals("Test Property", ctx.getProperty("testPropInMC"));
assertTrue(POJOCommandTestHelper.getInstance().isExecuted());
}
Aggregations