use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class ContextAwareLoggerTest method testLogInfoForMDCImmediateLogger.
public void testLogInfoForMDCImmediateLogger() {
String logMessage = "Testing INFO 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.info(logMessage);
validateMDCPropertyForMDCImmediateLogger();
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class ContextAwareLoggerTest method getCorrelationIdAwareAxis2Context.
private MessageContext getCorrelationIdAwareAxis2Context() {
MessageContext messageContext = new MessageContext();
messageContext.setProperty(CorrelationConstants.CORRELATION_ID, correlationId);
return messageContext;
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class JsonFormatterTest method testWriteTo.
public void testWriteTo() throws AxisFault, XMLStreamException {
JsonFormatter formatter = new JsonFormatter();
MessageContext messageContext = Util.newMessageContext("<jsonArray><jsonElement>10</jsonElement><jsonElement>20</jsonElement></jsonArray>");
OutputStream out = new ByteArrayOutputStream();
formatter.writeTo(messageContext, null, out, true);
assertEquals("Formatter output is invalid", "[10,20]", out.toString());
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class JsonFormatterTest method testCase.
/**
* NOTE: Under this test class, we cannot test the creation of JSON arrays by giving xml processing instructions to the
* xml input string object. The reason is that when doing stringToOm and setting the SOAP child with addChild() method,
* the addChild() method throws an exception saying that it does not support the xml PI node type.
*/
public void testCase() {
try {
InputStream inputStream = Util.getJson(0);
MessageFormatter formatter = Util.newJsonFormatter();
MessageContext messageContext = Util.newMessageContext();
JsonUtil.getNewJsonPayload(messageContext, inputStream, false, false);
OutputStream out = Util.newOutputStream();
formatter.writeTo(messageContext, null, out, false);
assertTrue(JsonDataSourceTest.expectedJSON.equals(out.toString()));
} catch (FileNotFoundException e) {
e.printStackTrace();
assertTrue(false);
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
assertTrue(false);
}
}
use of org.apache.axis2.context.MessageContext in project wso2-synapse by wso2.
the class JsonFormatterTest method testGetBytesXML.
public void testGetBytesXML() throws AxisFault, XMLStreamException {
JsonFormatter formatter = new JsonFormatter();
MessageContext messageContext = Util.newMessageContext("<name>WSO2</name>");
byte[] bytes = formatter.getBytes(messageContext, null);
assertEquals("Invalid content received", "{\"name\":\"WSO2\"}", new String(bytes));
}
Aggregations