testHttpLenient("text/html;charset=UTF-16BE", "no-bom", "US-ASCII", "UTF-8", "UTF-8");
}
public void testAlternateDefaultEncoding(final String cT, final String bomEnc, final String streamEnc, final String prologEnc, final String alternateEnc)
throws Exception {
XmlReader xmlReader = null;
try {
final InputStream is;
if (prologEnc == null) {
is = getXmlStream(bomEnc, XML1, streamEnc, prologEnc);
} else {
is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc);
}
XmlReader.setDefaultEncoding(alternateEnc);
xmlReader = new XmlReader(is, cT, false);
if (!streamEnc.equals("UTF-16")) {
// we can not assert things here becuase UTF-8, US-ASCII and
// ISO-8859-1 look alike for the chars used for detection
} else {
assertEquals(xmlReader.getEncoding().substring(0, streamEnc.length()), streamEnc);
}
} finally {
XmlReader.setDefaultEncoding(null);
if (xmlReader != null) {
xmlReader.close();
}
}
}