@Test
    public void testDetectRegExPDF() throws Exception {
        MediaType pdf = new MediaType("application", "pdf");
        Detector detector =
                new MagicDetector(pdf, "(?s)\\A.{0,144}%PDF-".getBytes(US_ASCII), null, true, 0, 0);

        assertDetect(detector, pdf, "%PDF-1.0");
        assertDetect(detector, pdf, "0        10        20        30        40        50        6" +
                "0        70        80        90        100       110       1" +
                "20       130       140" + "34%PDF-1.0");
        assertDetect(detector, MediaType.OCTET_STREAM,
                "0        10        20        30        40        50        6" +
                        "0        70        80        90        100       110       1" +
                        "20       130       140" + "345%PDF-1.0");
        assertDetect(detector, MediaType.OCTET_STREAM, "");
    }
Test cases for the {@link MagicDetector} class.
tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java