@Test
    public void testDetectString() throws Exception {
        String data = "abcdEFGhijklmnoPQRstuvwxyz0123456789";
        MediaType testMT = new MediaType("application", "test");
        Detector detector;

        // Check regular String matching
        detector = MagicDetector.parse(testMT, "string", "0:20", "abcd", null);
        assertDetect(detector, testMT, data.getBytes(US_ASCII));
        detector = MagicDetector.parse(testMT, "string", "0:20", "cdEFGh", null);
        assertDetect(detector, testMT, data.getBytes(US_ASCII));

        // Check Little Endian and Big Endian utf-16 strings
        detector = MagicDetector.parse(testMT, "unicodeLE", "0:20", "cdEFGh", null);
        assertDetect(detector, testMT, data.getBytes(UTF_16LE));
        detector = MagicDetector.parse(testMT, "unicodeBE", "0:20", "cdEFGh", null);
        assertDetect(detector, testMT, data.getBytes(UTF_16BE));

        // Check case ignoring String matching
        detector = MagicDetector.parse(testMT, "stringignorecase", "0:20", "BcDeFgHiJKlm", null);
        assertDetect(detector, testMT, data.getBytes(US_ASCII));
    }
Test cases for the {@link MagicDetector} class.
tika-core/src/test/java/org/apache/tika/detect/MagicDetectorTest.java