Search in sources :

Example 11 with AddressEndpoint

use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.

the class AddressEndpointSerializationTest method testAddressEndpointScenarioOne.

public void testAddressEndpointScenarioOne() throws Exception {
    String inputXML = "<endpoint  xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" />" + "</endpoint>";
    OMElement inputElement = createOMElement(inputXML);
    AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement(inputElement, true, null);
    OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint);
    assertTrue(compare(serializedOut, inputElement));
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) OMElement(org.apache.axiom.om.OMElement)

Example 12 with AddressEndpoint

use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.

the class AddressEndpointSerializationTest method testAddressEndpointScenarioThree.

public void testAddressEndpointScenarioThree() throws Exception {
    String inputXML = "<endpoint  xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "<markForSuspension>" + "<errorCodes>101507,101508</errorCodes>" + "<retriesBeforeSuspension>3</retriesBeforeSuspension>" + "<retryDelay>1000</retryDelay>" + "</markForSuspension>" + "<suspendOnFailure>" + "<errorCodes>101505,101506</errorCodes>" + "<initialDuration>5000</initialDuration>" + "<progressionFactor>2.0</progressionFactor>" + "<maximumDuration>60000</maximumDuration>" + "</suspendOnFailure>" + "<retryConfig>" + "<disabledErrorCodes>101501,101502</disabledErrorCodes>" + "</retryConfig>" + "</address>" + "</endpoint>";
    OMElement inputElement = createOMElement(inputXML);
    AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement(inputElement, true, null);
    OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint);
    assertTrue(compare(serializedOut, inputElement));
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) OMElement(org.apache.axiom.om.OMElement)

Example 13 with AddressEndpoint

use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.

the class SendMediatorSerializationTest method testSimpleFailoverSendSerialization.

public void testSimpleFailoverSendSerialization() {
    String sendConfig = "<send 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>" + "</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 failover endpoint.", send2.getEndpoint() instanceof FailoverEndpoint);
    FailoverEndpoint endpoint = (FailoverEndpoint) send2.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()));
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) OMElement(org.apache.axiom.om.OMElement) List(java.util.List) SendMediator(org.apache.synapse.mediators.builtin.SendMediator) Properties(java.util.Properties) FailoverEndpoint(org.apache.synapse.endpoints.FailoverEndpoint)

Example 14 with AddressEndpoint

use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.

the class SendMediatorSerializationTest method testAddressEndpointSerialization.

public void testAddressEndpointSerialization() {
    String sendConfig = "<send xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<address uri='http://localhost:9000/services/MyService1'>" + "<enableAddressing/>" + "<timeout>" + "<duration>60</duration>" + "<responseAction>discard</responseAction>" + "</timeout>" + "</address>" + "</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 address endpoint.", send1.getEndpoint() instanceof AddressEndpoint);
    AddressEndpoint ep1 = (AddressEndpoint) send1.getEndpoint();
    assertTrue("Top level endpoint should be a WSDL endpoint.", send2.getEndpoint() instanceof AddressEndpoint);
    AddressEndpoint ep2 = (AddressEndpoint) send2.getEndpoint();
    assertEquals("Address URI is not serialized properly", ep1.getDefinition().getAddress(), ep2.getDefinition().getAddress());
    assertEquals("Addressing information is not serialized properly", ep1.getDefinition().isAddressingOn(), ep2.getDefinition().isAddressingOn());
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) OMElement(org.apache.axiom.om.OMElement) SendMediator(org.apache.synapse.mediators.builtin.SendMediator) Properties(java.util.Properties)

Example 15 with AddressEndpoint

use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.

the class SendMediatorSerializationTest method testSimpleLoadbalanceSendSerialization.

public void testSimpleLoadbalanceSendSerialization() {
    String sendConfig = "<send 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>" + "</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 endpoint = (LoadbalanceEndpoint) send2.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()));
}
Also used : LoadbalanceEndpoint(org.apache.synapse.endpoints.LoadbalanceEndpoint) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) OMElement(org.apache.axiom.om.OMElement) List(java.util.List) SendMediator(org.apache.synapse.mediators.builtin.SendMediator) Properties(java.util.Properties)

Aggregations

AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)34 OMElement (org.apache.axiom.om.OMElement)17 Endpoint (org.apache.synapse.endpoints.Endpoint)12 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)10 MessageContext (org.apache.synapse.MessageContext)10 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)10 EndpointDefinition (org.apache.synapse.endpoints.EndpointDefinition)10 Properties (java.util.Properties)8 ArrayList (java.util.ArrayList)7 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)7 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)7 Test (org.junit.Test)7 List (java.util.List)6 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)6 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)6 LoadbalanceEndpoint (org.apache.synapse.endpoints.LoadbalanceEndpoint)6 SynapseException (org.apache.synapse.SynapseException)5 FailoverEndpoint (org.apache.synapse.endpoints.FailoverEndpoint)4 CallMediator (org.apache.synapse.mediators.builtin.CallMediator)4 SendMediator (org.apache.synapse.mediators.builtin.SendMediator)4