@Test
    public void testStreaming() throws Exception {
        String expectedDigest = digest("testJAR.jar");
        DefaultZipContainerDetector detector = new DefaultZipContainerDetector();
        try (InputStream is = TikaInputStream.get(getStream("testJAR.jar"))) {
            assertExpected(detector, is, "application/java-archive", expectedDigest);
        }

        for (int markLimit : new int[]{-1,0,10,100,1000}) {
            detector = new DefaultZipContainerDetector();
            //mark limit is ignored for a TikaInputStream
            try (InputStream is = TikaInputStream.get(getStream("testJAR.jar"))) {
                detector.setMarkLimit(markLimit);
                assertExpected(detector, is, "application/java-archive", expectedDigest);
            }
        }

        detector = new DefaultZipContainerDetector();
        //mark limit is ignored for a TikaInputStream
        try (InputStream is = TikaInputStream.get(getStream("testJAR.jar"))) {
            detector.setMarkLimit(-1);
            assertExpected(detector, is, "application/java-archive", expectedDigest);
        }

        detector = new DefaultZipContainerDetector();
        //try on a file that isn't a TikaInputStream
        try (InputStream is = new BufferedInputStream(Files.newInputStream(TikaInputStream.get(getStream("testJAR.jar")).getPath()))) {
            assertExpected(detector, is, "application/java-archive", expectedDigest);
        }

        detector = new DefaultZipContainerDetector();
        try (InputStream is = ZipDetectionTest.class.getResourceAsStream("/test-documents/testJAR.jar")) {
            assertExpected(detector, is, "application/java-archive", expectedDigest);
        }

        detector = new DefaultZipContainerDetector();
        detector.setMarkLimit(100);
        try (InputStream is = ZipDetectionTest.class.getResourceAsStream("/test-documents/testJAR.jar")) {
            assertExpected(detector, is, "application/zip", expectedDigest);
        }

        detector = new DefaultZipContainerDetector();
        detector.setMarkLimit(0);
        try (InputStream is = ZipDetectionTest.class.getResourceAsStream("/test-documents/testJAR.jar")) {
            assertExpected(detector, is, "application/zip", expectedDigest);
        }

        detector = new DefaultZipContainerDetector();
        detector.setMarkLimit(100000);
        try (InputStream is = ZipDetectionTest.class.getResourceAsStream("/test-documents/testJAR.jar")) {
            assertExpected(detector, is, "application/java-archive", expectedDigest);
        }
    }
Test cases for detecting zip-based files.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-zip-commons/src/test/java/org/apache/tika/detect/zip/ZipDetectionTest.java