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

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

        BatchProcessTestExecutor ex = new BatchProcessTestExecutor(args);
        StreamStrings streamStrings = ex.execute();
        List<Path> paths = listPaths(outputDir);
        assertEquals(1, paths.size());
        assertEquals(0, Files.size(paths.get(0)));
        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