use of org.apache.synapse.endpoints.AddressEndpoint 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());
}
use of org.apache.synapse.endpoints.AddressEndpoint 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());
}
use of org.apache.synapse.endpoints.AddressEndpoint 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());
}
use of org.apache.synapse.endpoints.AddressEndpoint in project wso2-synapse by wso2.
the class DynamicEndpointTest method testContextProperties.
public void testContextProperties() throws Exception {
SynapseXPath xpath = new SynapseXPath("$ctx:timeout");
AbstractEndpoint endpoint = new AddressEndpoint();
EndpointDefinition definition = new EndpointDefinition();
endpoint.setDefinition(definition);
definition.setDynamicTimeoutExpression(xpath);
MessageContext synCtx = new TestMessageContext();
synCtx.setProperty("timeout", "90000");
assertEquals(Long.valueOf((String) xpath.evaluate(synCtx)).longValue(), endpoint.getDefinition().evaluateDynamicEndpointTimeout(synCtx));
}
Aggregations