Latin1StringsParser extends AbstractParser { @Override public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException { new Latin1StringsParser().doParse(stream, handler, metadata, context); }  int getMinSize(); void setMinSize(int minSize); @Override Set<MediaType> getSupportedTypes(ParseContext arg0); @Override void parse(InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context);  }
@Test public void testParse() throws Exception { String testStr = "These are Latin1 accented scripts: \u00C2 \u00C3 \u00C9 \u00DC \u00E2 \u00E3 \u00E9 \u00FC"; String smallStr = "ab"; byte[] iso8859Bytes = testStr.getBytes(ISO_8859_1); byte[] utf8Bytes = testStr.getBytes(UTF_8); byte[] utf16Bytes = testStr.getBytes(UTF_16); byte[] zeros = new byte[10]; byte[] smallString = smallStr.getBytes(ISO_8859_1); byte[] trashBytes = { 0x00, 0x01, 0x02, 0x03, 0x1E, 0x1F, (byte) 0xFF }; ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos.write(iso8859Bytes); baos.write(zeros); baos.write(utf8Bytes); baos.write(trashBytes); baos.write(utf16Bytes); baos.write(zeros); baos.write(smallString); Parser parser = new Latin1StringsParser(); ContentHandler handler = new BodyContentHandler(); try (InputStream stream = new ByteArrayInputStream(baos.toByteArray())) { parser.parse(stream, handler, new Metadata(), new ParseContext()); } String result = handler.toString(); String expected = testStr + "\n" + testStr + "\n" + testStr + "\n"; assertTrue(result.equals(expected)); }