XMLStreamWriterEx writer = (XMLStreamWriterEx)buffer.createFromXMLStreamWriter();
writer.writeStartDocument();
writer.writeStartElement("foo");
writer.writeBinary(bytes, 0, bytes.length, null);
writer.writeEndElement();
writer.writeEndDocument();
assertTrue(buffer.isCreated());
return buffer;
}