@Test
    public void testHandlingOfIllegalXMLCharsInException() throws Exception {
        //tests to make sure that hierarchy is maintained when reading from
        //file list
        //also tests that list actually works.
        Path outputDir = getNewOutputDir("illegal_xml_chars_in_exception");

        Map<String, String> args = getDefaultArgs("illegal_xml_chars_in_exception", outputDir);
        args.put("numConsumers", "1");
        args.put("recursiveParserWrapper", "true");
        args.put("basicHandlerType", "text");

        BatchProcessTestExecutor ex = new BatchProcessTestExecutor(args, "/tika-batch-config-MockConsumersBuilder.xml", "/log4j2-on.properties");
        StreamStrings ss = ex.execute();
        assertFalse(ss
                .getOutString()
                .contains("error writing xml stream for"));
        assertContains("parse_ex resourceId=\"test0_bad_chars.xml\"", ss.getOutString());
    }
This tests to make sure that BatchProcess waits the appropriate
amount of time on an early termination before stopping.
<p>
If this fails, then interruptible parsers (e.g. those with
nio channels) will be interrupted and there will be corrupted data.
tika-batch/src/test/java/org/apache/tika/batch/fs/BatchProcessTest.java