use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class XFormURLEncodedBuilderTest method testProcessDocumentPostMethod.
/**
* Test XFormURLEncodedBuilder with HTTP POST method
* @throws AxisFault
*/
public void testProcessDocumentPostMethod() throws AxisFault {
String expectedSoapEnvelope = "<?xml version='1.0' encoding='utf-8'?>" + "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" + "<soapenv:Body>" + "<xformValues>" + "<price>10</price>" + "<symbol>WSO2</symbol>" + "</xformValues>" + "</soapenv:Body>" + "</soapenv:Envelope>";
String expectedSoapEnvelope2 = "<?xml version='1.0' encoding='utf-8'?>" + "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">" + "<soapenv:Body>" + "<xformValues>" + "<symbol>WSO2</symbol>" + "<price>10</price>" + "</xformValues>" + "</soapenv:Body>" + "</soapenv:Envelope>";
MessageContext messageContext = Util.newMessageContext();
messageContext.setTo(new EndpointReference("http://localhost:9000/stockquote/test?symbol=WSO2&price=10"));
messageContext.setProperty(HTTPConstants.HTTP_METHOD, "POST");
XFormURLEncodedBuilder urlEncodedBuilder = new XFormURLEncodedBuilder();
OMElement element = urlEncodedBuilder.processDocument(null, "", messageContext);
boolean assertion = expectedSoapEnvelope.equals(element.toString()) || expectedSoapEnvelope2.equals(element.toString());
assertTrue("Invalid SOAPEnvelope received", assertion);
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class ContextAwareLoggerTest method testGetMDCAwareLogger.
public void testGetMDCAwareLogger() {
// Not removing from mdc after logging
// Axis2 Message Context
MessageContext messageContext = getCorrelationIdAwareAxis2Context();
ContextAwareLogger.setCorrelationLoggingEnabled(true);
Log contextAwareLogger = ContextAwareLogger.getLogger(messageContext, log, false);
validateMDCAwareLogger(contextAwareLogger);
// HTTPContext
HttpContext httpContext = getCorrelationIdAwareHTTPContext();
contextAwareLogger = ContextAwareLogger.getLogger(httpContext, log, false);
validateMDCAwareLogger(contextAwareLogger);
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class ContextAwareLoggerTest method testGetMDCImmediateLogger.
public void testGetMDCImmediateLogger() {
// Removing from mdc after logging
// Axis2 MessageContext
MessageContext messageContext = getCorrelationIdAwareAxis2Context();
ContextAwareLogger.setCorrelationLoggingEnabled(true);
Log contextAwareLogger = ContextAwareLogger.getLogger(messageContext, log, true);
validateMDCImmediateLogger(contextAwareLogger);
// HTTP Context
HttpContext httpContext = getCorrelationIdAwareHTTPContext();
contextAwareLogger = ContextAwareLogger.getLogger(httpContext, log, true);
validateMDCImmediateLogger(contextAwareLogger);
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class ContextAwareLoggerTest method testLogWarnForMDCImmediateLogger.
public void testLogWarnForMDCImmediateLogger() {
String logMessage = "Testing WARN log For CorrelationMDCImmediateLogger";
HttpContext httpContext = getCorrelationIdAwareHTTPContext();
Log contextAwareLogger = ContextAwareLogger.getLogger(httpContext, log, true);
contextAwareLogger.info(logMessage);
validateMDCPropertyForMDCImmediateLogger();
MessageContext messageContext = getCorrelationIdAwareAxis2Context();
contextAwareLogger = ContextAwareLogger.getLogger(messageContext, log, true);
contextAwareLogger.warn(logMessage);
validateMDCPropertyForMDCImmediateLogger();
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class ContextAwareLoggerTest method testLogInfoForMDCAwareLogger.
public void testLogInfoForMDCAwareLogger() {
String logMessage = "Testing INFO log For CorrelationMDCAwareLogger";
HttpContext httpContext = getCorrelationIdAwareHTTPContext();
Log contextAwareLogger = ContextAwareLogger.getLogger(httpContext, log, false);
contextAwareLogger.info(logMessage);
validateMDCPropertyForMDCAwareLogger();
MessageContext messageContext = getCorrelationIdAwareAxis2Context();
contextAwareLogger = ContextAwareLogger.getLogger(messageContext, log, false);
contextAwareLogger.info(logMessage);
validateMDCPropertyForMDCAwareLogger();
}
Aggregations