private void assertRemovalTempfiles(String fileName) throws Exception {
        int numberOfTempFiles = countTemporaryFiles();

        try (TikaInputStream stream = TikaInputStream
                .get(getResourceAsUrl("/test-documents/" + fileName))) {
            detector.detect(stream, new Metadata());
        }

        assertEquals(numberOfTempFiles, countTemporaryFiles());
    }
Check that temporary files created by Tika are removed after
closing TikaInputStream.
tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java