use of org.apache.axis2.format.PlainTextFormatter in project wso2-axis2-transports by wso2.
the class PlainTextFormatterTest method testGetBytes.
private void testGetBytes(String encoding) throws Exception {
MessageContext messageContext = createMessageContext(testString);
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(encoding);
byte[] bytes = new PlainTextFormatter().getBytes(messageContext, format);
assertEquals(testString, new String(bytes, encoding));
}
use of org.apache.axis2.format.PlainTextFormatter in project wso2-axis2-transports by wso2.
the class PlainTextFormatterTest method testWriteTo.
private void testWriteTo(String encoding) throws Exception {
MessageContext messageContext = createMessageContext(testString);
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(encoding);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new PlainTextFormatter().writeTo(messageContext, format, baos, false);
assertEquals(testString, new String(baos.toByteArray(), encoding));
}
use of org.apache.axis2.format.PlainTextFormatter in project wso2-axis2-transports by wso2.
the class PlainTextFormatterTest method testElementGetBytes.
private void testElementGetBytes(String encoding) throws Exception {
MessageContext messageContext = createElementMessageContextElement(testElementString);
if (messageContext != null) {
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(encoding);
byte[] bytes = new PlainTextFormatter().getBytes(messageContext, format);
assertEquals(testElementString, new String(bytes, encoding));
} else {
assertTrue(false);
}
}
Aggregations