use of org.apache.synapse.mediators.bean.BeanMediator 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());
}
use of org.apache.synapse.mediators.bean.BeanMediator in project wso2-synapse by wso2.
the class BeanMediatorFactoryTest method testCreateSpecificMediator3.
/**
* Getting the property of BeanMediator and asserting the action.
*
* @throws XMLStreamException - XMLStreamException.
*/
@Test
public void testCreateSpecificMediator3() throws XMLStreamException {
BeanMediatorFactory beanMediatorFactory = new BeanMediatorFactory();
String inputXML = "<bean action=\"GET_PROPERTY\" property=\"latitude\" value=\"{//latitude}\" var=\"loc\" " + "target=\"target\" 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("GET_PROPERTY action is not set", BeanMediator.Action.GET_PROPERTY, beanMediator.getAction());
}
use of org.apache.synapse.mediators.bean.BeanMediator in project wso2-synapse by wso2.
the class BeanMediatorSerializerTest method testSerializeSpecificMediator3.
/**
* Test serializeSpecificMediator with GET_PROPERTY action and assert the action.
*/
@Test
public void testSerializeSpecificMediator3() {
BeanMediatorSerializer beanMediatorSerializer = new BeanMediatorSerializer();
BeanMediator mediator = new BeanMediator();
mediator.setAction(BeanMediator.Action.GET_PROPERTY);
mediator.setVarName("loc");
mediator.setPropertyName("testProperty");
Target target = new Target("attr", TestUtils.createOMElement("<target attr=\"testTarget\">"));
mediator.setTarget(target);
OMElement element = beanMediatorSerializer.serializeSpecificMediator(mediator);
Assert.assertEquals("GET_PROPERTY action is not performed", "GET_PROPERTY", element.getAttributeValue(new QName(BeanConstants.ACTION)));
}
use of org.apache.synapse.mediators.bean.BeanMediator in project wso2-synapse by wso2.
the class BeanMediatorSerializerTest method testSerializeSpecificMediator4.
/**
* Test serializeSpecificMediator with no action specified.
*/
@Test(expected = SynapseException.class)
public void testSerializeSpecificMediator4() {
BeanMediatorSerializer beanMediatorSerializer = new BeanMediatorSerializer();
BeanMediator mediator = new BeanMediator();
beanMediatorSerializer.serializeSpecificMediator(mediator);
}
use of org.apache.synapse.mediators.bean.BeanMediator in project wso2-synapse by wso2.
the class BeanMediatorSerializerTest method testSerializeSpecificMediator.
/**
* Test serializeSpecificMediator with CREATE action and assert the action.
*/
@Test
public void testSerializeSpecificMediator() {
BeanMediatorSerializer beanMediatorSerializer = new BeanMediatorSerializer();
BeanMediator mediator = new BeanMediator();
mediator.setAction(BeanMediator.Action.CREATE);
mediator.setVarName("loc");
mediator.setClazz(MockBean.class);
OMElement element = beanMediatorSerializer.serializeSpecificMediator(mediator);
Assert.assertEquals("CREATE action is not performed", "CREATE", element.getAttributeValue(new QName(BeanConstants.ACTION)));
}
Aggregations