use of org.apache.synapse.TestMessageContext 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.TestMessageContext 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.TestMessageContext 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.TestMessageContext 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());
}
use of org.apache.synapse.TestMessageContext 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