ContentHandlerExample { public String parseToHTML() throws IOException, SAXException, TikaException { ContentHandler handler = new ToXMLContentHandler(); AutoDetectParser parser = new AutoDetectParser(); Metadata metadata = new Metadata(); try (InputStream stream = ContentHandlerExample.class.getResourceAsStream("test.doc")) { parser.parse(stream, handler, metadata); return handler.toString(); } }  String parseToPlainText(); String parseToHTML(); String parseBodyToHTML(); String parseOnePartToHTML(); List<String> parseToPlainTextChunks();  }
@Test public void testParseToHTML() throws IOException, SAXException, TikaException { String result = example.parseToHTML().trim(); assertContains("<html", result); assertContains("<head>", result); assertContains("<meta name=\"dc:creator\"", result); assertContains("<title>", result); assertContains("<body>", result); assertContains(">test", result); }