Search in sources :

Example 1 with PlainTextFormatter

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));
}
Also used : MessageContext(org.apache.axis2.context.MessageContext) OMOutputFormat(org.apache.axiom.om.OMOutputFormat) PlainTextFormatter(org.apache.axis2.format.PlainTextFormatter)

Example 2 with PlainTextFormatter

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));
}
Also used : MessageContext(org.apache.axis2.context.MessageContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OMOutputFormat(org.apache.axiom.om.OMOutputFormat) PlainTextFormatter(org.apache.axis2.format.PlainTextFormatter)

Example 3 with PlainTextFormatter

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);
    }
}
Also used : MessageContext(org.apache.axis2.context.MessageContext) OMOutputFormat(org.apache.axiom.om.OMOutputFormat) PlainTextFormatter(org.apache.axis2.format.PlainTextFormatter)

Aggregations

OMOutputFormat (org.apache.axiom.om.OMOutputFormat)3 MessageContext (org.apache.axis2.context.MessageContext)3 PlainTextFormatter (org.apache.axis2.format.PlainTextFormatter)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1