private static void checkXmlContent(final String xml, final String encoding, final String defaultEncoding) throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final XmlStreamWriter writer = new XmlStreamWriter(out, defaultEncoding); writer.write(xml); writer.close(); final byte[] xmlContent = out.toByteArray(); assertEquals(encoding, writer.getEncoding()); assertTrue(Arrays.equals(xml.getBytes(encoding), xmlContent)); }
@Test public void testEmpty() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final XmlStreamWriter writer = new XmlStreamWriter(out); writer.flush(); writer.write(""); writer.flush(); writer.write("."); writer.flush(); writer.close(); }