use of org.apache.axiom.util.base64.Base64EncodingStringBufferOutputStream in project webservices-axiom by apache.
the class TextContent method appendTo.
@Override
public void appendTo(StringBuilder buffer) {
if (binary) {
Base64EncodingStringBufferOutputStream out = new Base64EncodingStringBufferOutputStream(buffer);
try {
getDataHandler().writeTo(out);
out.complete();
} catch (IOException ex) {
throw new OMException(ex);
}
} else {
buffer.append(value);
}
}
use of org.apache.axiom.util.base64.Base64EncodingStringBufferOutputStream in project webservices-axiom by apache.
the class XMLStreamReaderUtilsTest method testGetDataHandlerFromElementNonCoalescing.
private void testGetDataHandlerFromElementNonCoalescing(boolean useDHR) throws Exception {
// We generate base64 that is sufficiently large to force the parser to generate
// multiple CHARACTER events
StringBuffer buffer = new StringBuffer("<test>");
Base64EncodingStringBufferOutputStream out = new Base64EncodingStringBufferOutputStream(buffer);
byte[] data = new byte[65536];
new Random().nextBytes(data);
out.write(data);
out.complete();
buffer.append("</test>");
XMLStreamReader reader = StAXUtils.createXMLStreamReader(StAXParserConfiguration.NON_COALESCING, new StringReader(buffer.toString()));
if (useDHR) {
reader = new XMLStreamReaderWithDataHandlerReader(reader);
}
try {
reader.next();
// Check precondition
assertTrue(reader.isStartElement());
DataHandler dh = XMLStreamReaderUtils.getDataHandlerFromElement(reader);
// Check postcondition
assertTrue(reader.isEndElement());
assertTrue(Arrays.equals(data, IOUtils.toByteArray(dh.getInputStream())));
} finally {
reader.close();
}
}
Aggregations