use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.
the class RecipientListEndpointTest method getMockedSynapseEnvironment.
/**
* Create a mock SynapseEnvironment object
*
* @return Axis2SynapseEnvironment instance
* @throws AxisFault on creating/mocking object
*/
private Axis2SynapseEnvironment getMockedSynapseEnvironment() throws AxisFault {
Axis2SynapseEnvironment synapseEnvironment = PowerMockito.mock(Axis2SynapseEnvironment.class);
ConfigurationContext axis2ConfigurationContext = new ConfigurationContext(new AxisConfiguration());
Mockito.when(synapseEnvironment.getAxis2ConfigurationContext()).thenReturn(axis2ConfigurationContext);
return synapseEnvironment;
}
use of org.apache.axis2.context.ConfigurationContext 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 {
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());
}
use of org.apache.axis2.context.ConfigurationContext 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 {
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());
}
use of org.apache.axis2.context.ConfigurationContext 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 {
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());
}
use of org.apache.axis2.context.ConfigurationContext in project wso2-synapse by wso2.
the class OAuthUtilsTest method createMessageContext.
/**
* Create a empty message context
*
* @return A context with empty message
* @throws AxisFault on an error creating a context
*/
private static MessageContext createMessageContext() throws AxisFault {
Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration());
org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext();
axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration()));
ServiceContext svcCtx = new ServiceContext();
OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx);
axis2MC.setServiceContext(svcCtx);
axis2MC.setOperationContext(opCtx);
axis2MC.setTransportIn(new TransportInDescription("http"));
MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment);
mc.setMessageID(UIDGenerator.generateURNString());
mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope());
mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody());
return mc;
}
Aggregations