use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class AnnotatedCommandMediatorTest method testBasicExecute.
public void testBasicExecute() throws Exception {
AnnotatedCommandMediator m = new AnnotatedCommandMediator();
m.setCommand(AnnotatedCommand.class);
Mediator pcm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<annotatedCommand name='org.apache.synapse.mediators.ext.AnnotatedCommand2' xmlns='http://ws.apache.org/ns/synapse'/>"), new Properties());
MessageContext mc = TestUtils.getTestContext("<m:getQuote xmlns:m=\"http://services.samples/xsd\"><m:request><m:symbol>IBM</m:symbol></m:request></m:getQuote>");
pcm.mediate(mc);
assertEquals("IBM", AnnotatedCommand2.fieldResult);
assertEquals("IBM", AnnotatedCommand2.methodResult);
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class ClassMediatorTest method testInitializationAndMedition.
public void testInitializationAndMedition() 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());
((ManagedLifecycle) cm).init(new Axis2SynapseEnvironment(new SynapseConfiguration()));
assertTrue(ClassMediatorTestMediator.initialized);
TestMessageContext msgContext = new TestMessageContext();
msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
cm.mediate(msgContext);
assertTrue(ClassMediatorTestMediator.invoked);
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class ClassMediatorTest method testMediationWithLiteralProperties.
public void testMediationWithLiteralProperties() throws Exception {
Mediator cm = MediatorFactoryFinder.getInstance().getMediator(createOMElement("<class name='org.apache.synapse.mediators.ext.ClassMediatorTestMediator' " + "xmlns='http://ws.apache.org/ns/synapse'><property name='testProp' value='testValue'/></class>"), new Properties());
TestMessageContext msgContext = new TestMessageContext();
msgContext.setEnvironment(new Axis2SynapseEnvironment(new SynapseConfiguration()));
cm.mediate(msgContext);
assertTrue(ClassMediatorTestMediator.invoked);
assertTrue(ClassMediatorTestMediator.testProp.equals("testValue"));
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class SEDAMediator method init.
public void init(SynapseEnvironment se) {
Mediator mediator = se.getSynapseConfiguration().getSequence(consumer);
sedaQueue = new SEDAQueue(sedaQueuePolicy, new SEDAQueueConsumerWorkerFactory(sedaQueueConsumerPolicy, new DefaultConsumer(mediator)));
sedaQueueProducer = new SEDAQueueProducer(sedaQueueProducerPolicy, sedaQueue);
sedaQueue.init();
initialized = true;
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class AbstractTestCase method serialization.
protected boolean serialization(String inputXml, MediatorFactory mediatorFactory, MediatorSerializer mediatorSerializer) {
OMElement inputOM = createOMElement(inputXml);
Mediator mediator = mediatorFactory.createMediator(inputOM, new Properties());
OMElement resultOM = mediatorSerializer.serializeMediator(null, mediator);
try {
assertXMLEqual(resultOM.toString(), inputXml);
return true;
} catch (SAXException e) {
log.error(e);
} catch (IOException e) {
log.error(e);
}
return false;
}
Aggregations