class XlsDetector extends POIFSContainerDetector implements Detector {

    @Override
    public Format detect(Metadata metadata, TikaInputStream inputStream) throws IOException {

        Format result = null;

        MediaType mediaType = super.detect(inputStream, metadata);
        if (mediaType == null || StringUtils.equals(mediaType.toString(), FormatUtils.UNKNOWN_MEDIA_TYPE)) {
            mediaType = zipContainerDetector.detect(inputStream, new Metadata());
        }

        if (mediaType != null) {
            String mediaTypeName = mediaType.toString();
            if (StringUtils.startsWith(mediaTypeName, XlsFormatFamily.MEDIA_TYPE)
                    || StringUtils.equals(mediaTypeName, OLD_XLS_MEDIA_TYPE)) {
                result = new Format(xlsFormatFamily, FormatUtils.DEFAULT_ENCODING);
            }
        }

        return result;
    }

}

class XlsDetectorTest extends POIFSContainerDetector {

    @Autowired XlsDetector xlsDetector;

    @Test
    public void read_xls_that_can_be_parsed_as_csv_TDP_375() throws Exception {


        String fileName = "TDP-375_xsl_read_as_csv.xls";

        try (InputStream inputStream = this.getClass().getResourceAsStream(fileName)) {
            Format actual = xlsDetector.detect(inputStream);
            Assert.assertNotNull(actual);
            assertTrue(actual.getFormatFamily() instanceof XlsFormatFamily);
            assertEquals(XlsFormatFamily.MEDIA_TYPE, actual.getFormatFamily().getMediaType());
            assertTrue(StringUtils.equals("UTF-8", actual.getEncoding()));
        }

    }

}