use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class PayloadFactoryMediatorSerializerTest method testSerializeSpecificMediator5.
/**
* Test SerializeSpecificMediator method with PathArgument with expression added for payloadFactory mediator
* and assert that expression is added.
*/
@Test
public void testSerializeSpecificMediator5() throws JaxenException {
PayloadFactoryMediatorSerializer serializer = new PayloadFactoryMediatorSerializer();
PayloadFactoryMediator payloadFactoryMediator = new PayloadFactoryMediator();
Argument argument = new Argument();
argument.setExpression(new SynapseXPath("//name"));
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("Expression added for path argument is not serialized", "//name", ((PayloadFactoryMediator) mediator).getPathArgumentList().get(0).getExpression().toString());
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class AbstractTestCase method serialization.
protected boolean serialization(String inputXml, MediatorSerializer mediatorSerializer) {
OMElement inputOM = createOMElement(inputXml);
Mediator mediator = MediatorFactoryFinder.getInstance().getMediator(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 testCreateSpecificMediator.
/**
* Creating a bean mediator and asserting it is created successfully.
*
* @throws XMLStreamException - XMLStreamException.
*/
@Test
public void testCreateSpecificMediator() throws XMLStreamException {
BeanMediatorFactory beanMediatorFactory = new BeanMediatorFactory();
String inputXML = "<bean action=\"CREATE\" class=\"org.apache.synapse.util.TestTask\" " + "var=\"loc\"></bean>";
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("CREATE action is not set", BeanMediator.Action.CREATE, beanMediator.getAction());
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class BeanMediatorFactoryTest method testCreateSpecificMediator4.
/**
* Removing the property of BeanMediator and asserting the action.
*
* @throws XMLStreamException - XMLStreamException.
*/
@Test
public void testCreateSpecificMediator4() throws XMLStreamException {
BeanMediatorFactory beanMediatorFactory = new BeanMediatorFactory();
String inputXML = "<bean action=\"REMOVE\" 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("REMOVE action is not set", BeanMediator.Action.REMOVE, beanMediator.getAction());
}
use of org.apache.synapse.Mediator in project wso2-synapse by wso2.
the class EJBMediatorFactoryTest method testCreateSpecificMediator.
/**
* Test createSpecificMediator method and checked the returned mediator benStalkName.
*
* @throws XMLStreamException - XMLStreamException
*/
@Test
public void testCreateSpecificMediator() throws XMLStreamException {
EJBMediatorFactory factory = new EJBMediatorFactory();
String inputXML = "<ejb xmlns=\"http://ws.apache.org/ns/synapse\" beanstalk=\"jack\" class=\"org.apache.synapse" + ".mediators.bean.enterprise.EJBMediator\" method=\"setMethod\" target=\"store\" " + "jndiName=\"ejb:/EJBDemo/StoreRegisterBean!org.ejb.wso2.test.StoreRegister\">" + "<args><arg value=\"{get-property('loc_id')}\"/></args></ejb>";
OMElement inputElement = AXIOMUtil.stringToOM(inputXML);
Mediator mediator = factory.createSpecificMediator(inputElement, null);
EJBMediatorSerializer serializer = new EJBMediatorSerializer();
OMElement outputElement = serializer.serializeSpecificMediator(mediator);
Assert.assertEquals("EJB Mediator with beanstalk name jack is not returned", "jack", ((EJBMediator) mediator).getBeanstalkName());
Assert.assertTrue("Input XML and serialized output XMLs are not same", compare(inputElement, outputElement));
}
Aggregations