### Question:
XmlStreamReader extends Reader { public String getEncoding() { return encoding; } XmlStreamReader(final File file);  XmlStreamReader(final InputStream is);  XmlStreamReader(final InputStream is, final boolean lenient);  XmlStreamReader(final InputStream is, final boolean lenient, final String defaultEncoding);  XmlStreamReader(final URL url);  XmlStreamReader(final URLConnection conn, final String defaultEncoding);  XmlStreamReader(final InputStream is, final String httpContentType);  XmlStreamReader(final InputStream is, final String httpContentType,
            final boolean lenient, final String defaultEncoding);  XmlStreamReader(final InputStream is, final String httpContentType,
            final boolean lenient); String getDefaultEncoding(); String getEncoding(); @Override int read(final char[] buf, final int offset, final int len); @Override void close(); static final Pattern ENCODING_PATTERN; }### Answer:
@Test public void testRawContent() throws Exception { final String encoding = "UTF-8"; final String xml = getXML("no-bom", XML3, encoding, encoding); final ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(encoding)); final XmlStreamReader xmlReader = new XmlStreamReader(is); assertEquals("Check encoding", xmlReader.getEncoding(), encoding); assertEquals("Check content", xml, IOUtils.toString(xmlReader)); }
@Test public void testHttpContent() throws Exception { final String encoding = "UTF-8"; final String xml = getXML("no-bom", XML3, encoding, encoding); final ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(encoding)); final XmlStreamReader xmlReader = new XmlStreamReader(is, encoding); assertEquals("Check encoding", xmlReader.getEncoding(), encoding); assertEquals("Check content", xml, IOUtils.toString(xmlReader)); }