use of org.apache.synapse.endpoints.FailoverEndpoint in project wso2-synapse by wso2.
the class FailoverEndpointSerializer method serializeEndpoint.
protected OMElement serializeEndpoint(Endpoint endpoint) {
if (!(endpoint instanceof FailoverEndpoint)) {
handleException("Invalid endpoint type.");
}
FailoverEndpoint failoverEndpoint = (FailoverEndpoint) endpoint;
fac = OMAbstractFactory.getOMFactory();
OMElement endpointElement = fac.createOMElement("endpoint", SynapseConstants.SYNAPSE_OMNAMESPACE);
OMElement failoverElement = fac.createOMElement("failover", SynapseConstants.SYNAPSE_OMNAMESPACE);
endpointElement.addChild(failoverElement);
serializeCommonAttributes(endpoint, endpointElement);
if (failoverEndpoint.isBuildMessageAtt()) {
failoverElement.addAttribute(XMLConfigConstants.BUILD_MESSAGE, Boolean.toString(failoverEndpoint.isBuildMessageAtt()), null);
}
for (Endpoint childEndpoint : failoverEndpoint.getChildren()) {
failoverElement.addChild(EndpointSerializer.getElementFromEndpoint(childEndpoint));
}
if (!failoverEndpoint.isDynamic()) {
failoverElement.addAttribute("dynamic", "false", null);
}
// serialize the parameters
serializeProperties(failoverEndpoint, endpointElement);
return endpointElement;
}
use of org.apache.synapse.endpoints.FailoverEndpoint in project wso2-synapse by wso2.
the class SendMediatorSerializationTest method testNestedLoadbalanceFailoverSendSerialization.
public void testNestedLoadbalanceFailoverSendSerialization() {
String sendConfig = "<send 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>" + "</send>";
OMElement config1 = createOMElement(sendConfig);
SendMediator send1 = (SendMediator) factory.createMediator(config1, new Properties());
OMElement config2 = serializer.serializeMediator(null, send1);
SendMediator send2 = (SendMediator) factory.createMediator(config2, new Properties());
assertTrue("Top level endpoint should be a load balance endpoint.", send2.getEndpoint() instanceof LoadbalanceEndpoint);
LoadbalanceEndpoint loadbalanceEndpoint = (LoadbalanceEndpoint) send2.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