use of org.apache.synapse.mediators.builtin.CallMediator in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testSimpleFailoverCallSerialization.
public void testSimpleFailoverCallSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<failover>" + "<endpoint>" + "<address uri=\"http://localhost:9001/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9002/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9003/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "</failover>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a failover endpoint.", call2.getEndpoint() instanceof FailoverEndpoint);
FailoverEndpoint endpoint = (FailoverEndpoint) call2.getEndpoint();
List addresses = endpoint.getChildren();
assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(0) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(1) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(2) instanceof AddressEndpoint);
AddressEndpoint addressEndpoint = (AddressEndpoint) addresses.get(0);
assertTrue("URI of address endpoint is not serialized properly", "http://localhost:9001/services/Service1".equals(addressEndpoint.getDefinition().getAddress()));
}
use of org.apache.synapse.mediators.builtin.CallMediator in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testSimpleLoadbalanceCallSerialization.
public void testSimpleLoadbalanceCallSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<loadbalance>" + "<endpoint>" + "<address uri=\"http://localhost:9001/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9002/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9003/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "</loadbalance>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a load balance endpoint.", call2.getEndpoint() instanceof LoadbalanceEndpoint);
LoadbalanceEndpoint endpoint = (LoadbalanceEndpoint) call2.getEndpoint();
List addresses = endpoint.getChildren();
assertEquals("There should be 3 leaf level address endpoints", addresses.size(), 3);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(0) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(1) instanceof AddressEndpoint);
assertTrue("Leaf level endpoints should be address endpoints", addresses.get(2) instanceof AddressEndpoint);
AddressEndpoint addressEndpoint = (AddressEndpoint) addresses.get(0);
assertTrue("URI of address endpoint is not serialized properly", "http://localhost:9001/services/Service1".equals(addressEndpoint.getDefinition().getAddress()));
}
use of org.apache.synapse.mediators.builtin.CallMediator in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testWSDLEndpointSerialization.
public void testWSDLEndpointSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<wsdl uri='file:src/test/resources/esbservice.wsdl' service='esbservice' port='esbserviceSOAP11port_http'>" + "<enableAddressing/>" + "</wsdl>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a WSDL endpoint.", call1.getEndpoint() instanceof WSDLEndpoint);
WSDLEndpoint ep1 = (WSDLEndpoint) call1.getEndpoint();
assertTrue("Top level endpoint should be a WSDL endpoint.", call2.getEndpoint() instanceof WSDLEndpoint);
WSDLEndpoint ep2 = (WSDLEndpoint) call2.getEndpoint();
assertEquals("Service name is not serialized properly.", ep1.getServiceName(), ep2.getServiceName());
assertEquals("Port name is not serialized properly", ep1.getPortName(), ep2.getPortName());
assertEquals("WSDL URI is not serialized properly", ep1.getWsdlURI(), ep2.getWsdlURI());
assertEquals("Addressing information is not serialized properly", ep1.getDefinition().isAddressingOn(), ep2.getDefinition().isAddressingOn());
}
use of org.apache.synapse.mediators.builtin.CallMediator in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testBlockingAttributeSerialization.
public void testBlockingAttributeSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\" blocking=\"true\">" + "<endpoint>" + "<address uri='http://localhost:9000/services/MyService1'>" + "<enableAddressing/>" + "<timeout>" + "<duration>60</duration>" + "<responseAction>discard</responseAction>" + "</timeout>" + "</address>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("blocking attribute is not serialized properly - probably an issue in factory", call1.isBlocking());
assertTrue("blocking attribute is not serialized properly", call2.isBlocking());
}
use of org.apache.synapse.mediators.builtin.CallMediator in project wso2-synapse by wso2.
the class CallMediatorSerializationTest method testNestedLoadbalanceFailoverCallSerialization.
public void testNestedLoadbalanceFailoverCallSerialization() {
String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<loadbalance>" + "<endpoint>" + "<address uri=\"http://localhost:9001/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<failover>" + "<endpoint>" + "<address uri=\"http://localhost:9002/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9003/services/Service1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "</failover>" + "</endpoint>" + "</loadbalance>" + "</endpoint>" + "</call>";
OMElement config1 = createOMElement(callConfig);
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, call1);
CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a load balance endpoint.", call2.getEndpoint() instanceof LoadbalanceEndpoint);
LoadbalanceEndpoint loadbalanceEndpoint = (LoadbalanceEndpoint) call2.getEndpoint();
List children = loadbalanceEndpoint.getChildren();
assertEquals("Top level endpoint should have 2 child endpoints.", children.size(), 2);
assertTrue("First child should be a address endpoint", children.get(0) instanceof AddressEndpoint);
assertTrue("Second child should be a fail over endpoint", children.get(1) instanceof FailoverEndpoint);
FailoverEndpoint failoverEndpoint = (FailoverEndpoint) children.get(1);
List children2 = failoverEndpoint.getChildren();
assertEquals("Fail over endpoint should have 2 children.", children2.size(), 2);
assertTrue("Children of the fail over endpoint should be address endpoints.", children2.get(0) instanceof AddressEndpoint);
assertTrue("Children of the fail over endpoint should be address endpoints.", children2.get(1) instanceof AddressEndpoint);
}
Aggregations