@Test
    public void testDetectMask() throws Exception {
        MediaType html = new MediaType("text", "html");
        byte up = (byte) 0xdf;
        Detector detector = new MagicDetector(html, new byte[]{'<', 'H', 'T', 'M', 'L'},
                new byte[]{(byte) 0xff, up, up, up, up}, 0, 64);

        assertDetect(detector, html, "<html");
        assertDetect(detector, html, "<HTML><head/><body/></html>");
        assertDetect(detector, html, "<?xml?><HtMl/>");
        assertDetect(detector, html, "\n    <html");
        assertDetect(detector, html, "\u0000<HTML");
        assertDetect(detector, MediaType.OCTET_STREAM, "<htm");
        assertDetect(detector, MediaType.OCTET_STREAM, " html");

        assertDetect(detector, html,
                "0        1         2         3         4         5         6" + "1234<html");
        assertDetect(detector, MediaType.OCTET_STREAM,
                "0        1         2         3         4         5         6" + "12345<html");

        assertDetect(detector, MediaType.OCTET_STREAM, "");
    }
Test cases for the {@link MagicDetector} class.
tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java