use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class PayloadFactoryMediatorSerializerTest method testSerializeSpecificMediator4.
/**
* Test SerializeSpecificMediator method with PathArgument added for payloadFactory mediator
* and assert that argument is added.
*/
@Test
public void testSerializeSpecificMediator4() throws JaxenException {
PayloadFactoryMediatorSerializer serializer = new PayloadFactoryMediatorSerializer();
PayloadFactoryMediator payloadFactoryMediator = new PayloadFactoryMediator();
Argument argument = new Argument();
argument.setValue("TestArgument1");
payloadFactoryMediator.addPathArgument(argument);
payloadFactoryMediator.setFormat(format);
OMElement element = serializer.serializeSpecificMediator(payloadFactoryMediator);
MediatorFactory mediatorFactory = new PayloadFactoryMediatorFactory();
Mediator mediator = mediatorFactory.createMediator(element, null);
Assert.assertNotNull(element);
Assert.assertEquals("Path argument added is not serialized", "TestArgument1", ((PayloadFactoryMediator) mediator).getPathArgumentList().get(0).getValue());
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class PayloadFactoryMediatorSerializerTest method testSerializeSpecificMediator3.
/**
* Test SerializeSpecificMediator method with Dynamic format added for payloadFactory mediator
* and assert that dynamic format is set.
*/
@Test
public void testSerializeSpecificMediator3() {
PayloadFactoryMediatorSerializer serializer = new PayloadFactoryMediatorSerializer();
PayloadFactoryMediator payloadFactoryMediator = new PayloadFactoryMediator();
payloadFactoryMediator.setFormat(format);
payloadFactoryMediator.setFormatDynamic(true);
payloadFactoryMediator.setFormatKey(new Value("testKey"));
OMElement element = serializer.serializeSpecificMediator(payloadFactoryMediator);
Assert.assertNotNull(element);
MediatorFactory mediatorFactory = new PayloadFactoryMediatorFactory();
Mediator mediator = mediatorFactory.createMediator(element, null);
Assert.assertTrue("Dynamic Format set for Mediator is not serialized", ((PayloadFactoryMediator) mediator).isFormatDynamic());
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class EventPublisherMediatorSerializerTest method testCreateEventSource.
/**
* Passing unsupported mediator.
*/
@Test(expected = SynapseException.class)
public void testCreateEventSource() {
EventPublisherMediatorSerializer mediatorSerializer = new EventPublisherMediatorSerializer();
Mediator mediator = new CallMediator();
mediatorSerializer.serializeSpecificMediator(mediator);
}
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;
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class BeanMediatorFactoryTest method testCreateSpecificMediator2.
/**
* Setting property of BeanMediator and asserting the action.
*
* @throws XMLStreamException - XMLStreamException.
*/
@Test
public void testCreateSpecificMediator2() throws XMLStreamException {
BeanMediatorFactory beanMediatorFactory = new BeanMediatorFactory();
String inputXML = "<bean action=\"SET_PROPERTY\" property=\"latitude\" value=\"{//latitude}\" var=\"loc\" " + "xmlns:ns3=\"http://org.apache.synapse/xsd\" " + "xmlns:ns=\"http://org.apache.synapse/xsd\"></bean>\n";
OMElement element = AXIOMUtil.stringToOM(inputXML);
Mediator mediator = beanMediatorFactory.createSpecificMediator(element, null);
Assert.assertTrue("BeanMediator is not created successfully.", mediator instanceof BeanMediator);
BeanMediator beanMediator = (BeanMediator) mediator;
Assert.assertEquals("SET_PROPERTY action is not set", BeanMediator.Action.SET_PROPERTY, beanMediator.getAction());
}
Aggregations