Search in sources :

Example 1 with SendMediator

use of org.apache.synapse.mediators.builtin.SendMediator in project wso2-synapse by wso2.

the class SendMediatorSerializationTest method testWSDLEndpointSerialization.

public void testWSDLEndpointSerialization() {
    String sendConfig = "<send xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<wsdl uri='file:src/test/resources/esbservice.wsdl' service='esbservice' port='esbserviceSOAP11port_http'>" + "<enableAddressing/>" + "</wsdl>" + "</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 WSDL endpoint.", send1.getEndpoint() instanceof WSDLEndpoint);
    WSDLEndpoint ep1 = (WSDLEndpoint) send1.getEndpoint();
    assertTrue("Top level endpoint should be a WSDL endpoint.", send2.getEndpoint() instanceof WSDLEndpoint);
    WSDLEndpoint ep2 = (WSDLEndpoint) send2.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());
}
Also used : WSDLEndpoint(org.apache.synapse.endpoints.WSDLEndpoint) OMElement(org.apache.axiom.om.OMElement) SendMediator(org.apache.synapse.mediators.builtin.SendMediator) Properties(java.util.Properties)

Example 2 with SendMediator

use of org.apache.synapse.mediators.builtin.SendMediator 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 3 with SendMediator

use of org.apache.synapse.mediators.builtin.SendMediator 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 4 with SendMediator

use of org.apache.synapse.mediators.builtin.SendMediator in project wso2-synapse by wso2.

the class SendMediatorSerializationTest method testBuildMessageBeforeSentSerialization.

public void testBuildMessageBeforeSentSerialization() {
    String sendConfig = "<send buildmessage=\"true\" xmlns=\"http://ws.apache.org/ns/synapse\" />";
    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());
    assertEquals("buildmessage attribute is not serialized properly", send1.isBuildMessage(), send2.isBuildMessage());
}
Also used : OMElement(org.apache.axiom.om.OMElement) SendMediator(org.apache.synapse.mediators.builtin.SendMediator) Properties(java.util.Properties)

Example 5 with SendMediator

use of org.apache.synapse.mediators.builtin.SendMediator 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

SendMediator (org.apache.synapse.mediators.builtin.SendMediator)9 OMElement (org.apache.axiom.om.OMElement)8 Properties (java.util.Properties)6 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)4 List (java.util.List)3 Endpoint (org.apache.synapse.endpoints.Endpoint)2 FailoverEndpoint (org.apache.synapse.endpoints.FailoverEndpoint)2 LoadbalanceEndpoint (org.apache.synapse.endpoints.LoadbalanceEndpoint)2 Value (org.apache.synapse.mediators.Value)2 WSDLEndpoint (org.apache.synapse.endpoints.WSDLEndpoint)1 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)1 LogMediator (org.apache.synapse.mediators.builtin.LogMediator)1 InMediator (org.apache.synapse.mediators.filters.InMediator)1 OutMediator (org.apache.synapse.mediators.filters.OutMediator)1