@Test
    @Timeout(60000)
    public void testWaitAfterEarlyTermination() throws Exception {
        Path outputDir = getNewOutputDir("wait_after_early_termination");

        Map<String, String> args = getDefaultArgs("wait_after_early_termination", outputDir);
        args.put("numConsumers", "1");
        args.put("maxAliveTimeSeconds", "5");//main process loop should stop after 5 seconds
        args.put("timeoutThresholdMillis", "300000");//effectively never
        args.put("pauseOnEarlyTerminationMillis", "20000");//let the parser have up to 20 seconds

        BatchProcessTestExecutor ex = new BatchProcessTestExecutor(args);

        StreamStrings streamStrings = ex.execute();
        assertEquals(1, countChildren(outputDir));
        assertContains("<p>some content</p>", readFileToString(outputDir.resolve("test0_sleep.xml.xml"), UTF_8));

        assertContains("exitStatus=" + BatchProcessDriverCLI.PROCESS_RESTART_EXIT_CODE, streamStrings.getOutString());
        assertContains("causeForTermination='BATCH_PROCESS_ALIVE_TOO_LONG'", streamStrings.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