Search in sources :

Example 61 with Endpoint

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

the class SALSessionsTest method testUpdateCookieWithOldSession.

/**
 * Test updating session with cookie and old session
 * @throws Exception
 */
@Test
public void testUpdateCookieWithOldSession() 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);
    List<String> path = new ArrayList<>();
    path.add("samplePath");
    oldSessionInfo.setPath(path);
    messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo);
    SessionCookie sessionCookie = new SessionCookie();
    sessionCookie.setSessionId("testCookie2");
    sessionCookie.setPath("samplePath");
    salSessions.updateSession(messageContext, sessionCookie);
    SessionInformation sessionInformation = salSessions.getSession("testCookie2");
    Assert.assertEquals("Session not updated!", "testCookie2", 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 62 with Endpoint

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

the class SALSessionsTest method testUpdateCookieWithOldSessionSameName.

/**
 * Test updating session with cookie and old session where the old session id is same as current session id
 * @throws Exception
 */
@Test
public void testUpdateCookieWithOldSessionSameName() 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("testCookie3", endpoints, 30000);
    List<String> path = new ArrayList<>();
    path.add("samplePath");
    oldSessionInfo.setPath(path);
    messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo);
    SessionCookie sessionCookie = new SessionCookie();
    sessionCookie.setSessionId("testCookie3");
    sessionCookie.setPath("samplePath");
    salSessions.updateSession(messageContext, sessionCookie);
    SessionInformation sessionInformation = salSessions.getSession("testCookie3");
    Assert.assertEquals("Session not updated!", "testCookie3", 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 63 with Endpoint

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

the class SALSessionsTest method testUpdateWithCookie.

/**
 * Test updating session with cookie
 * @throws Exception
 */
@Test
public void testUpdateWithCookie() 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);
    SessionCookie sessionCookie = new SessionCookie();
    sessionCookie.setSessionId("testCookie");
    salSessions.updateSession(messageContext, sessionCookie);
    SessionInformation sessionInformation = salSessions.getSession("testCookie");
    Assert.assertEquals("Session not updated!", "testCookie", 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 64 with Endpoint

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

the class LoadBalanceEndpointSerializationTest method testLoadBalanceEndpointScenarioOne.

public void testLoadBalanceEndpointScenarioOne() throws Exception {
    String inputXml = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<session type=\"simpleClientSession\"/>" + "<loadbalance algorithm=\"org.apache.synapse.endpoints.algorithms.RoundRobin\">" + "<endpoint>" + "<address uri=\"http://localhost:9001/soap/LBService1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9002/soap/LBService1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "<endpoint>" + "<address uri=\"http://localhost:9003/soap/LBService1\">" + "<enableAddressing/>" + "</address>" + "</endpoint>" + "</loadbalance>" + "</endpoint>";
    OMElement inputElement = createOMElement(inputXml);
    Endpoint endpoint = LoadbalanceEndpointFactory.getEndpointFromElement(inputElement, true, null);
    OMElement serializedOut = LoadbalanceEndpointSerializer.getElementFromEndpoint(endpoint);
    assertTrue(compare(serializedOut, inputElement));
}
Also used : Endpoint(org.apache.synapse.endpoints.Endpoint) OMElement(org.apache.axiom.om.OMElement)

Aggregations

Endpoint (org.apache.synapse.endpoints.Endpoint)64 OMElement (org.apache.axiom.om.OMElement)22 SynapseException (org.apache.synapse.SynapseException)13 AddressEndpoint (org.apache.synapse.endpoints.AddressEndpoint)13 SequenceMediator (org.apache.synapse.mediators.base.SequenceMediator)11 ArrayList (java.util.ArrayList)10 MessageContext (org.apache.synapse.MessageContext)9 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)8 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)8 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)8 IndirectEndpoint (org.apache.synapse.endpoints.IndirectEndpoint)8 SALoadbalanceEndpoint (org.apache.synapse.endpoints.SALoadbalanceEndpoint)8 InboundEndpoint (org.apache.synapse.inbound.InboundEndpoint)8 OMAttribute (org.apache.axiom.om.OMAttribute)7 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)7 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)7 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)7 QName (javax.xml.namespace.QName)6 AbstractEndpoint (org.apache.synapse.endpoints.AbstractEndpoint)6 DynamicLoadbalanceEndpoint (org.apache.synapse.endpoints.DynamicLoadbalanceEndpoint)6