Search in sources :

Example 6 with AddressEndpoint

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

the class SALSessionsTest method testUpdateWithOldSessionSameName.

/**
 * Test updating session with session id and old session where the old session id is same as current session id
 * @throws Exception
 */
@Test
public void testUpdateWithOldSessionSameName() throws Exception {
    BasicConfigurator.configure();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment);
    MessageContext messageContext = axis2MessageContext;
    Endpoint endpoint = new AddressEndpoint();
    List<Endpoint> endpoints = new ArrayList<>();
    endpoints.add(endpoint);
    messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints);
    SALSessions salSessions = SALSessions.getInstance();
    salSessions.initialize(false, cfgCtx);
    SessionInformation oldSessionInfo = new SessionInformation("testSession3", endpoints, 30000);
    messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo);
    salSessions.updateSession(messageContext, "testSession3");
    SessionInformation sessionInformation = salSessions.getSession("testSession3");
    Assert.assertEquals("Session not updated!", "testSession3", sessionInformation.getId());
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) ArrayList(java.util.ArrayList) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Test(org.junit.Test)

Example 7 with AddressEndpoint

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

the class SALSessionsTest method testUpdateWithOldSession.

/**
 * Test updating session with session id and old session
 * @throws Exception
 */
@Test
public void testUpdateWithOldSession() throws Exception {
    BasicConfigurator.configure();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment);
    MessageContext messageContext = axis2MessageContext;
    Endpoint endpoint = new AddressEndpoint();
    List<Endpoint> endpoints = new ArrayList<>();
    endpoints.add(endpoint);
    SALSessions salSessions = SALSessions.getInstance();
    salSessions.initialize(false, cfgCtx);
    SessionInformation oldSessionInfo = new SessionInformation("oldTestSession", endpoints, 30000);
    messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo);
    salSessions.updateSession(messageContext, "testSession2");
    SessionInformation sessionInformation = salSessions.getSession("testSession2");
    Assert.assertEquals("Session not updated!", "testSession2", sessionInformation.getId());
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) ArrayList(java.util.ArrayList) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Test(org.junit.Test)

Example 8 with AddressEndpoint

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

the class SALSessionsTest method testUpdateWithId.

/**
 * Test updating session with session id
 * @throws Exception
 */
@Test
public void testUpdateWithId() throws Exception {
    BasicConfigurator.configure();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration);
    SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration);
    Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment);
    MessageContext messageContext = axis2MessageContext;
    Endpoint endpoint = new AddressEndpoint();
    List<Endpoint> endpoints = new ArrayList<>();
    endpoints.add(endpoint);
    messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints);
    SALSessions salSessions = SALSessions.getInstance();
    salSessions.initialize(false, cfgCtx);
    salSessions.updateSession(messageContext, "testSession");
    SessionInformation sessionInformation = salSessions.getSession("testSession");
    Assert.assertEquals("Session not updated!", "testSession", sessionInformation.getId());
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) SynapseEnvironment(org.apache.synapse.core.SynapseEnvironment) ArrayList(java.util.ArrayList) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Axis2SynapseEnvironment(org.apache.synapse.core.axis2.Axis2SynapseEnvironment) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) Endpoint(org.apache.synapse.endpoints.Endpoint) MessageContext(org.apache.synapse.MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext) Test(org.junit.Test)

Example 9 with AddressEndpoint

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

the class SynapseXMLConfigurationSerializerTest method testSerializeConfiguration6.

/**
 * Test serializeConfigurationMethod with Endpoint added for SynapseConfiguration and assert OMElement returned
 */
@Test
public void testSerializeConfiguration6() {
    SynapseXMLConfigurationSerializer serializer = new SynapseXMLConfigurationSerializer();
    SynapseConfiguration synapseConfiguration = new SynapseConfiguration();
    AddressEndpoint endpoint = new AddressEndpoint();
    EndpointDefinition definition = new EndpointDefinition();
    definition.setAddress("testUrl");
    endpoint.setName("testEndpoint");
    endpoint.setDefinition(definition);
    synapseConfiguration.addEndpoint(endpoint.getName(), endpoint);
    OMElement element = serializer.serializeConfiguration(synapseConfiguration);
    Assert.assertNotNull("OMElement is not returned", element);
    Assert.assertEquals("definitions", element.getLocalName());
    Assert.assertTrue("Endpoint added is not serialized.", element.getChildren().next().toString().contains("name=\"testEndpoint\""));
}
Also used : AddressEndpoint(org.apache.synapse.endpoints.AddressEndpoint) EndpointDefinition(org.apache.synapse.endpoints.EndpointDefinition) OMElement(org.apache.axiom.om.OMElement) SynapseConfiguration(org.apache.synapse.config.SynapseConfiguration) Test(org.junit.Test)

Example 10 with AddressEndpoint

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

the class AddressEndpointSerializationTest method testAddressEndpointScenarioTwo.

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

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