@Test
public void testDetect() {

    assertDetect(MediaType.TEXT_PLAIN, "text/plain");
    assertDetect(MediaType.TEXT_PLAIN, "TEXT/PLAIN");
    assertDetect(MediaType.TEXT_PLAIN, " text/\tplain\n");
    assertDetect(TEXT_PLAIN_A_EQ_B, "text/plain; a=b");
    assertDetect(TEXT_PLAIN_A_EQ_B, "\ttext/plain; a=b\n");
    assertDetect(MediaType.OCTET_STREAM, "text\\plain");
    // test also the zero input cases
    assertDetect(MediaType.OCTET_STREAM, "");
    assertDetect(MediaType.OCTET_STREAM, null);
    try {
        assertEquals(
                MediaType.OCTET_STREAM,
                detector.detect(null, new Metadata()));
    } catch (IOException e) {
        fail("TypeDetector should never throw an IOException");
    }
}