Search in sources :

Example 1 with OutputStreamXmlWriter

use of org.apache.axiom.core.stream.serializer.writer.OutputStreamXmlWriter in project webservices-axiom by apache.

the class OutputStreamXmlWriterTest method testUnmappableCharacterToCharacterReference.

@Test
public void testUnmappableCharacterToCharacterReference() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XmlWriter writer = new OutputStreamXmlWriter(baos, Charset.forName("iso-8859-1"));
    writer.setUnmappableCharacterHandler(UnmappableCharacterHandler.CONVERT_TO_CHARACTER_REFERENCE);
    writer.write("abc€def");
    writer.flushBuffer();
    assertThat(baos.toString("iso-8859-1")).isEqualTo("abc€def");
}
Also used : OutputStreamXmlWriter(org.apache.axiom.core.stream.serializer.writer.OutputStreamXmlWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) XmlWriter(org.apache.axiom.core.stream.serializer.writer.XmlWriter) OutputStreamXmlWriter(org.apache.axiom.core.stream.serializer.writer.OutputStreamXmlWriter) Test(org.junit.Test)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStreamXmlWriter (org.apache.axiom.core.stream.serializer.writer.OutputStreamXmlWriter)1 XmlWriter (org.apache.axiom.core.stream.serializer.writer.XmlWriter)1 Test (org.junit.Test)1